http://stackoverflow.com/a/50892690
answers question: http://stackoverflow.com/q/2598129
score: 0
type: Answer
has body: Question: Remove Duplicate characters in a string Method 1 :(Python) import collections a = "GiniGinaProtijayi" aa = collections.OrderedDict().fromkeys(a) print(''.join(aa)) Method 2 :(Python) a = "GiniGinaProtijayi" list = [] aa = [ list.append(ch) for ch in a if ch not in list] print( ''.join(list)) IN Java: class test2{ public static void main(String[] args) { String a = "GiniGinaProtijayi"; List&lt;Character&gt; list = new ArrayList&lt;&gt;(); for(int i = 0 ; i &lt; a.length() ;i++) { char ch = a.charAt(i); if( list.size() == 0 ) {list.add(ch);} if(!list.contains(ch)) {list.add(ch) ;} }//for StringBuffer sbr = new StringBuffer(); for( char ch : list) {sbr.append(ch);} System.out.println(sbr); }//main }//end

http://stackoverflow.com/a/2696061
accepted answer of: http://stackoverflow.com/q/2670133
downvote count: 0
answers question: http://stackoverflow.com/q/2670133
type: AcceptedAnswer
score: 4
has body: You can use several routes to branch out the workflow, like this from("queue:start"). choice().xpath("//foo")).to("queue:taskB"). otherwise().to("queue:taskA"); from("queue:taskB").process(new DoTaskB()).to("queue:taskA"); from("queue:taskA").process(new DoTaskA()).to("queue:done");
type: Answer
upvote count: 4

http://stackoverflow.com/comment/2763085
has text: I think small is a poor way of expressing the problem. You can come up with trivially large examples which have the same problem. Let n be any "large enough" number to satisfy your "it's no longer small" criteria. Then compare the bitwise-or and arithmetic add values of shifting 1 by n and (n-1). See my point? I think the important bit is that the binary representation of the numbers chosen were not sufficiently varied. That said the animated gif was awesome. :)
comment on: http://stackoverflow.com/a/2735017
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/2785964
has answer: http://stackoverflow.com/a/2786019
type: Question
upvote count: 87
accepted answer: http://stackoverflow.com/a/2786019
tagged with: optimization
answer count: 2
score: 87
downvote count: 0
has body: In ArrayBlockingQueue, all the methods that require the lock copy it to a local final variable before calling lock(). public boolean offer(E e) { if (e == null) throw new NullPointerException(); final ReentrantLock lock = this.lock; lock.lock(); try { if (count == items.length) return false; else { insert(e); return true; } } finally { lock.unlock(); } } Is there any reason to copy this.lock to a local variable lock when the field this.lock is final? Additionally, it also uses a local copy of E[] before acting on it: private E extract() { final E[] items = this.items; E x = items[takeIndex]; items[takeIndex] = null; takeIndex = inc(takeIndex); --count; notFull.signal(); return x; } Is there any reason for copying a final field to a local final variable?
favorite count: 0
has answer: http://stackoverflow.com/a/15407563
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/15407563
has title: In ArrayBlockingQueue, why copy final member field into local final variable?
tagged with: final
tagged with: java
tagged with: multithreading
tagged with: local-variables

http://stackoverflow.com/q/2633770
type: Question
has comment: http://stackoverflow.com/comment/2647617
has comment: http://stackoverflow.com/comment/2647940
has title: HIbernate query language problem
score: 0
answer count: 1
has comment: http://stackoverflow.com/comment/2647602
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/2649872
has body: I have a Project class that has a Set of userstories called userStories12many. I'm having troubles trying to get the project that has a certain userstory in its set getComponent(int userStoryID) I think im on the right track but i dont know what i did wrong public Projects getComponent(int userStoryID) { Session session = SessionFactoryHelper.getSessionFactory() .getCurrentSession(); session.beginTransaction(); List&lt;Projects&gt; compo = session.createQuery("select p " + "from Projects as p inner join fetch p.userStories12many as u " + "where u.storyId='" + userStoryID + "'").list(); session.getTransaction().commit(); return compo.get(0); }
tagged with: java
tagged with: hibernate
has comment: http://stackoverflow.com/comment/2647805
has comment: http://stackoverflow.com/comment/2647687
has answer: http://stackoverflow.com/a/2633903

http://stackoverflow.com/a/2622325
answers question: http://stackoverflow.com/q/2622104
has comment: http://stackoverflow.com/comment/2634739
has comment: http://stackoverflow.com/comment/2635396
score: 0
has body: You must call the start() method of the timer to start it. public ShowMe(){ timer = new javax.swing.Timer(20, new MoveListener()); timer.start(); } EDIT: I have not seen that start() is being called in the Test class... Next step would be to add some logging/printing to the MouseListener class to check if it is being called or not private class MoveListener implements ActionListener { public void actionPerformed(ActionEvent e) { System.out.println("MouseListener activated"); // TODO delete this line // some code here to perform the animation } } If it's running (I can't find any reason why not in the posted code), the problem is as Ash wrote above: You created a new instance assigned to vis and started its Timer, but you have not added that instance to any visible container. (maybe you added another instance of ShowMe earlier in the code...)
type: Answer

http://stackoverflow.com/a/2659385
type: Answer
downvote count: 0
score: 1
accepted answer of: http://stackoverflow.com/q/2659183
answers question: http://stackoverflow.com/q/2659183
has body: This is recognizeable as an old and vulrenable feature of Tomcat's builtin InvokerServlet. To fix this, disable it in Tomcat's /conf.web.xml by removing or outcommenting the <servlet> and <servlet-mapping> entries associated with invoker . This was a security hole in the ancient Tomcat versions and was fixed in Tomcat 5 and upwards where it is been deprecated and by default disabled. It will be removed in Tomcat 7. You need to explicitly define all of the servlets in webapp's web.xml yourself along with a decent url-pattern. If you have pretty a lot of servlets, consider the Front Controller Pattern, i.e. just only one servlet which delegates and executes the desired business logic based on under each the request method, request URI, request pathinfo and so on.
upvote count: 1
type: AcceptedAnswer

http://stackoverflow.com/a/2712897
answers question: http://stackoverflow.com/q/2712880
score: -2
downvote count: 2
has comment: http://stackoverflow.com/comment/2737771
has body: If the Exception is never caught, the thread is terminated. If this is your main thread, the application ends. Try the following: try { props.load(...); } catch (FileNotFoundException ex) { Thread.sleep(x * 1000); props.load(...); }
has comment: http://stackoverflow.com/comment/2737762
type: Answer
upvote count: 0

http://stackoverflow.com/comment/2708035
type: Comment
comment on: http://stackoverflow.com/a/2687254
has text: ... which is actually a helpful answer, since the question did not mention particle systems at all, and they *can* be used to create more realistic explosions.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/139950410
type: Comment
comment on: http://stackoverflow.com/a/58846892
has text: this answer is out of scope. You are giving answer something converting list to array. Not the answer for converting array to list. But for the answer you ask for is : with list.toArray(new WeatherStation[0]) part, it creates a new array of same type and size of it is fit to the list's contents.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/2650050
has text: @Boris: technically yes, but the idea is to use a domain that you "control" in order to avoid conflicts. Also: prefixing "com.google" implies ownership or at least endorsement by Google which may or may not be desired.
type: Comment
comment on: http://stackoverflow.com/q/2636080
score: 0
type: QuestionComment

http://stackoverflow.com/q/2636432
has answer: http://stackoverflow.com/a/2636458
has body: My idea is to create a .jar file that contains Services managed by Spring, that should be got by getBean() I want to put it to WEB-INF/lib of a Web-app Then in web-app Servlets I want to get use of the functionality of a Jar file. 1 Idea. Create classes that encapsulate invokation to Spring Context (getBean() etc) For example, the class I'll be using will simply get a parameter and return a parameter, but inside that class there'll be an invocation to Spring's getBean etc. In this case, I suppose there'll be no problem in using those in Servlets through jar import. Only thing, what kind of context I should use inside .jar to get beans so that it worked after packing into jar? ApplicationContext or what? 2 Idea. Is there another simple solution how to pack into jar and then use Services in a non-managed by Spring environment?
score: 0
answer count: 2
possible better answer: http://stackoverflow.com/a/2636458
tagged with: tomcat
has title: Non-managed by Spring web-application and jar file with Spring features
has answer: http://stackoverflow.com/a/2636533
tagged with: spring
type: AnsweredQuestion
type: Question
accepted answer: http://stackoverflow.com/a/2636533
tagged with: java
tagged with: servlets

http://stackoverflow.com/comment/2812075
comment on: http://stackoverflow.com/a/2777526
has text: @mmr: Using a better algorithm isn't cheating - it's just being smart and using all given information to optimize your program.
type: Comment
score: 2
type: AnswerComment

http://stackoverflow.com/comment/2774717
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2745003
has text: @Dan, Java has no way of freeing memory, with your own caches or otherwise. If you disabled GC, then the memory footprint would grow (probably surprisingly quickly) and the JVM would crash very quickly.
score: 0

http://stackoverflow.com/a/2756715
has comment: http://stackoverflow.com/comment/2788200
type: Answer
score: 2
accepted answer of: http://stackoverflow.com/q/2756626
has comment: http://stackoverflow.com/comment/2788195
answers question: http://stackoverflow.com/q/2756626
has comment: http://stackoverflow.com/comment/2788350
type: AcceptedAnswer
downvote count: 0
has body: On Sun's Windows JDK, the thread will in fact throw InterruptedException when entering sleep(): public static final void main(String args[]) throws Exception { final Thread main = Thread.currentThread(); Thread t = new Thread() { @Override public void run() { main.interrupt(); } }; t.start(); t.join(); Thread.sleep(1000); System.out.println("Not interrupted!"); } The API documentation of sleep() can be interpreted to mean that this is mandatory behaviour: throws InterruptedException - if any thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown. But that's not very clear, so I wouldn't depend on it and instead check isInterrupted() manually.
upvote count: 2

http://stackoverflow.com/comment/72991164
type: AnswerComment
type: Comment
has text: @vorburger When using *any* port, care should be taken to close it. `new ServerSocket(0)` is not different in this respect. There is nothing whatsoever in your first link about this. Your second link merely exhibits poor practice. Once you've constructed the `ServerSocket` you should *use* it, not *close* it and try to reuse the same port number. All that is a *complete waste of time,* as well as being vulnerable to timing-window problems.
score: 2
comment on: http://stackoverflow.com/a/2675416

http://stackoverflow.com/comment/2674543
comment on: http://stackoverflow.com/a/2657537
type: Comment
type: AnswerComment
has text: Do you ever leak the reference to the `int[]` or do you always keep it private?
score: 0

http://stackoverflow.com/comment/2680842
score: 4
has text: To be fair, most of "knowing algorithms" is like this -- unless you're doing research-level things!
comment on: http://stackoverflow.com/q/2663115
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2621177
downvote count: 0
score: 4
has title: How is Object[] cloneable
has body: Object[] o = new Object[]{}; System.out.println(o instanceof Cloneable); This gives true as o/p. I could not understand why?
favorite count: 0
tagged with: instanceof
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2621186
has answer: http://stackoverflow.com/a/2621189
tagged with: java
type: Question
upvote count: 4
answer count: 2
tagged with: cloneable
tagged with: arrays

http://stackoverflow.com/q/2622725
has body: how to take user input in Array using Java? i.e we are not initializing it by ourself in our program but the user is going to give its value.. please guide!!
type: AnsweredQuestion
has title: how to take user input in Array using java?
score: 7
tagged with: java
has answer: http://stackoverflow.com/a/2622736
upvote count: 7
has answer: http://stackoverflow.com/a/71766240
type: Question
accepted answer: http://stackoverflow.com/a/2623292
has answer: http://stackoverflow.com/a/52479127
downvote count: 0
possible better answer: http://stackoverflow.com/a/7702240
has answer: http://stackoverflow.com/a/28647721
has answer: http://stackoverflow.com/a/7702240
has answer: http://stackoverflow.com/a/3846171
has answer: http://stackoverflow.com/a/2623578
favorite count: 0
tagged with: java.util.scanner
linked to: http://stackoverflow.com/q/2391553
answer count: 9
has answer: http://stackoverflow.com/a/2623292
has answer: http://stackoverflow.com/a/60181407
linked to: http://stackoverflow.com/q/2538718

http://stackoverflow.com/a/2722774
has comment: http://stackoverflow.com/comment/2759602
type: AcceptedAnswer
type: Answer
has comment: http://stackoverflow.com/comment/2758878
has body: You should use openRawResource() to access items in R.raw. To access the SD card, check out resources like this post.
has comment: http://stackoverflow.com/comment/2759044
answers question: http://stackoverflow.com/q/2721839
score: 0
accepted answer of: http://stackoverflow.com/q/2721839

http://stackoverflow.com/comment/53577613
score: 0
type: Comment
has text: Yes I perhaps should make my use case more clear. I work on mainly content management (HTML editing) things.
comment on: http://stackoverflow.com/a/4847599
type: AnswerComment

http://stackoverflow.com/comment/2825264
has text: Unfortunately i've changed my code a lot so it's harder now to reproduce the environment. Anyway the problem seems to be in the Hibernate Session management between different test executions. The base class gets the session object to export the schema by calling HibernateUtil.getCurrentSession(), then the test class executes some dao methods that internally get the session object in the same way. When the second test is executed, the HibernateUtil.getCurrentSession() returns an invalid session and all sort of exceptions are thrown by Hibernate. Here is the stack trace of the exception:
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2759817
type: Comment

http://stackoverflow.com/a/2735812
answers question: http://stackoverflow.com/q/2628534
has body: This is provided here just for reference. This is essentially Alan's solution, but using replace instead of String.format. public String plusOut(String str, String word) { return str.replaceAll( "(?&lt;!(?=word).{0,M})." .replace("word", java.util.regex.Pattern.quote(word)) .replace("M", String.valueOf(word.length()-1)), "+" ); }
score: 0
type: Answer

jfreechart
type: Tag
tags question: http://stackoverflow.com/q/2701651
tags question: http://stackoverflow.com/q/2636791
tags question: http://stackoverflow.com/q/2602696
tags question: http://stackoverflow.com/q/2677704
tags question: http://stackoverflow.com/q/2721536
tag name: jfreechart

http://stackoverflow.com/a/37963331
downvote count: 0
answers question: http://stackoverflow.com/q/2614774
type: Answer
upvote count: 1
has body: Hy i had the same problem, but the couse for me was i was using the remote Debugging(VmArgs: -Xdebug -Xrunjdwp:transport=dt_socket,address=%port%,server=y,suspend=y) when i disabled this the java.exe Process exited as expected.
score: 1

http://stackoverflow.com/q/2624192
has comment: http://stackoverflow.com/comment/2636906
has answer: http://stackoverflow.com/a/2624385
favorite count: 0
has answer: http://stackoverflow.com/a/2624259
has body: I'm trying to think up a good hash function for strings. And I was thinking it might be a good idea to sum up the unicode values for the first five characters in the string (assuming it has five, otherwise stop where it ends). Would that be a good idea, or is it a bad one? I am doing this in Java, but I wouldn't imagine that would make much of a difference.
linked to: http://stackoverflow.com/q/1579721
tagged with: hash
possible better answer: http://stackoverflow.com/a/2624385
downvote count: 2
has comment: http://stackoverflow.com/comment/2636858
has answer: http://stackoverflow.com/a/2624439
has comment: http://stackoverflow.com/comment/2636886
has comment: http://stackoverflow.com/comment/105544730
has answer: http://stackoverflow.com/a/14387972
has answer: http://stackoverflow.com/a/12816123
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/125911110
has comment: http://stackoverflow.com/comment/108007265
has answer: http://stackoverflow.com/a/2624210
tagged with: hashcode
linked to: http://stackoverflow.com/q/7666509
tagged with: java
score: 198
has answer: http://stackoverflow.com/a/22515087
type: Question
has answer: http://stackoverflow.com/a/21614679
linked to: http://stackoverflow.com/q/98153
has answer: http://stackoverflow.com/a/2625646
has answer: http://stackoverflow.com/a/2624213
has answer: http://stackoverflow.com/a/44303629
upvote count: 200
has answer: http://stackoverflow.com/a/50438295
has answer: http://stackoverflow.com/a/14574712
accepted answer: http://stackoverflow.com/a/2624210
answer count: 14
has title: Good Hash Function for Strings
has answer: http://stackoverflow.com/a/2624218
has comment: http://stackoverflow.com/comment/2636902
has comment: http://stackoverflow.com/comment/2636859
tagged with: hashtable

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

http://stackoverflow.com/a/21068644
type: Answer
has comment: http://stackoverflow.com/comment/80732296
has comment: http://stackoverflow.com/comment/80723371
has comment: http://stackoverflow.com/comment/122586239
accepted answer of: http://stackoverflow.com/q/2749689
has comment: http://stackoverflow.com/comment/128714113
has comment: http://stackoverflow.com/comment/38122710
answers question: http://stackoverflow.com/q/2749689
has comment: http://stackoverflow.com/comment/93513261
has comment: http://stackoverflow.com/comment/121609008
has comment: http://stackoverflow.com/comment/138332413
has comment: http://stackoverflow.com/comment/95564854
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/105292158
has comment: http://stackoverflow.com/comment/77083277
has comment: http://stackoverflow.com/comment/60811620
has comment: http://stackoverflow.com/comment/137633278
has comment: http://stackoverflow.com/comment/60844280
score: 337
has body: Why is the notion of a owning side necessary: The idea of a owning side of a bidirectional relation comes from the fact that in relational databases there are no bidirectional relations like in the case of objects. In databases we only have unidirectional relations - foreign keys. What is the reason for the name 'owning side'? The owning side of the relation tracked by Hibernate is the side of the relation that owns the foreign key in the database. What is the problem that the notion of owning side solves? Take an example of two entities mapped without declaring a owning side: @Entity @Table(name="PERSONS") public class Person { @OneToMany private List<IdDocument> idDocuments; } @Entity @Table(name="ID_DOCUMENTS") public class IdDocument { @ManyToOne private Person person; } From a OO point of view this mapping defines not one bi-directional relation, but two separate uni-directional relations. Another way of thinking about the two uni-directional relations above could be as follows: if Person contains a List of documents they've written, the Document can also 'write' a Person, but only one. That is, an independent action is implied by each class. So one Person writes several documents (and a document can only be written by one person), and a Document writes only one Person (but several Documents can write the same Person). The mapping would create not only tables PERSONS and ID_DOCUMENTS, but would also create a third association table PERSONS_ID_DOCUMENTS: CREATE TABLE PERSONS_ID_DOCUMENTS ( persons_id bigint NOT NULL, id_documents_id bigint NOT NULL, CONSTRAINT fk_persons FOREIGN KEY (persons_id) REFERENCES persons (id), CONSTRAINT fk_docs FOREIGN KEY (id_documents_id) REFERENCES id_documents (id), CONSTRAINT pk UNIQUE (id_documents_id) ) Notice the primary key pk on ID_DOCUMENTS only. In this case Hibernate tracks both sides of the relation independently: If you add a document to relation Person.idDocuments, it inserts a record in the association table PERSON_ID…
upvote count: 337

http://stackoverflow.com/q/2622045
accepted answer: http://stackoverflow.com/a/2622163
tagged with: jpanel
tagged with: margins
tagged with: printing
downvote count: 0
answer count: 1
favorite count: 0
upvote count: 2
has title: How do I get hold of the margins of the Paper when using java printing?
has answer: http://stackoverflow.com/a/2622163
tagged with: margin
score: 2
type: AnsweredQuestion
tagged with: java
has body: I'm trying to print a JPanel with some painted graphics on it (overriding paintComponent). The graphics is so big that they wont fit on a single page and therefor I'm letting it span across multiple pages. My problem lies within the fact that if I let the user choose the pageFormat/Paper type by calling: PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); PageFormat pf = printJob.pageDialog(aset); printJob.setPrintable(canvas, pf); When I'm writing my print() method (implementing Printable) in my JPanel class I can't seem to get the hold of the margins? I use graphics.translate(pageFormat.getImageableX(), pageFormat.getImageableY()); to make it start drawing in the correct topleft corner (0;0) and it takes the margins into consideration (i.e.,starting more at (80; 100) or so). But then it prints over the bottom and right margin which I don't want it to do since that negates the user's wishes. Here is the code of my print() method as a reference, which works fine when you don't let the user set the paper (using the default instead): Rectangle[] pageBreaks; public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException { //Calculate how many pages our print will be if(pageBreaks == null){ double pageWidth = pageFormat.getPaper().getWidth(); double pageHeight = pageFormat.getPaper().getHeight(); //Find out how many pages we need int numberOfPagesHigh = (int) Math.ceil(size.getHeight()/pageHeight); int numberOfPagesWide = (int) Math.ceil(size.getWidth()/pageWidth); pageBreaks = new Rectangle[numberOfPagesHigh*numberOfPagesWide]; double x = 0; double y = 0; int curXPage = 0; //Calculate what we will print on each page for (int i = 0; i &lt; pageBreaks.length; i++){ double xStart = x; double yStart = y; x += pageWidth; pageBreaks[i] = new Rectangle((int)xStart, (int)yStart, (int)pageWidth, (int)pageHeight); curXPage++; if (curXPage &gt; numberOfPagesWide){ curXPage = 0; x = 0; y += pageHeight; } } } if (pageIndex &lt; pag…
type: Question

http://stackoverflow.com/comment/2665521
has text: No problem...I'd never heard of the Scanner class and now I can write more concise code :)
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2649331
type: Comment

http://stackoverflow.com/a/2624533
type: Answer
answers question: http://stackoverflow.com/q/2622937
accepted answer of: http://stackoverflow.com/q/2622937
type: AcceptedAnswer
has body: Try Chainsaw V2 - the supported expression syntax used to filter, search and colorize rows isn't SQL based, but provides a good amount of functionality (regexp queries, exists (not null), relational operators, etc). You can view information on the expression syntax from the help/tutorial menu. Chainsaw V2's home page: http://logging.apache.org/chainsaw/ You can run Chainsaw V2 via web start from the 'download' link on that page.
score: 0

communication
tags question: http://stackoverflow.com/q/2649631
tag name: communication
tags question: http://stackoverflow.com/q/2699816
tags question: http://stackoverflow.com/q/2682429
tags question: http://stackoverflow.com/q/2722949
type: Tag
tags question: http://stackoverflow.com/q/2775413

http://stackoverflow.com/q/2687441
duplicate of: http://stackoverflow.com/q/1857646
type: Question
upvote count: 4
answer count: 2
has title: Is there a standard constant in Java used to refer to HTTP request methods?
favorite count: 0
has body: Possible Duplicate: Where are the request method constants in the Servlet API? I'm looking for a Java string constant to refer to HTTP request methods (GET, POST, PUT, etc.). I expected HttpServlet or HttpServletRequest to have constants for these methods, but that doesn't seem to be the case.
possible better answer: http://stackoverflow.com/a/2687497
has answer: http://stackoverflow.com/a/2687453
has answer: http://stackoverflow.com/a/2687497
downvote count: 1
accepted answer: http://stackoverflow.com/a/2687453
type: AnsweredQuestion
score: 3
linked to: http://stackoverflow.com/q/1857646
tagged with: java
tagged with: servlets

http://stackoverflow.com/a/2612466
accepted answer of: http://stackoverflow.com/q/2612426
has comment: http://stackoverflow.com/comment/47344766
has comment: http://stackoverflow.com/comment/47338904
has body: The simplest way is still to download and installed the RCP edition of eclipse (that you are using). With it comes a series of project templates which will illustrate precisely the topics you want to explore, both for RCP standalone but also for Eclipse contribution itself. See this article and its next part for instance to add contributions to eclipse. One of the key innovations of e4 is the separation between the application model and the implementation of the application’s parts, such as view. The application model can be extended using fragments. A fragment is a small application model itself and defines elements which need to be added to the root application model. Fragments can add anything that can be part of the application model, for example handlers, menu items or even windows. Regarding the default Eclipse Plugin Development Templates, which are in org.eclipse.pde.ui.templates, Mr_and_Mrs_D reports in the coments: They are in New Project &gt; Plug-in Project (give it a name !) &gt; ...Next &gt; Templates. They are present to the Eclipse IDE for Eclipse Committers - and they belong indeed to org.eclipse.pde.ui.templates plugin.
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/47408705
upvote count: 8
type: Answer
score: 8
answers question: http://stackoverflow.com/q/2612426
has comment: http://stackoverflow.com/comment/47424947
has comment: http://stackoverflow.com/comment/47408743

http://stackoverflow.com/comment/2800610
comment on: http://stackoverflow.com/a/2766567
has text: it is a good idea, Thanks. Of-course I will need to set the eventHandler to be tolerant for the "field is required" error but it should not be a problem. I wonder if there is a different solution, I am trying to make the user of my system (I am writing a lib for my group that deal with configuration) to be able to easily set this feature. I can do it with annotation and some class introspection to see all fields that need to be tested for the name required issue... inside afterUnmarshal(...) . I'll keep this unanswered maybe there is someone with an a more suiting answer for what I need.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/2776272
score: 0
type: Comment
has text: Log4j was a defacto standard, but with java.util.logging, Commons Logging, and the many other logging frameworks that it supports, I'm not sure if that still holds true. Many open source projects that I've seen lately don't use log4j any more.
comment on: http://stackoverflow.com/a/2746666
type: AnswerComment

http://stackoverflow.com/a/11780266
has body: private void rev() { String st="hello"; String b=""; for(int i=st.length()-1;i&gt;=0;i--){ b=b+st.charAt(i); } System.out.println("reverse:::"+b); }
downvote count: 0
answers question: http://stackoverflow.com/q/2612976
type: Answer
score: 1
upvote count: 1

http://stackoverflow.com/comment/3017177
type: QuestionComment
has text: It is called "someone being too clever and creating unreadable code, instead of creating clean logically structured code that can be read and maintained easily". polygenelubricants answer is perfect because it is immediately understandable.
score: 0
comment on: http://stackoverflow.com/q/2657819
type: Comment

http://stackoverflow.com/comment/2727942
score: 0
has text: What about upgrades to ADF? don't you have to respecifiy each dependency for every single application?
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/2703922

http://stackoverflow.com/q/2729027
type: Question
tagged with: atom-feed
tagged with: seam
tagged with: java
duplicate of: http://stackoverflow.com/q/113063
answer count: 6
has answer: http://stackoverflow.com/a/2729095
has answer: http://stackoverflow.com/a/9206842
downvote count: 0
has answer: http://stackoverflow.com/a/2749123
has answer: http://stackoverflow.com/a/2770864
has body: I am looking for libraries which can read RSS / ATOM feeds in my J2EE application (based on JBoss Seam). Is Rome the only application there for reading feeds? I am assuming the Seam RSS integration is only for generating RSS feeds and not for reading feeds.
favorite count: 0
upvote count: 30
possible better answer: http://stackoverflow.com/a/2770864
accepted answer: http://stackoverflow.com/a/2729095
score: 30
has title: java library for reading RSS and ATOM feeds
type: AnsweredQuestion
tagged with: rss
has answer: http://stackoverflow.com/a/5517751
has answer: http://stackoverflow.com/a/2772211
linked to: http://stackoverflow.com/q/113063

http://stackoverflow.com/comment/2773103
comment on: http://stackoverflow.com/a/2740523
type: Comment
has text: Specify the MIME type of the attached data. For a PNG image, for example, use "image/png".
score: 0
type: AnswerComment

http://stackoverflow.com/comment/3060598
type: AnswerComment
comment on: http://stackoverflow.com/a/2599128
type: Comment
score: 4
has text: +1; just a couple of additional remarks. First of all, the term serialization is also sometimes used in the context of handling requests *in sequence* rather than simultaneously. Other than that, I would say Java objects are serialized to bytestreams rather than bitstreams. AFAIK, output is always byte-aligned.

http://stackoverflow.com/q/2736126
has title: Eclipse building - exclude from jar packaging but include into final product
tagged with: eclipse-rcp
downvote count: 0
answer count: 1
tagged with: packaging
favorite count: 0
upvote count: 2
type: UnansweredQuestion
score: 2
has body: I am using a Derby local (embedded) database for one of my RCP projects. The database is located within the project folder structure in eclipse and is checked to be included in the build. My folder structure in Eclipse is: projectname I I- src I I- database I I I I-project database here I I I- icons ... The Eclipse build process now includes the database folder including the subfolders into the jar file of the project. Unfortunately I can not convice Derby to look inside the packaged jar file and use the database there, so I would like to have the database, which I am using and filling while developing the software, excluded from the jar packaging, but included into the later build product. My dream would be to have the product folder structure like this: productname I I- configuration I I- database ...! I I- jre I I- p2 I I- plugins I I- artifacts.xml I- productname.exe I- productname.ini Can this somehow be achieved with the PDE build process? Thanks!
tagged with: java
tagged with: eclipse
type: Question
has answer: http://stackoverflow.com/a/3298366

http://stackoverflow.com/a/2624125
score: 20
has comment: http://stackoverflow.com/comment/2646754
upvote count: 21
accepted answer of: http://stackoverflow.com/q/2623966
type: AcceptedAnswer
downvote count: 1
has body: The parsing is greedy, that is , it looks for the longest matching token first. This simplify the implementations a lot (presumably). Also the Java language spec(3.2) says Java always uses the longest possible translation at each step, even if the result does not ultimately make a correct Java program, while another lexical translation would So, for y+++++y; the parser/tokenizer will break it down something like this: variable y operator ++ (as there is no +++ operator, ++ is the longest that match the syntax of java) operator ++ (as there is no +++ operator, ++ is the longest that match the syntax of java) operator + (This was the first thing that matches the syntax now) variable y Effectively it is parsed as (y++) (++) (+y) the ++ operator is defined for a variable, however the first expression (y++) returns a value. You can't apply the next operator (++) to a value. This means that x = y+++y; would be parsed as y++ + y, which is nothing wrong with.
answers question: http://stackoverflow.com/q/2623966
type: Answer

http://stackoverflow.com/a/2658881
has comment: http://stackoverflow.com/comment/2688507
accepted answer of: http://stackoverflow.com/q/2658681
has body: You can add Bookmarks in your code. Select the code fragment you want to bookmark and then go to Edit > Add Bookmark... (also possible via the menu available with a right-click in the left hand column of the editor, like breakpoints). Then, add the Bookmarks view. Select Window > Show View > Other... > Bookmarks and you'll get something like this: Sadly, I don't think you can bind a shortcut to a particular bookmark. Just in case, the shortcut to jump to a particular line is CTRL+L.
has comment: http://stackoverflow.com/comment/2676374
score: 15
upvote count: 15
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2676510
answers question: http://stackoverflow.com/q/2658681
type: Answer

http://stackoverflow.com/comment/2670794
comment on: http://stackoverflow.com/a/2654368
type: AnswerComment
has text: Good answer. Nothing more to add.
type: Comment
score: 1

http://stackoverflow.com/a/2649252
has comment: http://stackoverflow.com/comment/2665262
downvote count: 2
accepted answer of: http://stackoverflow.com/q/2649213
type: AcceptedAnswer
score: 328
has body: static means that the variable or method marked as such is available at the class level. In other words, you don't need to create an instance of the class to access it. public class Foo { public static void doStuff(){ // does stuff } } So, instead of creating an instance of Foo and then calling doStuff like this: Foo f = new Foo(); f.doStuff(); You just call the method directly against the class, like so: Foo.doStuff();
type: Answer
has comment: http://stackoverflow.com/comment/2666522
upvote count: 330
has comment: http://stackoverflow.com/comment/24958785
answers question: http://stackoverflow.com/q/2649213
has comment: http://stackoverflow.com/comment/104833409

http://stackoverflow.com/comment/2747542
has text: i m working on a wap project ,i want to download mp3 files when user presses an option using gprs.i m testing this application using opera browser which is used for(wap-wireless access protocol) ,there i m able to download a file using code u mentioned above.but now i m facing a major problem i m not able to download on mobile .may be slow network or speed.what can be the best soloution to make it work.please suggest. byte[] buffer = new byte[1024]intbyteRead = 0;while((byteReadfis.read(buffer)) !os.write(buffer, 0, byteRead);} i m using this code small sample.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2721354
type: Comment

http://stackoverflow.com/a/25315733
score: 97
upvote count: 97
answers question: http://stackoverflow.com/q/2772470
downvote count: 0
has comment: http://stackoverflow.com/comment/76671568
type: Answer
has comment: http://stackoverflow.com/comment/104763649
has body: As already answered, multi-column index can be added using @Table annotation. However, columnNames needs to be the name of actual DB columns, not the class attribute. So, if the column is like the following: @Column(name="product_id") Long productId; Then the @Table annotation should be like the following @Table(uniqueConstraints= @UniqueConstraint(columnNames = {"product_id", "serial"}))
has comment: http://stackoverflow.com/comment/104211199
has comment: http://stackoverflow.com/comment/101627797

http://stackoverflow.com/q/2758799
has answer: http://stackoverflow.com/a/2760292
accepted answer: http://stackoverflow.com/a/2759427
type: AnsweredQuestion
downvote count: 0
has body: The classes belong to the same pkg. They are in the dir, name of the pkg. In general, how can classes access one another in the same pkg? Error javac PackTest.java PackTest.java:8: cannot find symbol symbol : class PriTest location: class pacc.PackTest System.out.println(new PriTest().getSaluto()); ^ 1 error Classes in the PKG pacc $ cat PackTest.java package pacc; import java.io.*; public class PackTest { public static void main(String[] args) { System.out.println(new PriTest().getSaluto()); } } $ cat PriTest.java package pacc; public class PriTest { public PriTest(){} private String saluto="SALUTO FROM PriTest"; public String getSaluto(){return saluto;} } PKG of the name of dir $ find .. -type d -name "pacc" ../pacc $ ls ../pacc makefile PackTest.java PriTest.java $ ls makefile PackTest.java PriTest.java Solved! $ cat makefile p: javac ./pacc/PackTest.java java pacc/PackTest $ make p javac ./pacc/PackTest.java java pacc/PackTest SALUTO FROM PriTest
has comment: http://stackoverflow.com/comment/2790731
has answer: http://stackoverflow.com/a/2758816
has answer: http://stackoverflow.com/a/2769391
favorite count: 0
has comment: http://stackoverflow.com/comment/2790619
type: Question
has comment: http://stackoverflow.com/comment/2790489
possible better answer: http://stackoverflow.com/a/2758816
has answer: http://stackoverflow.com/a/2759243
tagged with: package
has answer: http://stackoverflow.com/a/2759427
has title: Java newbie problem: classes of the same package accessing one another?
score: 4
tagged with: java
answer count: 5
has comment: http://stackoverflow.com/comment/2790752
has comment: http://stackoverflow.com/comment/2791054
upvote count: 4

http://stackoverflow.com/comment/2701098
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2681359
has text: I find the user-interface that the existing tools create to be not user-friendly/efficient enough (at least for the purpose I intend to use the tool for). Also, the created user-interface doesn't leverage state-of-the-art user input (e.g. multi-touch). There may be other tools out there, maybe being in the works, that are going further than the existing ones. Those are the ones I am searching for.

http://stackoverflow.com/q/2637065
tagged with: jetty
has body: I have one web app works perfectly under linux with jetty-6.1.22. However, when I tried to run it under windows, it throws an exception right at the initialization: java.lang.IllegalArgumentException: name at sun.misc.URLClassPath$Loader.findResource(Unknown Source) at sun.misc.URLClassPath.findResource(Unknown Source) at java.net.URLClassLoader$2.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findResource(Unknown Source) at org.mortbay.jetty.webapp.WebAppClassLoader.getResource(WebAppClassLoader.java:271) at org.mortbay.resource.Resource.newSystemResource(Resource.java:203) at org.mortbay.jetty.webapp.WebXmlConfiguration.configureDefaults(WebXmlConfiguration.java:159) at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1230) I checked into the source code of WebAppClassLoader.java, it looks like this: String defaultsDescriptor=getWebAppContext().getDefaultsDescriptor(); if(defaultsDescriptor!=null&amp;&amp;defaultsDescriptor.length()&gt;0) { Resource dftResource=Resource.newSystemResource(defaultsDescriptor); if(dftResource==null) dftResource=Resource.newResource(defaultsDescriptor); configure(dftResource.getURL().toString()); _defaultWelcomeFileList=_welcomeFiles!=null; } The exception happens on this line: Resource.dftResource=Resource.newSystemResource(defaultsDescriptor);. But I do not understand. How come it works on Linux but not on windows?
type: AnsweredQuestion
tagged with: java
type: Question
score: 0
answer count: 1
has title: Has anyone seen jetty got initialized successfully under linux but throws exceptions under windows?
tagged with: embedded-jetty
has answer: http://stackoverflow.com/a/2644191
accepted answer: http://stackoverflow.com/a/2644191

http://stackoverflow.com/a/2657885
has comment: http://stackoverflow.com/comment/2674840
has body: Seems like you have a local variable or a parameter with the same name
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2657875
type: Answer
accepted answer of: http://stackoverflow.com/q/2657875
upvote count: 3
score: 3

http://stackoverflow.com/a/2609290
has body: I think that here are two problems: Grades logic is too much mixed with Student. It should be done in Grades class Teacher's logic is placed into Student. Conclusion: Student knows too much about inner structure and logic of Teacher and Grades and that breaks LoD
type: Answer
score: 3
upvote count: 3
answers question: http://stackoverflow.com/q/2609236
downvote count: 0

http://stackoverflow.com/a/61075619
upvote count: 2
type: Answer
answers question: http://stackoverflow.com/q/2661110
score: 2
has body: While both are valid, to me the first feels like a type mismatch. To me b == false looks as wrong as (i == 0) == false. It is like: huh? Booleans are not an enum with 2 possible values. You don't compare them. Boolean are predicates and represent some truth. They have specific operators like &, |, ^, !. To reverse the truth of an expression use the operator '!', pronounced as "not". With proper naming it becomes natural: !isEmpty reads "not is empty", quite readable to me. While isEmpty == false reads something like "it is false that it is empty", which I need more time to process. Coding style guidelines in Java and other language generally discourage "== true/false" style. Sonar https://rules.sonarsource.com/java/RSPEC-1125 CheckStyle https://checkstyle.sourceforge.io/config_coding.html#SimplifyBooleanExpression TSLint https://palantir.github.io/tslint/rules/no-boolean-literal-compare/ C# https://www.c-sharpcorner.com/article/common-code-smell-mistakes-in-c-sharp-part-1/ C# queries https://help.semmle.com/wiki/display/CSHARP/Unnecessarily+complex+Boolean+expression But the following Codeshare blog entry shows cases in javascript where "b == true" can be useful. This might explain why people do it. https://codeshare.co.uk/blog/please-tell-me-you-dont-write-if-true-equals-true/
downvote count: 0

http://stackoverflow.com/q/2666717
upvote count: 1
has body: My slides say that: A recursive call should always be on a smaller data structure than the current one There must be a non recursive option if the data structure is too small You need a wrapper method to make the recursive method accessible Just reading this from the slides makes no sense, especially seeing as it was a topic from before christmas! Could anyone try and clear up what it means please? Thank you
type: Question
tagged with: recursion
has answer: http://stackoverflow.com/a/2666761
score: 1
tagged with: java
downvote count: 0
answer count: 1
favorite count: 0
accepted answer: http://stackoverflow.com/a/2666761
has title: Recursion Question : Revision
has comment: http://stackoverflow.com/comment/2684646
type: AnsweredQuestion
tagged with: linked-list
has comment: http://stackoverflow.com/comment/2684695

http://stackoverflow.com/comment/2782685
score: 2
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2750829
has text: +1. You nailed it right with "`BigDecimal` not `BigFractional`". And your insight on `double` for financial application is appreciated.

http://stackoverflow.com/a/2678219
answers question: http://stackoverflow.com/q/2677564
downvote count: 5
score: 0
type: Answer
has body: Well what i did is not the best solution but is readable: /** Pre: True * Post: The x is pushed onto the top of the stack, * and the rest of the stack remains unchanged. * * @param x Indicates the current node */ public void push(int x){ ... } Till a proper answer is found, hope it helps!
upvote count: 5

http://stackoverflow.com/q/2700047
tagged with: ehcache
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/2700277
tagged with: hibernate
tagged with: orm
upvote count: 1
type: Question
tagged with: caching
has title: Basic Hibernate Caching Question
accepted answer: http://stackoverflow.com/a/2700277
has body: Does Hibernate use cache (second level or otherwise) if all I am doing is batch inserts? No entities are being requested from the database, and no generators are used. Also, would StatelessSession vs Session change the answer? What if I was using a Session with a JDBC batch size of 50? The cache I will be using is Ehcache
answer count: 1
downvote count: 0
score: 1
favorite count: 0

http://stackoverflow.com/comment/2690778
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2655873
has text: the problem is that you dont really know whether it is a type or not, since B.jsp communication with `GenericServlet` via POST request

http://stackoverflow.com/q/2776729
possible better answer: http://stackoverflow.com/a/5926827
score: 2
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/5926827
has body: I am writing a port scanner in Java and I want to be able to distinct the following 4 use cases: port is open port is open and server banner was read port is closed server is not live I have the following code: InetAddress address = InetAddress.getByName("google.com"); int[] ports = new int[]{21, 22, 23, 80, 443}; for (int i = 0; i &lt; ports.length; i++) { int port = ports[i]; Socket socket = null; try { socket = new Socket(address, port); socket.setSoTimeout(500); System.out.println("port " + port + " open"); BufferedReader reader = new BufferedReader( new InputStreamReader(socket.getInputStream())); String line = reader.readLine(); if (line != null) { System.out.println(line); } socket.close(); } catch (SocketTimeoutException ex) { // port was open but nothing was read from input stream ex.printStackTrace(); } catch (ConnectException ex) { // port is closed ex.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (socket != null &amp;&amp; !socket.isClosed()) { try { socket.close(); } catch (Exception e) { e.printStackTrace(); } } } } The problem is that I get a ConnectionException both when the port is closed and the server cannot be reached but with a different exception message: java.net.ConnectException: Connection timed out: connect when the connection was never established and java.net.ConnectException: Connection refused: connect when the port was closed so I cannot make the distinction between the two use cases without digging into the actual exception message. Same thing happens when I try a different approach for the socket creation. If I use: socket = new Socket(); socket.setSoTimeout(500); socket.connect(new InetSocketAddress(address, port), 1000); I have the same problem but with the SocketTimeoutException instead. I get a java.net.SocketTimeoutException: Read timed out if port was open but there was no banner to be read and java.net.SocketTimeoutException: connect timed out if server is not live or port is closed. Any idea…
tagged with: java
accepted answer: http://stackoverflow.com/a/2778713
type: Question
answer count: 2
downvote count: 0
favorite count: 0
tagged with: network-scan
has answer: http://stackoverflow.com/a/2778713
has title: How do I detect server status in a port scanner java implementation
upvote count: 2
tagged with: sockets

http://stackoverflow.com/a/2628426
type: AcceptedAnswer
type: Answer
accepted answer of: http://stackoverflow.com/q/2628379
has body: Convert your dictionary into an anagram dictionary. In an anagram dictionary, the words are indexed by their letters in sorted alphabetical order. To look up anagrams for a certain word, you sort its letters and look up corresponding ones from the anagram dictionary.
upvote count: 15
answers question: http://stackoverflow.com/q/2628379
downvote count: 0
score: 15

http://stackoverflow.com/a/2654897
has comment: http://stackoverflow.com/comment/85113586
has comment: http://stackoverflow.com/comment/87831286
type: Answer
accepted answer of: http://stackoverflow.com/q/2654839
answers question: http://stackoverflow.com/q/2654839
has comment: http://stackoverflow.com/comment/89300469
upvote count: 276
has body: What is the return type of the round() method in the snippet? If this is the Math.round() method, it returns a Long when the input param is Double. So, you will have to cast the return value: int a = (int) Math.round(doubleVar);
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/137108586
score: 276

http://stackoverflow.com/a/2698555
type: Answer
has body: I could be wrong, but I don't believe you can use ".." like that in a call to getResource(). I suggest you try an "absolute" resource: URL url = getClass().getResource("/path/to/resources/test.properties");
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/2698532
upvote count: 2

http://stackoverflow.com/q/2749664
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2780144
has body: Let's assume I want to send many messages between 2 programs made in java that use TCP sockets. I think the most convienient way is to send objects like: PrintStream ps = new PrintStream(s.getOutputStream()); ObjectOutputStream oos = new ObjectOutputStream(ps); some_kind_of_object_here; oos.writeObject(some_kind_of_object_here); ps.print(oos); I want to send, strings, numbers, HashMaps, boolean values How can I do this using fx 1 object that can store all that properties? I though about ArrayList that is serializable and we can put there everything but is not elegant way. I want to send different types of data because user can choose from a variety of options that server can do for it. Any advices?
tagged with: tcp
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/2779959
accepted answer: http://stackoverflow.com/a/2750151
has answer: http://stackoverflow.com/a/2749679
has answer: http://stackoverflow.com/a/2749730
has answer: http://stackoverflow.com/a/2749891
possible better answer: http://stackoverflow.com/a/2749679
score: 0
tagged with: send
has answer: http://stackoverflow.com/a/2750151
has title: What structure of data use to communicate via tcp/ip in java?
answer count: 4

http://stackoverflow.com/comment/2612944
type: Comment
comment on: http://stackoverflow.com/a/2603277
score: 0
type: AnswerComment
has text: Yeah I've already been advised to use the MVC design to aid code organization - another big problem is my old code isnt in the least bit DRY. I'm wondering just how I'll keep this new code DRY whilst implementing the CRUD. Would I create a superclass with the basic CRUD functionality, and somehow pass the variables (table, field etc.) from the child to the parent to perform the CRUD - or would I write SQL queries in the methods of each class for their own specific use? Thanks for your replies - appreciate it!

java
tags question: http://stackoverflow.com/q/2604588
tags question: http://stackoverflow.com/q/2632631
tags question: http://stackoverflow.com/q/2617369
tags question: http://stackoverflow.com/q/2703044
tags question: http://stackoverflow.com/q/2668796
tags question: http://stackoverflow.com/q/2653458
tags question: http://stackoverflow.com/q/2693048
tags question: http://stackoverflow.com/q/2777107
tags question: http://stackoverflow.com/q/2754631
tags question: http://stackoverflow.com/q/2620961
tags question: http://stackoverflow.com/q/2670269
tags question: http://stackoverflow.com/q/2621996
tags question: http://stackoverflow.com/q/2686993
tags question: http://stackoverflow.com/q/2710269
tags question: http://stackoverflow.com/q/2695349
tags question: http://stackoverflow.com/q/2761618
tags question: http://stackoverflow.com/q/2755306
tags question: http://stackoverflow.com/q/2652801
tags question: http://stackoverflow.com/q/2657298
tags question: http://stackoverflow.com/q/2683914
tags question: http://stackoverflow.com/q/2712709
tags question: http://stackoverflow.com/q/2708229
tags question: http://stackoverflow.com/q/2624545
tags question: http://stackoverflow.com/q/2672316
tags question: http://stackoverflow.com/q/2618595
tags question: http://stackoverflow.com/q/2644339
tags question: http://stackoverflow.com/q/2622725
tags question: http://stackoverflow.com/q/2786132
tags question: http://stackoverflow.com/q/2642651
tags question: http://stackoverflow.com/q/2764624
tags question: http://stackoverflow.com/q/2732981
tags question: http://stackoverflow.com/q/2743106
tags question: http://stackoverflow.com/q/2720738
tags question: http://stackoverflow.com/q/2631984
tags question: http://stackoverflow.com/q/2720141
tags question: http://stackoverflow.com/q/2746598
tags question: http://stackoverflow.com/q/2757231
tags question: http://stackoverflow.com/q/2762914
tags question: http://stackoverflow.com/q/2736628
tags question: http://stackoverflow.com/q/2714066
tags question: http://stackoverflow.com/q/2623610
tags question: http://stackoverflow.com/q/2708418
tags question: http://stackoverflow.com/q/2729947
tags question: http://stackoverflow.com/q/2661829
tags question: http://stackoverflow.com/q/2709161
tags question: http://stackoverflow.com/q/2611481
tags question: http://stackoverflow.com/q/2648306
tags question: http://stackoverflow.com/q/2636056
tags question: http://stackoverflow.com/q/2711551
tags question: http://stackoverflow.com/q/2655255
tags question: http://stackoverflow.com/q/2762489
tags question: http://stackoverflow.com/q/2746098
tags question: http://stackoverflow.com/q/2762769
tags question: http://stackoverflow.com/q/2717936
tags question: http://stackoverflow.com/q/2599090
tags question: http://stackoverflow.com/q/2721062
tags question: http://stackoverflow.com/q/2606049
tags question: http://stackoverflow.com/q/2773826
tags question: http://stackoverflow.com/q/2762245
tags question: http://stackoverflow.com/q/2616960
tags question: http://stackoverflow.com/q/2736767
tags question: http://stackoverflow.com/q/2618617
tags question: http://stackoverflow.com/q/2672811
tags question: http://stackoverflow.com/q/2774320
tags question: http://stackoverflow.com/q/2720774
tags question: http://stackoverflow.com/q/2731749
tags question: http://stackoverflow.com/q/2742880
tags question: http://stackoverflow.com/q/2724063
tags question: http://stackoverflow.com/q/2768747
tags question: http://stackoverflow.com/q/2666734
tags question: http://stackoverflow.com/q/2778386
tags question: http://stackoverflow.com/q/2598383
tags question: http://stackoverflow.com/q/2673762
tags question: http://stackoverflow.com/q/2732639
tags question: http://stackoverflow.com/q/2706201
tags question: http://stackoverflow.com/q/2714663
tags question: http://stackoverflow.com/q/2623966
tags question: http://stackoverflow.com/q/2726694
tags question: http://stackoverflow.com/q/2704157
tags question: http://stackoverflow.com/q/2646049

http://stackoverflow.com/comment/2620637
type: Comment
has text: but I want logs to be written onto one file... So, I'll have to add file handlers all the time...
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2610025

http://stackoverflow.com/a/2603406
score: 5
type: AcceptedAnswer
downvote count: 0
type: Answer
has body: You may want to try OpenAM. I also noticed this.. http://download.java.net/general/opensso/webstartnew/ which will download the bits for testing. And guess what... there is an opensso.war and the like 'in there' that were produced about the same time as the tutorial was written.
answers question: http://stackoverflow.com/q/2602516
upvote count: 5
accepted answer of: http://stackoverflow.com/q/2602516

http://stackoverflow.com/a/2734588
type: Answer
has body: You could rewrite it like this: public Loan[] findLoans(Person p) { Loan[] allLoans = this.getAllLoans(); System.arraycopy(allLoans, searchedLoanArray, 0, 0, allLoans.length); // fill new array with all values // remainder of method the same } But as it stands, the code still has some problems: The maximum number of loans is fixed to the size of the array. You will avoid this problem when you switch to List&lt;Loan&gt;. Using the id as an index means that your ids must be carefully generated. If IDs come from a database, you may find that the list tries to allocate a huge amount of memory to size itself to match the Id. You would be better using a Map, then the size of the map is based on the number of loans, rather than their IDs. As the number of people and loans increase, the search time will also increase. You can reduce search time to a constant (irrespective of how many People) by using a Map>, which allows quick lookup of the loans associated just with that person. Here's a version with these changes: class AcmeLoanManager { public void addLoan(Loan l) { Person client = l.getClient(); List&lt;Loan&gt; loans = clientLoans.get(l); if (loans==null) { loans = new ArrayList(); clientLoans.put(client, loans); } loans.add(l); allLoans.put(l.getLoanId(), l); } public void removeLoan(int loanId) { Loan l = loans.remove(loanId); clientLoans.remove(loan); } public Collection&lt;Loan&gt; getAllLoans() { return loans.values(); } public List&lt;Loan&gt; findLoans(Person p) { List&lt;Loan&gt; loans = clientLoans.get(p); if (loans==null) loans = Collections.emptyList(); return loans; } private Map&lt;Integer,Loan&gt; allLoans = new HashMap&lt;Integer,Loan&gt;(); private Map&lt;Person, List&lt;Loan&gt;&gt; clientLoans = new HashMap&lt;Person,List&lt;Loan&gt;&gt;(); } I hope this helps!
score: 0
answers question: http://stackoverflow.com/q/2734386

http://stackoverflow.com/a/2737534
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2737420
type: Answer
answers question: http://stackoverflow.com/q/2737420
has comment: http://stackoverflow.com/comment/2766185
has comment: http://stackoverflow.com/comment/2766183
has comment: http://stackoverflow.com/comment/34830143
has comment: http://stackoverflow.com/comment/89206503
upvote count: 93
has body: Don't know of JPA property for this either. But you could just add the Hibernate property (assuming you use Hibernate as provider) as ... &lt;property name="hibernate.default_schema" value="myschema"/&gt; ... Hibernate should pick that up
score: 93

http://stackoverflow.com/comment/2617291
has text: The JSL doesn't specify a reason, though, which is what this question is about.
score: 2
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/2607215

http://stackoverflow.com/comment/2650316
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2636252
has text: im calling a Voice response system, so i guess it is not ringing? since my log in the RINGING is not showing in the DDMS, but only IDLE to OFFHOOK? and how do i add dtmf tones with it?

http://stackoverflow.com/q/2662531
has answer: http://stackoverflow.com/a/2663565
has answer: http://stackoverflow.com/a/61672475
linked to: http://stackoverflow.com/q/17589730
has answer: http://stackoverflow.com/a/15534177
has answer: http://stackoverflow.com/a/73193645
has answer: http://stackoverflow.com/a/4433117
has answer: http://stackoverflow.com/a/44218712
score: 446
favorite count: 0
has body: My app needs to show Google Maps directions from A to B, but I don't want to put the Google Maps into my application - instead, I want to launch it using an Intent. Is this possible? If yes, how?
possible better answer: http://stackoverflow.com/a/4433117
accepted answer: http://stackoverflow.com/a/2663565
tagged with: android
has comment: http://stackoverflow.com/comment/103473498
answer count: 18
tagged with: android-intent
upvote count: 447
has answer: http://stackoverflow.com/a/28912340
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/41780174
tagged with: java
has answer: http://stackoverflow.com/a/50740803
has answer: http://stackoverflow.com/a/19160703
has answer: http://stackoverflow.com/a/45553465
has title: Launching Google Maps Directions via an intent on Android
downvote count: 1
linked to: http://stackoverflow.com/q/28560029
type: Question
has answer: http://stackoverflow.com/a/65322942
linked to: http://stackoverflow.com/q/8534899
has answer: http://stackoverflow.com/a/44365894
tagged with: google-maps
has answer: http://stackoverflow.com/a/53428137
has answer: http://stackoverflow.com/a/61338753
linked to: http://stackoverflow.com/q/7965747
has answer: http://stackoverflow.com/a/43994890
has answer: http://stackoverflow.com/a/65425971
has answer: http://stackoverflow.com/a/27504066

http://stackoverflow.com/a/2708192
has body: Not all Throwables are Exceptions. Does your error logging code catch Errors (OutOfMemoryError, StackOverflowError, etc)?
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2708136
upvote count: 1
score: 1

http://stackoverflow.com/comment/2763807
comment on: http://stackoverflow.com/a/2735479
type: AnswerComment
score: 0
type: Comment
has text: Sure. Nothing Android-specific here above `openFileOutput(..)`.

http://stackoverflow.com/comment/2790084
has text: @Edan: Did the accepted answer really solve your problem? Making it static will lead to unwanted (as I understand it) behavior if you make another instance of your class...
type: Comment
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/2758279

http://stackoverflow.com/q/2762914
favorite count: 0
tagged with: android
possible better answer: http://stackoverflow.com/a/2795721
has answer: http://stackoverflow.com/a/2795721
has title: After making a call programatically, my android app crashes
type: AnsweredQuestion
downvote count: 0
score: 1
accepted answer: http://stackoverflow.com/a/2810867
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/2810867
has body: The title explains all... I have this snippet of code in my application: String url = createTelUrl("3112007315"); Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse(url)); context.startActivity(intent); It does make a call, but once the call ends, my application crashes. I'd like to return to my application once the call has finished, but I read this post and it seems not to be possible. So... is there anyway to at least pause my application and resume it once the call has finished? EDIT: Thanks for the two answers I received, I feel I'm really close to my goal... I had already done some of the things you guys suggested. But, maybe I didn't explain some details of the application... I'm developing Who Wants To Be A Millonarie game, so I need to implement calls (I don't know how it's called in USA or other countrys, but here we call it "call to a friend"). Anyway... I've done too many changes to this app and now it's not crashing. But, the Canvas where I draw the UI is not been showed once the called has ended. I have a SurfaceView that holds the UI. For that SurfaceView I created a thread that is meant to refresh the UI... this is basically what the thread does: @Override public void run() { Canvas c; while (_run) { c = null; try { c = _surfaceHolder.lockCanvas(null); // Check if should wait synchronized (_surfaceHolder) { _panel.onDraw(c); } } finally { // do this in a finally so that if an exception is thrown // during the above, we don't leave the Surface in an // inconsistent state if (c != null) { _surfaceHolder.unlockCanvasAndPost(c); } } } } But, once the call has ended I get a black screen. The surface is there (I know it because it still can receive some touch events), but it's not showing anything. Another thing to take in account is how I'm starting the Thread from the SurfaceView class: public void surfaceCreated(SurfaceHolder holder) { hilo.setRunning(true); try{ hilo.start(); }catch(IllegalThreadStateException ite){ Log.e("wwtbam"…
answer count: 3
upvote count: 1
has answer: http://stackoverflow.com/a/2791643

http://stackoverflow.com/comment/2767604
score: 0
type: Comment
type: QuestionComment
has text: no from my program..Mysql 5.1
comment on: http://stackoverflow.com/q/2738787

http://stackoverflow.com/q/2712884
tagged with: deployment
score: 2
upvote count: 2
tagged with: java
has body: I am working on a java based application and we are looking to ease our deployment of updates. Up until now, we've always simply sent out new install packs &amp; had the sysadmin's on our customer sites roll out the upgrades - painful for a large number of users. what I'd like to do is something similar to java webstart (or eclipse p2) - when the application starts, it checks for updates in a specified location and then downloads the updates prior to starting. But here's my problem - I want more control over what's done outside of the scope of plugins &amp; jar files. For example: I'd like to be able to upate my JVM (we ship a modified version with additional security features). I need to install DLL's - possibly local to the jar files, sometimes to windows Occasiontally run MSI's to install windows components (e.g. printer drivers). I need to modify config files &amp; the registry. I have found a few applications that support this (such as AppLifeUpdate at http://www.kineticjump.com/) but they tend to be .NET focused and it seems a bit perverse to introduce a .NET dependancy on a java application ;) I know I could write my own here, but if there is already a 3rd party library out there that supports this kind of facility, then it would make my life a lot easier. So, has anyone else had a similar problem &amp; knows of some products I could look at? Thanks, Brian.
has answer: http://stackoverflow.com/a/2792691
type: Question
downvote count: 0
answer count: 1
has title: are there java based auto-updating tools other than WebStart & Eclipse P2?
favorite count: 0
type: UnansweredQuestion

http://stackoverflow.com/comment/2674400
comment on: http://stackoverflow.com/q/2642992
has text: I dont find any other way, i posted the complete code so that the reader can run it and see. If you have any other better way to do this you are always welcome :)
type: QuestionComment
type: Comment
score: 0

http://stackoverflow.com/comment/2689251
type: AnswerComment
comment on: http://stackoverflow.com/a/2670550
type: Comment
score: 1
has text: Unless it is a homework it pays to use Apache utils, there's a lot more on that lib and it's not that big. I always add Apache utils on my code whenever I need, it saves a lot of time.

http://stackoverflow.com/a/2717444
score: 0
type: Answer
answers question: http://stackoverflow.com/q/2710200
has body: You could try embedding the crystal reports swing components inside your swt application using org.eclipse.swt.awt.SWT_AWT. For more information on how that class can be used check out this article.

http://stackoverflow.com/a/2756000
downvote count: 0
has body: So long as the this reference is the same. If you run the code on two different objects, the lock will have no effect. Note, if you were to use Object.wait on this instead of calling Thread.sleep to delay, then the lock would be removed (and reacquired before moving on).
answers question: http://stackoverflow.com/q/2755969
upvote count: 2
type: Answer
score: 2

http://stackoverflow.com/q/2631650
has answer: http://stackoverflow.com/a/2631673
type: Question
has answer: http://stackoverflow.com/a/2631693
has answer: http://stackoverflow.com/a/2631669
downvote count: 0
accepted answer: http://stackoverflow.com/a/2631673
tagged with: variable-assignment
has body: The problem drives me to the big try-catch loops. I want smaller. So how to access assignments in the loops? $ javac TestInit2.java TestInit2.java:13: variable unknown might not have been initialized System.out.println(unknown); ^ 1 error Code import java.util.*; import java.io.*; public class TestInit2 { public static void main(String[] args){ String unknown; try{ unknown="cannot see me, why?"; }catch(Exception e){ e.printStackTrace(); } System.out.println(unknown); } }
favorite count: 0
possible better answer: http://stackoverflow.com/a/2631657
has comment: http://stackoverflow.com/comment/2645030
has answer: http://stackoverflow.com/a/2631657
answer count: 5
has title: Java: how to access assignments in try-catch -loop?
tagged with: error-handling
has comment: http://stackoverflow.com/comment/2644981
type: AnsweredQuestion
score: 3
upvote count: 3
tagged with: java
has answer: http://stackoverflow.com/a/2631661

http://stackoverflow.com/a/37518937
answers question: http://stackoverflow.com/q/2691018
upvote count: 10
type: Answer
downvote count: 0
score: 10
has body: The real solution is: don't use floating-point numbers for anything that needs to be counted with precision: If you are dealing with currency, don't use a double number of dollars, use an integer number of cents. If you are dealing with hours of time and need to count quarter-hours and 10-minute intervals, use an integer number of minutes. A floating point number is almost always an approximation of some real value. They are suitable for measurements and calculation of physical quantities (top a degree of precision) and for statistical artifacts. Fooling about with rounding floating point to a number of digits is a code smell: it's wasteful and you can never really be sure that your code will work properly in all cases.

http://stackoverflow.com/comment/2674277
type: Comment
comment on: http://stackoverflow.com/a/2657347
has text: What makes you think RegGetValue works on Windows XP? Did you test it yourself? On which service pack? The MSDN documentation states that Vista or XP SP1 is required.
score: 0
type: AnswerComment

http://stackoverflow.com/q/2729536
score: 3
has comment: http://stackoverflow.com/comment/2757088
upvote count: 3
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/2729818
downvote count: 0
tagged with: awt
has body: given the following code: public class DialogTest implements ActionListener { public static void main(String[] args) {DialogTest g = new DialogTest();} public DialogTest() { JButton b1 = new JButton("Button A"); b1.addActionListener(this); JDialog d = new JDialog(); d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); JPanel p = new JPanel(); p.add(b1); d.add(p); d.getRootPane().setDefaultButton(b1); d.pack(); d.setVisible(true); d.dispose(); d.pack(); d.setVisible(true); } public void actionPerformed(ActionEvent e) {System.out.println("hello");} } Shouldn't pressing the Enter key write something to the console? According to the docs (http://java.sun.com/javase/7/docs/api/java/awt/Window.html#dispose()): The Window and its subcomponents can be made displayable again by rebuilding the native resources with a subsequent call to pack or show. The states of the recreated Window and its subcomponents will be identical to the states of these objects at the point where the Window was disposed Is this intended behaviour?
has comment: http://stackoverflow.com/comment/2756981
has title: Default Button after dispose and setVisible
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/2729818
has comment: http://stackoverflow.com/comment/2766412
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2756962

http://stackoverflow.com/comment/9814715
comment on: http://stackoverflow.com/a/2668990
has text: Can you provide a code sample where to attach the route? I'm confused if I should override a method in my `Resource` class or just attach the route when I start my application...
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/q/2608462
has body: I have a fairly simple question about these 2 templating engines. I'm trying to make a future/past date, a fixed time from now, e.g. 18 months ago, or tomorrow. I know that it is possible to do this with a java date object inside a velocity/freemarker template (something like $date.add(2,-18)), but I would like to do this with DateTool or freemarker core. This is something that I see as purely presentational (just think at the default dates you see in flight booking forms), so I can't see any reason why a templating engine shouldn't be able to do this. Is it possible though? If so, how?
type: Question
has answer: http://stackoverflow.com/a/2608552
score: 4
has title: Freemarker/Velocity - date manipulation
has answer: http://stackoverflow.com/a/11793143
upvote count: 4
downvote count: 0
answer count: 7
has answer: http://stackoverflow.com/a/56172324
accepted answer: http://stackoverflow.com/a/2608552
favorite count: 0
tagged with: freemarker
has answer: http://stackoverflow.com/a/2608502
has answer: http://stackoverflow.com/a/3156009
tagged with: velocity
possible better answer: http://stackoverflow.com/a/28764040
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/28764040
has answer: http://stackoverflow.com/a/74192482
tagged with: java

http://stackoverflow.com/q/2657827
tagged with: image
upvote count: 2
has answer: http://stackoverflow.com/a/2659509
answer count: 3
has answer: http://stackoverflow.com/a/16695188
has answer: http://stackoverflow.com/a/3974630
favorite count: 0
has title: File name after MediaStore.Images.Media.insertImage
type: UnansweredQuestion
tagged with: android
has body: I am using MediaStore.Images.Media.insertImage(ContentResolver cr, String imagePath, String name, String description) function to insert a newly created image into gallery. System is naming the file by default, but it's diferent than names of pictures taken by orginal app (Time stamp). Is there easy way to set it up?
score: 2
downvote count: 0
tagged with: java
type: Question
tagged with: rename

http://stackoverflow.com/a/2757700
score: 1
has comment: http://stackoverflow.com/comment/2791220
has body: With this solution, the JVM guarantees that it's only one mapper and that's it's initialized before use. public enum KeyMapperFactory { ; private static KeyMapper mapper = new LocalMemoryMapper(); public static KeyMapper getMapper() { return mapper; } }
answers question: http://stackoverflow.com/q/2757043
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/2792464
upvote count: 1

http://stackoverflow.com/q/2700195
answer count: 2
downvote count: 0
has title: Write a MAT file without using matlab headers and libraries
favorite count: 0
has comment: http://stackoverflow.com/comment/2722899
possible better answer: http://stackoverflow.com/a/2700442
tagged with: matlab
tagged with: c++
has body: I have some data that I would like to save to a MAT file (version 4 or 5, or any version, for that matter). The catch: I wanted to do this without using matlab libraries, since this code will not necessary run in a machine with matlab. My program uses Java and C++, so any existing library in those languages that achieves this could help me out... I did some research but did not find anything in Java/C++. However, I found that scipy on python achieves this with mio4.py or mio5.py. I thought about implementing this on java or C++, but it seems a bit out of my time schedule. So the question is: is there any libraries in Java or C/C++ that permits saving MAT files without using Matlab libraries? Thanks a lot
has answer: http://stackoverflow.com/a/2700520
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2700520
type: Question
has answer: http://stackoverflow.com/a/2700442
tagged with: java
score: 10
tagged with: mat-file
upvote count: 10

http://stackoverflow.com/q/2649048
has body: i want to write a mapviewer, i must to work small tile of big map image file and there is need to tiling the big image, the problem now is to tiling big image to small tiles (250 * 250 pixel or like this size) so on, i used ImageMagic program to do it but there was problem now is any other programing method or application that do tiling? can i do it with JAI in java? how?
accepted answer: http://stackoverflow.com/a/2964326
possible better answer: http://stackoverflow.com/a/2723922
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2723922
has answer: http://stackoverflow.com/a/2651000
tagged with: java
has comment: http://stackoverflow.com/comment/2665405
tagged with: tiling
type: Question
upvote count: 4
has title: slicing up a very big jpg map image , 49000* 34300 pixel
has comment: http://stackoverflow.com/comment/2665014
downvote count: 0
answer count: 6
has answer: http://stackoverflow.com/a/2840686
has answer: http://stackoverflow.com/a/2964326
has comment: http://stackoverflow.com/comment/2667050
tagged with: jai
has answer: http://stackoverflow.com/a/8909070
has comment: http://stackoverflow.com/comment/2665094
favorite count: 0
has answer: http://stackoverflow.com/a/2733214
score: 4

http://stackoverflow.com/a/2781202
has body: Is your webapp a real Java EE 6 webapp (without web.xml or with a Servlet 3.0 web.xml)? If yes, maybe NetBeans doesn't show Tomcat because Tomcat is not a valid runtime environment for your application (use GlassFish).
type: Answer
upvote count: 6
score: 6
has comment: http://stackoverflow.com/comment/2816144
has comment: http://stackoverflow.com/comment/2818483
answers question: http://stackoverflow.com/q/2781057
downvote count: 0

http://stackoverflow.com/q/2731964
downvote count: 0
favorite count: 0
upvote count: 2
has answer: http://stackoverflow.com/a/6117013
has body: Is someone using Facelets with JSP 2.0 tags? How to add tag library to xhtml page? In JSP I used: &lt;% taglib prefix="example" tagdir="/WEB-INF/tags/my" %&gt; and : &lt;example:sample/&gt; How can I do the same in facelets with JSP 2.0 tags?
type: AnsweredQuestion
tagged with: facelets
tagged with: jsf
tagged with: java
has answer: http://stackoverflow.com/a/2732034
type: Question
tagged with: jsp
possible better answer: http://stackoverflow.com/a/2732102
tagged with: jsf-2
has answer: http://stackoverflow.com/a/2732102
answer count: 3
score: 2
has title: Using JSP 2.0 tags in Facelets
accepted answer: http://stackoverflow.com/a/2732034

http://stackoverflow.com/a/67467448
upvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/124092068
score: 2
has body: fun calculateAngle( touchX: Float, touchY: Float, centerX: Float, centerY: Float ): Float { val deltaX = centerX - touchX val deltaY = centerY - touchY return Math.toDegrees(atan2(deltaY.toDouble(), deltaX.toDouble())).toFloat() } This function will return value like If we + 180 to the return value then we will get the value from right to left like 360(&lt;=&gt; 0) -&gt; 45 -&gt; 90 -&gt; 135 -&gt; 180 -&gt; 225 -&gt; 270 -&gt; 315 similar to the angle when we drawArc
downvote count: 0
answers question: http://stackoverflow.com/q/2676719

http://stackoverflow.com/a/2773032
type: AcceptedAnswer
has body: This is an interesting algorithm for generating values. Here is an implementation that I have created based on the explanation give at this page in the references from the wikipedia article. It will create "spherical values" (wrapped at all the edges). There are notes in the comments for how to change it to generate new values on the edges instead of wrapping (though the meaning of average for the edges isn't really correct in these cases). //size of grid to generate, note this must be a //value 2^n+1 final int DATA_SIZE = 9; //an initial seed value for the corners of the data final double SEED = 1000.0; double[][] data = new double[DATA_SIZE][DATA_SIZE]; //seed the data data[0][0] = data[0][DATA_SIZE-1] = data[DATA_SIZE-1][0] = data[DATA_SIZE-1][DATA_SIZE-1] = SEED; double h = 500.0;//the range (-h -&gt; +h) for the average offset Random r = new Random();//for the new value in range of h //side length is distance of a single square side //or distance of diagonal in diamond for(int sideLength = DATA_SIZE-1; //side length must be &gt;= 2 so we always have //a new value (if its 1 we overwrite existing values //on the last iteration) sideLength &gt;= 2; //each iteration we are looking at smaller squares //diamonds, and we decrease the variation of the offset sideLength /=2, h/= 2.0){ //half the length of the side of a square //or distance from diamond center to one corner //(just to make calcs below a little clearer) int halfSide = sideLength/2; //generate the new square values for(int x=0;x&lt;DATA_SIZE-1;x+=sideLength){ for(int y=0;y&lt;DATA_SIZE-1;y+=sideLength){ //x, y is upper left corner of square //calculate average of existing corners double avg = data[x][y] + //top left data[x+sideLength][y] +//top right data[x][y+sideLength] + //lower left data[x+sideLength][y+sideLength];//lower right avg /= 4.0; //center is average plus random offset data[x+halfSide][y+halfSide] = //We calculate random value in range of 2h //and then subtract h so the end value is //in the …
has comment: http://stackoverflow.com/comment/17530273
type: Answer
has comment: http://stackoverflow.com/comment/21983671
upvote count: 27
downvote count: 0
has comment: http://stackoverflow.com/comment/43611258
accepted answer of: http://stackoverflow.com/q/2755750
score: 27
answers question: http://stackoverflow.com/q/2755750
has comment: http://stackoverflow.com/comment/28424240

http://stackoverflow.com/a/2630838
score: 1
upvote count: 1
downvote count: 0
has body: Way back when, the news was that the Java team looked at other languages (primarily C++) and tried to make a judgment call as to what language level features to include (or exclude) from Java. Operator overloading was a big new feature in C++ and lots of budding programmers used it to solve problems in interesting ways. Unfortunately, most of those ways were buggy, and few programmers overloaded operators in ways that were "programmer portable". As a result, reading a program would often miss that "magic" code had been introduced in the "+" operator (or something else). Outside of numbers (vectors, etc.) you also had disagreements as to what "+" might mean. So the cover story (no idea if it was true) was that the Java team saw that you could just name methods sum.plus(...) and it would be obvious that the call was to user written code (which could be overloaded) while the reserved operations "+", etc. would only did what the language defined. This would increase some types of code readability at the expense of a few extra words. Is it true, or is it an attempt to back fill history with rationalizations? I don't know. Perhaps the language implementers just were busy trying to get Java working and didn't get around to operator overloading by release date. Either way, it greatly increases the readability of Java in 95% of all cases, at the expense of making vector math a bit wordy.
answers question: http://stackoverflow.com/q/2629501
type: Answer

http://stackoverflow.com/comment/15893279
score: 389
type: AnswerComment
comment on: http://stackoverflow.com/a/2671636
type: Comment
has text: A few good examples here. I would add, however, that "static" is often valuable when you know something is not going to change across instances. If this is the case, I would really consider the "Single Responsability Principle", which implies a class should have one responsability and thus only one reason to change. I feel one should consider moving the "ConvertMpgToKpl(double mpg)" function, and similar methods, to their own class. The purpose of a car object is to allow instantiation of cars, not provide a comparison between them. Those should be external to the class.

http://stackoverflow.com/q/2605111
type: UnansweredQuestion
downvote count: 0
score: 1
tagged with: java
type: Question
has body: I wrote an Applet program which draws a pie chart. The values for the applet should be passed from JSP page. I wrote the following lines of code in JSP: &lt;jsp:plugin type="applet" code="drawPie" codebase="." width="750" heigth="300"&gt; &lt;jsp:params&gt; &lt;jsp:param name="user_id" value="&lt;% =user %&gt;"/&gt; &lt;/jsp:params&gt; &lt;/jsp:plugin&gt; and in applet I used String user=getParameter("user_id"); when I open the jsp page nothing comes neither error nor the chart. What is the problem/error in the above code snippet?
has answer: http://stackoverflow.com/a/2605201
upvote count: 1
has title: Including Applet in JSP page
answer count: 1
tagged with: jsp
tagged with: applet
favorite count: 0

http://stackoverflow.com/q/2726182
has comment: http://stackoverflow.com/comment/2754701
has answer: http://stackoverflow.com/a/27925110
has answer: http://stackoverflow.com/a/2726188
favorite count: 0
has comment: http://stackoverflow.com/comment/2758656
upvote count: 5
answer count: 5
type: AnsweredQuestion
has title: Location of Java dump heap file when using jconsole?
downvote count: 0
accepted answer: http://stackoverflow.com/a/2731852
tagged with: java
tagged with: eclipse
tagged with: heap-dump
possible better answer: http://stackoverflow.com/a/2726328
type: Question
has answer: http://stackoverflow.com/a/2726328
score: 5
has answer: http://stackoverflow.com/a/2731852
has answer: http://stackoverflow.com/a/3191652
tagged with: jconsole
has comment: http://stackoverflow.com/comment/2753124
has body: Well this is embarrassing ... I'm starting to play with the Eclipse Memory Analyzer to look for Java memory leaks on a Windows box. Step 1 is to obtain a heap dump file. To do this I start my Java (javaw.exe) process from within Eclipse and connect to it with jconsole. Then on the jconsole MBeans tab I click the dumpHeap button. The first time I did this, I saw a pop-up saying it had created the heap dump file, but not giving its name or location. Now whenever I do a dumpHeap again while connected to a different javaw.exe process, jconsole says: Problem invoking dumpHeap : java.io.IOException: File exists and of course doesn't give its name or path. Where could it be? I've searched my C: drive (using cygwin command line tools) for files containing "hprof" or "java_pid" or "heapdump" and didn't find anything plausible. I've even used the Windows search to look for all files in my Eclipse workspace that have changed in the last day. I'm using the Sun Java 1.6 JVM, and don't have -XX:HeapDumpPath set. Update (28 April 2010): My original heap file location must have been determined by jconsole, the tool I triggered the heap dump from. The JVM's heap dump location must apply only to heap dumps it triggers (eg, on an OutOfMemoryException). Matt B's suggestion to use jvisualvm nicely solves my problem by pointing me to a far more useful replacement for the old jconsole. It has a nice memory profiler that shows which types of objects are most numerous and hold the most memory. And it has a monitor that shows actual memory use over time. When you ask it for a heap dump, it tells you the file name even! The Eclipse Memory Analyzer gives you full details.
has comment: http://stackoverflow.com/comment/2758632

http://stackoverflow.com/q/2671103
answer count: 4
favorite count: 0
has answer: http://stackoverflow.com/a/2671250
has comment: http://stackoverflow.com/comment/2690018
has comment: http://stackoverflow.com/comment/2689674
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2671964
has title: How to make a try-catch block that keeps on calling a method on an object until there are no more exceptions to catch
has answer: http://stackoverflow.com/a/2671120
downvote count: 0
score: 1
tagged with: java
tagged with: loops
has answer: http://stackoverflow.com/a/2671934
tagged with: try-catch-finally
has body: Basically iterating through a list and, - Invoke method on first object - Catch the first exception (if any); if there are no more exceptions to catch, return normally. Otherwise, keep on invoking method until all exceptions are caught. - Move on to next object. I can iterate through each object, invoke the method, and catch one exception but I do not know how to continuously invoke the method on it and keep on catching exceptions.
type: Question
tagged with: try-catch
upvote count: 1

http://stackoverflow.com/a/2735664
upvote count: 4
has body: package org.com; import java.lang.*; import java.util.*; public class Calculator { private int solution; private static int x; private static int y; private char operators; public Calculator() { solution = 0; Scanner operators = new Scanner(System.in); Scanner operands = new Scanner(System.in); } public int addition(int x, int y) { return x + y; } public int subtraction(int x, int y) { return x - y; } public int multiplication(int x, int y) { return x * y; } public int division(int x, int y) { solution = x / y; return solution; } public void calc(int ops){ x = 4; System.out.println("operand 2: "); y = 5; switch(ops) { case(1): System.out.println(addition(x, y)); // operands.next(); break; case(2): System.out.println(subtraction(x, y)); // operands.next(); break; case(3): System.out.println(multiplication(x, y)); // operands.next(); break; case(4): System.out.println(division(x, y)); // operands.next(); break; } } public static void main (String[] args) { System.out.println("What operation? ('+', '-', '*', '/')"); System.out.println(" Enter 1 for Addition"); System.out.println(" Enter 2 for Subtraction"); System.out.println(" Enter 3 for Multiplication"); System.out.println(" Enter 4 for Division"); Calculator calc = new Calculator(); calc.calc(1); } } This will work
downvote count: 0
score: 4
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2734227
type: Answer
answers question: http://stackoverflow.com/q/2734227

http://stackoverflow.com/q/2730343
type: Question
has body: I am creating an options dialog using JOptionPane.showOptionDialog(...) When I click one of the buttons added to this dialog, I need a label to apear underneath on the dialog (and this label should be scrollable if necessary). I have written event handlers for the buttons, but I am not sure how to get this label to appear on the dialog. Any help would be great. Update: I realized that it would be ok if I somehow called JOptionPane.showOptionDialog(...) with an initial message, and then when one of the buttons was clicked I would change the message. Is this possible?
answer count: 1
downvote count: 0
has answer: http://stackoverflow.com/a/2730477
favorite count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2757749
has title: Adding a scrollable label to an option dialog
score: 1
accepted answer: http://stackoverflow.com/a/2730477
tagged with: java
has comment: http://stackoverflow.com/comment/2757779
upvote count: 1
tagged with: swing

http://stackoverflow.com/a/2631661
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/2631650
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/2645075
has body: You never give unknown a value when you declare it, not even null. The compiler doesn't know what happens in the try block, and can't guarantee that anything inside takes place. So, as far as it knows, unknown isn't referencing anything until the moment your println() hits. EDIT: To clarify, all the compiler knows is that an exception might be thrown at any point during a try block, so it can't assume that what you put in there will succeed.

http://stackoverflow.com/q/2676514
answer count: 1
downvote count: 0
favorite count: 0
type: UnansweredQuestion
tagged with: http://stackoverflow.com/tag/xml
tagged with: java
has body: Where is the documentation for quartz xml files (specifically jobs.xml)? I found the javadoc online, but I can't seem to find the documentation for how to write an xml file, just some brief examples e.g. this one from O'Reilly. edit: apparently the java class that reads the jobs.xml is JobInitializationPlugin, but I don't see the docs for the xml format there either.
tagged with: quartz-scheduler
has answer: http://stackoverflow.com/a/2683589
type: Question
upvote count: 5
has title: quartz: documentation for xml files?
score: 5

http://stackoverflow.com/comment/2686371
type: Comment
score: 1
has text: Both point will always be visible using this method. However, the further the points are from each other the less accurate this method becomes.
type: AnswerComment
comment on: http://stackoverflow.com/a/2668076

http://stackoverflow.com/a/55292496
has comment: http://stackoverflow.com/comment/137498530
upvote count: 25
downvote count: 1
has body: Open the windows cmd. First list all the java processes, jps -m now get the name and run below command, for /f "tokens=1" %i in ('jps -m ^| find "Name_of_the_process"') do ( taskkill /F /PID %i ) or simply kill the process ID taskkill /F /PID &lt;ProcessID&gt; sample :) C:\Users\tk&gt;jps -m 15176 MessagingMain 18072 SoapUI-5.4.0.exe 15164 Jps -m 3420 org.eclipse.equinox.launcher_1.3.201.v20161025-1711.jar -os win32 -ws win32 -arch x86_64 -showsplash -launcher C:\Users\tk\eclipse\jee-neon\eclipse\eclipse.exe -name Eclipse --launcher.library C:\Users\tk\.p2\pool\plugins\org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.401.v20161122-1740\eclipse_1617.dll -startup C:\Users\tk\eclipse\jee-neon\eclipse\\plugins/org.eclipse.equinox.launcher_1.3.201.v20161025-1711.jar --launcher.appendVmargs -exitdata 4b20_d0 -product org.eclipse.epp.package.jee.product -vm C:/Program Files/Java/jre1.8.0_131/bin/javaw.exe -vmargs -Dosgi.requiredJavaVersion=1.8 -XX:+UseG1GC -XX:+UseStringDeduplication -Dosgi.requiredJavaVersion=1.8 -Xms256m -Xmx1024m -Declipse.p2.max.threads=10 -Doomph.update.url=http://download.eclipse.org/oomph/updates/milestone/latest -Doomph.redirection.index.redirection=index:/-&gt;http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/ -jar C:\Users\tk\ and C:\Users\tk&gt;for /f "tokens=1" %i in ('jps -m ^| find "MessagingMain"') do ( taskkill /F /PID %i ) C:\Users\tk&gt;(taskkill /F /PID 15176 ) SUCCESS: The process with PID 15176 has been terminated. or C:\Users\tk&gt;taskkill /F /PID 15176 SUCCESS: The process with PID 15176 has been terminated.
score: 24
answers question: http://stackoverflow.com/q/2643901
type: Answer

http://stackoverflow.com/a/2684001
type: Answer
upvote count: 4
downvote count: 0
has body: You could try an algorithm like this: String collapsePath(String path) { /* Split into directory parts */ String[] directories = path.split("/"); String[] newDirectories = new String[directories.length]; int i, j = 0; for (i=0; i&lt;directories.length; i++) { /* Ignore the previous directory if it is a double dot */ if (directories[i].equals("..") &amp;&amp; j &gt; 0) newDirectories[j--] = ""; /* Completely ignore single dots */ else if (! directories[i].equals(".")) newDirectories[j++] = directories[i]; } /* Ah, what I would give for String.join() */ String newPath = new String(); for (i=0; i &lt; j; i++) newPath = newPath + "/" + newDirectories[i]; return newPath; } It isn't perfect; it's linear over the number of directories but does make a copy in memory.
answers question: http://stackoverflow.com/q/2683676
score: 4

http://stackoverflow.com/comment/2617515
type: Comment
score: 0
has text: Dunno I didn't vote you down +1
comment on: http://stackoverflow.com/a/2607259
type: AnswerComment

http://stackoverflow.com/comment/2723925
score: 0
type: Comment
comment on: http://stackoverflow.com/q/2701100
type: QuestionComment
has text: Do a `which java` to find out which physical java executable is being run! Is it possible you have a local shell script or `alias` shortcutting directly to one of your javas?

http://stackoverflow.com/comment/2609748
score: 0
type: Comment
has text: Doubtful to the homework comment.
type: QuestionComment
comment on: http://stackoverflow.com/q/2600608

http://stackoverflow.com/q/2723809
has answer: http://stackoverflow.com/a/2724073
has comment: http://stackoverflow.com/comment/2750296
score: 0
tagged with: jakarta-mail
answer count: 3
has comment: http://stackoverflow.com/comment/2750283
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/2750616
has comment: http://stackoverflow.com/comment/2750275
upvote count: 1
has comment: http://stackoverflow.com/comment/2750332
has answer: http://stackoverflow.com/a/2724211
tagged with: java
has comment: http://stackoverflow.com/comment/2750571
downvote count: 1
has title: What's wrong with this code
type: Question
has answer: http://stackoverflow.com/a/2723889
has body: I am getting the compiler error. Can anybody debug this? import javax.mail.*; import javax.mail.internet.*; import java.util.*; public class SendMail { public static void main(String [] args) { SendMail sm=new SendMail(); sm.postMail("abc@yahoo.com","hi","hello","xyz@gmail.com"); } public void postMail( String recipients[ ], String subject, String message , String from) throws MessagingException { boolean debug = false; //Set the host smtp address Properties props = new Properties(); props.put("mail.smtp.host", "webmail.emailmyname.com"); // create some properties and get the default Session Session session = Session.getDefaultInstance(props, null); session.setDebug(debug); // create a message Message msg = new MimeMessage(session); // set the from and to address InternetAddress addressFrom = new InternetAddress(from); msg.setFrom(addressFrom); InternetAddress[] addressTo = new InternetAddress[recipients.length]; for (int i = 0; i &lt; recipients.length; i++) { addressTo[i] = new InternetAddress(recipients[i]); } msg.setRecipients(Message.RecipientType.TO, addressTo); // Optional : You can also set your custom headers in the Email if you Want msg.addHeader("MyHeaderName", "myHeaderValue"); // Setting the Subject and Content Type msg.setSubject(subject); msg.setContent(message, "text/plain"); Transport.send(msg); } }

http://stackoverflow.com/a/2674509
has body: you can't run directly the run() method. Whenever start your thread by using thread.start(), then the run() method has been called and performed the further operation.
score: 0
answers question: http://stackoverflow.com/q/2674174
type: Answer

http://stackoverflow.com/comment/2804356
score: 1
has text: looking at the docs for the HttpExchange class, this seems like a server-side class, as it returns the response, yet your description indicates that you are using it client side? Can you confirm where you are using HttpExchange, and perhaps post a code snippet of your client side code?
comment on: http://stackoverflow.com/q/2770940
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/2676127
comment on: http://stackoverflow.com/a/2656786
score: 0
type: AnswerComment
type: Comment
has text: +1 Good comments. I would only point out, regarding your first point about profiling tools, that 1) sampling the PC register is nearly useless (compared to sampling the stack) in all but the simplest programs, and 2) not many samples are needed, because accuracy of time measurement is not needed (assuming the goal is to find fruitful points to optimize). Here's more on that subject: http://stackoverflow.com/questions/1777556/alternatives-to-gprof/1779343#1779343

http://stackoverflow.com/q/2671031
linked to: http://stackoverflow.com/q/3202305
has comment: http://stackoverflow.com/comment/139777972
has answer: http://stackoverflow.com/a/2671329
linked to: http://stackoverflow.com/q/6159118
score: 0
answer count: 1
tagged with: parsing
has body: I am new to parsers. I like to fetch specific data from a website. I need to use parsers for that. How to get started with parsers? What do I need to download? What would the code be to fetch the data from a website using parsers in Java?
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/2044017
tagged with: java
has title: Getting started with a parser in Java code
type: Question

http://stackoverflow.com/q/2616293
upvote count: 1
possible better answer: http://stackoverflow.com/a/2616300
favorite count: 0
has answer: http://stackoverflow.com/a/2618457
tagged with: http://stackoverflow.com/tag/html
accepted answer: http://stackoverflow.com/a/2618457
type: AnsweredQuestion
downvote count: 0
score: 1
has answer: http://stackoverflow.com/a/2616300
tagged with: java
has body: Anyone know a decent Java libarary for HTML elements? Ex if I want to create an img-element, I would go new Image(...) The object should support the normal HTML functions/attributes, such as setting CSS or disable.
has answer: http://stackoverflow.com/a/2616400
type: Question
tagged with: tags
has title: Java libarary for HTML elements/tags
answer count: 3

http://stackoverflow.com/comment/2618988
score: 0
has text: @dbemerlin: Hence the word "roughly" above. I completely agree with you. In a case like a BankAccount class, it's easy to define methods that don't hint at the structure: deposit(double amt), withdraw(double amt), transfer(BankAccount acct, double amt). It's not so easy as classes represent objects more far removed from things we are familiar with. For example, setting the properties of a Swing component.
comment on: http://stackoverflow.com/a/2607718
type: AnswerComment
type: Comment

http://stackoverflow.com/a/2675974
downvote count: 0
has comment: http://stackoverflow.com/comment/2694858
has comment: http://stackoverflow.com/comment/2694881
has body: Allowing double values as indices is a pretty large change from what ArrayList does. The reason for this is that an array or list with double as indices would almost by definition be a sparse array, which means it has no value (or depending on your definition: a fixed, known value) for almost all possible indices and only a finite number of indices have an explicit value set. There is no prebuilt class in Java SE that supports all that. Personally I'd implement such a data structure as a skip-list (or similar fast-searching data structure) of (index, value) tuples with appropriate interpolation. Edit: Actually there's a pretty good match for the back-end storage (i.e. everything except for the interpolation): Simply use a NavigableMap such as a TreeMap to store the mapping from index to value. With that you can easily use ceilingEntry() and (if necessary) higherEntry() to get the closest value(s) to the index you need and then interpolate from those.
score: 4
has comment: http://stackoverflow.com/comment/2694825
type: Answer
answers question: http://stackoverflow.com/q/2675929
upvote count: 4

http://stackoverflow.com/comment/2636279
type: AnswerComment
comment on: http://stackoverflow.com/a/2623282
type: Comment
has text: Looks fun, easy and I expect you can leverage libraries with ease. I have a penchant for Amazon AWS S3. I could utilize the Java JetS3t toolkit just like another library, could I?
score: 0

http://stackoverflow.com/q/2741231
has answer: http://stackoverflow.com/a/2741253
tagged with: loops
type: Question
possible better answer: http://stackoverflow.com/a/2741236
has answer: http://stackoverflow.com/a/2741632
has answer: http://stackoverflow.com/a/2741292
score: 5
has answer: http://stackoverflow.com/a/2741236
upvote count: 5
answer count: 6
tagged with: arraylist
downvote count: 0
has body: My problem is as follows. I have an arraylist of integers. The arraylist contains 5 ints e.g[5,5,3,3,9] or perhaps [2,2,2,2,7]. Many of the arraylists have duplicate values and i'm unsure how to count how many of each of the values exist. The problem is how to find the duplicate values in the arraylist and count how many of that particular duplicate there are. In the first example [5,5,3,3,9] there are 2 5's and 2 3's. The second example of [2,2,2,2,7] would be only 4 2's. The resulting information i wish to find is if there are any duplicates how many of them there are and what specific integer has been duplicated. I'm not too sure how to do this in java. Any help would be much appreciated. Thanks.
accepted answer: http://stackoverflow.com/a/2741632
favorite count: 0
has answer: http://stackoverflow.com/a/2741319
has answer: http://stackoverflow.com/a/2741239
tagged with: integer
type: AnsweredQuestion
has title: How to find multiples of the same integer in an arraylist?
tagged with: java

http://stackoverflow.com/a/2680547
type: AcceptedAnswer
upvote count: 3
type: Answer
score: 3
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2680513
answers question: http://stackoverflow.com/q/2680513
has body: This sort of kills the very purpose of Java (portability of the language), so you should always try to use the files compiled as .jar, since most of the computers out there (especially Windows and Macs) do have a Java Virtual Machine. If you really need to compile something down to exe, you should be interested in Ahead-of-Time compilers (AOT), one of them being the GNU Compiler for Java.

http://stackoverflow.com/a/2694523
score: 1
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/2694470
has body: Try renaming Variable Rand to other name..
downvote count: 0

synchronization
tags question: http://stackoverflow.com/q/2715983
tags question: http://stackoverflow.com/q/2778313
tags question: http://stackoverflow.com/q/2611754
tags question: http://stackoverflow.com/q/2650458
tags question: http://stackoverflow.com/q/2759727
tag name: synchronization
tags question: http://stackoverflow.com/q/2728311
tags question: http://stackoverflow.com/q/2760294
type: Tag
tags question: http://stackoverflow.com/q/2647039
tags question: http://stackoverflow.com/q/2733630
tags question: http://stackoverflow.com/q/2695426

http://stackoverflow.com/a/2773798
has comment: http://stackoverflow.com/comment/2807602
type: Answer
answers question: http://stackoverflow.com/q/2773717
has comment: http://stackoverflow.com/comment/2807880
score: 0
has body: I would have create another interface IAveragable which contains the average operation which derives from Value . Then StringValue would implement just Value interface and NumberValue would implement IAveragable. Then when it is required to use the average operation I would check if the object implements IAveragable.

http://stackoverflow.com/q/2693268
has body: I'm using Spring Security 3.0.2 form based authentication. But I can't figure out how I can configure it so that when a session expires that the request is not redirect to an other page (expired-url) or displays a 'session expires' message. I don't want any redirect or messages, I want that a anonymous session is started just like when a user without a session enters the website. My current configuration: &lt;http&gt; &lt;intercept-url pattern="/login.action*" filters="none"/&gt; &lt;intercept-url pattern="/admin/**" access="ROLE_ADMIN" /&gt; &lt;intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY"/&gt; &lt;form-login login-page="/login.action" authentication-failure-url="/login.action?error=failed" login-processing-url="/login-handler.action"/&gt; &lt;logout logout-url="/logoff-execute.action" logout-success-url="/logoff.action?done=1"/&gt; &lt;remember-me key="remember-me-security" services-ref="rememberMeServices"/&gt; &lt;session-management &gt; &lt;concurrency-control max-sessions="1" error-if-maximum-exceeded="false" expired-url="/login.action?error=expired.url"/&gt; &lt;/session-management&gt; &lt;/http&gt;
score: 6
has answer: http://stackoverflow.com/a/2725518
accepted answer: http://stackoverflow.com/a/2725518
has comment: http://stackoverflow.com/comment/52440838
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/47310438
downvote count: 0
tagged with: java
has title: Spring Security: session expiration without redirect to expired-url?
type: Question
tagged with: session
upvote count: 6
answer count: 2
possible better answer: http://stackoverflow.com/a/47310438
tagged with: spring-security
favorite count: 0

http://stackoverflow.com/q/2741151
type: Question
type: AnsweredQuestion
tagged with: java
has title: Why can't Java servlet sent out an object?
has body: I use the following method to send out an object from a servlet : public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException { String Full_URL=request.getRequestURL().append("?"+request.getQueryString()).toString(); String Contact_Id=request.getParameter("Contact_Id"); String Time_Stamp=Get_Date_Format(6),query="select from "+Contact_Info_Entry.class.getName()+" where Contact_Id == '"+Contact_Id+"' order by Contact_Id desc"; PersistenceManager pm=null; try { pm=PMF.get().getPersistenceManager(); // note that this returns a list, there could be multiple, DataStore does not ensure uniqueness for non-primary key fields List&lt;Contact_Info_Entry&gt; results=(List&lt;Contact_Info_Entry&gt;)pm.newQuery(query).execute(); Write_Serialized_XML(response.getOutputStream(),results.get(0)); } catch (Exception e) { Send_Email(Email_From,Email_To,"Check_License_Servlet Error [ "+Time_Stamp+" ]",new Text(e.toString()+"\n"+Get_Stack_Trace(e)),null); } finally { pm.close(); } } /** Writes the object and CLOSES the stream. Uses the persistance delegate registered in this class. * @param os The stream to write to. * @param o The object to be serialized. */ public static void writeXMLObject(OutputStream os,Object o) { // Classloader reference must be set since netBeans uses another class loader to loead the bean wich will fail in some circumstances. ClassLoader oldClassLoader=Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(Check_License_Servlet.class.getClassLoader()); XMLEncoder encoder=new XMLEncoder(os); encoder.setExceptionListener(new ExceptionListener() { public void exceptionThrown(Exception e) { e.printStackTrace(); }}); encoder.writeObject(o); encoder.flush(); encoder.close(); Thread.currentThread().setContextClassLoader(oldClassLoader); } private static ByteArrayOutputStream writeOutputStream=new ByteArrayOutputStream(16384); /** Writes an object to XML. * @param out The boject out to write to. [ …
tagged with: servlets
answer count: 1
has comment: http://stackoverflow.com/comment/2770535
accepted answer: http://stackoverflow.com/a/2741654
favorite count: 0
score: 0
has comment: http://stackoverflow.com/comment/2769979
has comment: http://stackoverflow.com/comment/2770044
linked to: http://stackoverflow.com/q/2701565
has comment: http://stackoverflow.com/comment/2770020
upvote count: 1
downvote count: 1
has answer: http://stackoverflow.com/a/2741654

http://stackoverflow.com/comment/57024998
type: Comment
type: QuestionComment
has text: You will want to try [android sqlite asset helper](https://github.com/jgilfelt/android-sqlite-asset-helper). It makes it a piece of cake.
comment on: http://stackoverflow.com/q/2605555
score: 0

http://stackoverflow.com/comment/132785271
comment on: http://stackoverflow.com/a/41406399
type: Comment
score: 1
has text: Even 7 years after you posted this solution, it's saving us developers time and effort. I needed just this solution for an ad hoc delta report. Thanks!
type: AnswerComment

http://stackoverflow.com/comment/2756962
score: 0
has text: I tried running it and it runs fine, not sure why you have a dispose() in your constructor. Can you clarify your question ? what are you asking ?
comment on: http://stackoverflow.com/q/2729536
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2692772
has answer: http://stackoverflow.com/a/2692847
downvote count: 0
tagged with: tomcat
favorite count: 0
score: 3
has body: i want to create a photo album. But I want to organize on the server the albums so I want to create new folders : /myapp /myapp/albums /myapp/albums/1 /myapp/albums/2 ... How can I do that on tomcat with Grails ? It create all new folder in tomcat/bin not in tomcat/webapps/myapp/
possible better answer: http://stackoverflow.com/a/2692876
accepted answer: http://stackoverflow.com/a/2692847
has answer: http://stackoverflow.com/a/2692876
upvote count: 3
type: Question
type: AnsweredQuestion
has title: How can I create a new folder in my web-app (for upload photo album) with Grails on Tomcat?
tagged with: java
tagged with: grails
answer count: 2

http://stackoverflow.com/comment/2719423
comment on: http://stackoverflow.com/a/2697005
type: AnswerComment
score: 0
type: Comment
has text: My program called a new class Now and did not resulted in error. Thnx a lot

http://stackoverflow.com/a/2616462
score: 1
type: Answer
has body: You may want to try JavaFX. For all its problems, I find that if you want to put a decent (preetier than Swing) interface over your Java application, its quite easy to do. Plus good Java integration. You can implement Java interfaces in JavaFX and vice versa.
upvote count: 1
has comment: http://stackoverflow.com/comment/79549795
answers question: http://stackoverflow.com/q/2616448
downvote count: 0

http://stackoverflow.com/comment/2747612
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2721001
has text: @mdma - yours is a highly unusual use-case. And anyway, a custom BeanFactory should do the job for you.

http://stackoverflow.com/q/2669926
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/32699420
has answer: http://stackoverflow.com/a/3296467
has title: Practical advice on using Jersey and Guice for RESTful service
has answer: http://stackoverflow.com/a/27817392
type: Question
has answer: http://stackoverflow.com/a/35689981
tagged with: java
has answer: http://stackoverflow.com/a/9646401
possible better answer: http://stackoverflow.com/a/3296467
answer count: 11
has body: From what I can find online, the state of the art for Guice + Jersey integration has stagnated since 2008 when it appears both teams reached an impasse. The crux of the issue is that JAX-RS annotations perform field and method injection and this doesn't play nicely with Guice's own dependency injection. A few examples which I've found don't go far enough to elucidate: Iqbalyusuf's post on Jersey + Guice on Google App Engine Java suffers from a lot of boilerplate (manually getting and calling the injector). I want binding and injection should happen behind the scenes via Guice annotations. Jonathan Curran's article Creating a RESTful service with Jersey, Guice, and JSR-250 gave me hope because it's much more current (2010), but went no further than showing how to start up a Jersey service inside of a Guice ServletModule. However, there are no examples of doing any real dependency injection. I suppose that was left as an exercise for the reader. Curran's post may in fact be the correct first step towards wiring up Guice and Jersey and so I plan on starting with that. tantalizingly James Strachan writes: JAX-RS works well with dependency injection frameworks such as Spring, Guice, GuiceyFruit or JBossMC - you can basically pick whichever one you prefer. But I see no evidence that is true from a practitioner's point of view. What I find lacking are practical examples and explanations on how to combine JAX-RS and Guice annotations. For instance: I believe I cannot use constructor injection with any resource as Jersey wants to control this I'm uncertain whether I can combine @Inject with @PathParam, @QueryParam, et al. How to use injection in a MessageBodyWriter implementation Does anyone have examples, preferably with source, of non-trivial application which combines Jersey and Guice without sacrificing one or the other in the process? I'm keeping on this road regardless, but the bits and pieces on the Jersey and Guice lists makes me think I'm repeating the work of other…
has answer: http://stackoverflow.com/a/6172474
tagged with: jersey
has answer: http://stackoverflow.com/a/4220273
tagged with: guice
has answer: http://stackoverflow.com/a/6801866
downvote count: 0
tagged with: jax-rs
has answer: http://stackoverflow.com/a/52491123
favorite count: 0
score: 64
has answer: http://stackoverflow.com/a/2683080
upvote count: 64
has answer: http://stackoverflow.com/a/9613252
has answer: http://stackoverflow.com/a/4490211
has comment: http://stackoverflow.com/comment/2702743
accepted answer: http://stackoverflow.com/a/6172474
tagged with: jsr330

http://stackoverflow.com/a/2750629
answers question: http://stackoverflow.com/q/2749275
score: 1
has body: Create Items as demonstrated in this posting
downvote count: 0
type: Answer
upvote count: 1

http://stackoverflow.com/a/2780158
has comment: http://stackoverflow.com/comment/2816230
has comment: http://stackoverflow.com/comment/2815834
type: Answer
answers question: http://stackoverflow.com/q/2780129
has comment: http://stackoverflow.com/comment/2816017
has comment: http://stackoverflow.com/comment/2815737
score: 0
has body: You should have a HashMap with the numbers as keys and the enum values as values. This map can typically be in your repository. Then you can easily replace an int variable from the database with your preferred enum value. If your keys (int values) are stored in a database, then I will say its bad design to carry those keys around in an enum on your business layer. If that's the case, I will recommend not to store the int value in the enum.
has comment: http://stackoverflow.com/comment/2815813

http://stackoverflow.com/a/2754269
type: AcceptedAnswer
has body: You could do a lot of things, I will just list them in order that will give you the best impact. FlexTable is not meant for 300 rows. Since your table is so simple, you should consider generating the HTML by hand, and then using simple HTML widget. Also, 300 rows is a lot of information - consider using pagination. The DynaTable sample app shows you how to do this. It looks like you are using one GWT module per page. That is the wrong approach to GWT. Loading a GWT module has some non-trivial cost. To understand what I mean, compare browser refresh on gmail v/s the refresh link that gmail provides. That is the same cost you pay when every page in your website has a distinct GWT module. If the list of candidates is needed across views, you can send it along with the HTML as a JSON object, and then use the Dictionary class in GWT to read it. This saves you the RPC call that you are making. This approach is only recommended if the data is going to be useful across multiple views/screens (like logged in users info) Check how long your RPC method call is taking. You can enable stats in GWT to figure out where your application is taking time. You can also run Speed Tracer to identify where the bottleneck is. This is last only because it is obvious FlexTable is performing a lot of DOM manipulations. In general, if you don't know where to start, Speed Tracer is a great tool.
type: Answer
score: 8
answers question: http://stackoverflow.com/q/2754035
accepted answer of: http://stackoverflow.com/q/2754035
downvote count: 0
upvote count: 8

http://stackoverflow.com/a/2757628
downvote count: 0
score: 1
has body: Is your application a Swing application or not? You are probably using an IDE which you automatically let organize the imports in your source file. The IDE added an import for javax.swing.text.Document instead of org.w3c.dom.Document. This is something I've encountered myself often while using the Eclipse IDE. What you have to do: Remove this line from the top of your source code file: import javax.swing.text.Document; Replace it with: import org.w3c.dom.Document;
answers question: http://stackoverflow.com/q/2757034
has comment: http://stackoverflow.com/comment/2792214
upvote count: 1
has comment: http://stackoverflow.com/comment/2789683
type: Answer

http://stackoverflow.com/q/2622658
tagged with: java
tagged with: javascript
answer count: 2
tagged with: encoding
has answer: http://stackoverflow.com/a/2622797
has body: I have a javascript file that lots of people have embedded to their pages. Since I am hosting the file, I have control over that javascript file; I cannot control the way it is embedded because lots of people is using it already. This javascript file sends GET requests to my servlets, and the parameters passed with the request are recorded to DB. For example, javascript sends a request to http://myserver.com/servlet?p1=123&amp;p2=aString and then servlet records 123 and aString to DB somehow. Before sending strings I use encodeURIComponent() to encode it. But what I figured out is every client sends the same string with different encodings depending on either their browser or the site they are visiting. As a result, same strings are represented with different characters when it reaches servlet (so they are different strings). What I am trying to do is to convert the strings to one kind of encoding from javascript so when they reach the client same words are represented with same characters. How is this possible? PS. If there is a way to convert the encoding from Java it is also applicable. Edit: To be more precise, I select some words from the page and send it to the server. That is where encoding causes problems. Edit 2: I am NOT sending (and can't send) GET requests via XMLHttpRequest, because domains are different. I am using adding script tag to head method that @streetpc mentioned. Edit 3: At the moment I am sanitizing the strings by replacing non-ASCII characters at javascript side, but I have a feeling that this is not the way to go: function sanitize(word) { /* ğ : \u011f ü : \u00fc ş : \u015f ö : \u00f6 ç : \u00e7 ı : \u0131 û : \u00fb */ return encodeURIComponent( word.replace(/\u011f/g, '_g') .replace(/\u00fc/g, '_u') .replace(/\u00fb/g, '_u') .replace(/\u015f/g, '_s') .replace(/\u00f6/g, '_o') .replace(/\u00e7/g, '_c') .replace(/\u0131/g, '_i')); }
downvote count: 0
score: 1
tagged with: unicode
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2622779
tagged with: utf-8
has title: How to send parameters with same encoding from javascript?
upvote count: 1
type: Question

http://stackoverflow.com/q/2676890
has title: Java Socket fails to transmit data over the network
has answer: http://stackoverflow.com/a/2676920
score: 0
answer count: 2
tagged with: knopflerfish
has body: I'm experiencing a bizarre problem with sockets between a Java Knopflerfish client bundle and a PHP (CLI, not web) server. The client/server pair work fine when both are located on the localhost, and all data is transmitted successfully. However, when the Java client exists on a different machine, connections to the server are successful, but no data is received by the PHP script. Packet analysis confirms that the data sent by the Java client is received on by the server - PHP just seems to have problems getting its hands on it. As a further note, I've done some tests with telnet as the client. The PHP server script receives all data fine from any host. This leads me to believe that the problem has something to do with the way java is setting up the socket or that there is some networking issue that I'm not familiar with. Any thoughts would be appreciated. Can post code samples if desired.
type: UnansweredQuestion
tagged with: sockets
tagged with: php
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/2695865
tagged with: network-programming
has answer: http://stackoverflow.com/a/2677327

http://stackoverflow.com/a/39552448
type: Answer
has body: Rather than thinking about making the resource a singleton, focus more on managing backend, service type objects like your ResponseGenerator class as singletons, which obviously shouldn't be instantiated every request. Making the resource a singleton as well is one way of managing ResponseGenerator as a singleton, but it's not the only or necessarily the best way, see Access external objects in Jersey Resource class and How to wire in a collaborator into a Jersey resource? for ways to inject this into non-singleton resources. Note that your ResponseGenerator class would need work before it would function as a singleton, whether injected into a per-request resource or instantiated in a singleton resource. It's not thread safe, and you would open a single connection on startup and reuse it across requests, which won't work, you should use a connection pool to do the heavy lifting of efficiently + safely reusing connections across requests. Some comments on best practices for the code will also be helpful. You'll get better responses on http://codereview.stackexchange.com, but: ResponseGenerator is a poor name for a class (just about everything in a web application is a response generator). don't use String as the return type of your service and object, use proper typed objects (eg it sounds like you're returning a java.util.List of something). Don't swallow your SQLException, bubble it up to allow Jersey to generate a 5xx series response code in your resource. Use final member variables. Your log object should be static.
score: 0
answers question: http://stackoverflow.com/q/2749378

http://stackoverflow.com/q/2699209
has comment: http://stackoverflow.com/comment/61623402
favorite count: 0
tagged with: file-io
score: 45
has answer: http://stackoverflow.com/a/26299875
has answer: http://stackoverflow.com/a/2699330
has answer: http://stackoverflow.com/a/2699270
has body: Is there a not so ugly way of treat the close() exception to close both streams then: InputStream in = new FileInputStream(inputFileName); OutputStream out = new FileOutputStream(outputFileName); try { copy(in, out); } finally { try { in.close(); } catch (Exception e) { try { // event if in.close fails, need to close the out out.close(); } catch (Exception e2) {} throw e; // and throw the 'in' exception } } out.close(); } update: All the above code is within one more try-catch, thanks for the warnings. FINALLY (after the answers): And a good utility method can be done using Execute Around idiom (thanks Tom Hawtin).
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2751831
answer count: 12
has answer: http://stackoverflow.com/a/2699241
has answer: http://stackoverflow.com/a/25900919
accepted answer: http://stackoverflow.com/a/2699270
linked to: http://stackoverflow.com/q/2441853
has answer: http://stackoverflow.com/a/8893549
has answer: http://stackoverflow.com/a/35624271
linked to: http://stackoverflow.com/q/341971
type: Question
tagged with: try-catch
possible better answer: http://stackoverflow.com/a/2699250
has answer: http://stackoverflow.com/a/2699257
has answer: http://stackoverflow.com/a/2699250
tagged with: java
has answer: http://stackoverflow.com/a/2699273
has title: Java io ugly try-finally block
has answer: http://stackoverflow.com/a/2699570
linked to: http://stackoverflow.com/q/12552863
has comment: http://stackoverflow.com/comment/2723163
downvote count: 0
upvote count: 45
linked to: http://stackoverflow.com/q/884007
has answer: http://stackoverflow.com/a/2699364
has comment: http://stackoverflow.com/comment/2721750

http://stackoverflow.com/comment/2724777
comment on: http://stackoverflow.com/a/2700468
type: Comment
score: 0
has text: That sounds like fun! ;) Glad I could help.
type: AnswerComment

http://stackoverflow.com/a/2758991
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/2790653
answers question: http://stackoverflow.com/q/2758879
has body: DI makes it easy to mock your implementation for writing tests. For example, suppose you want to test a password reset flow. With a hard-coded Utils.sendMail(), your test code would be forced to make a mock SMTP server, read and parse the email and then click on the password reset link. If you had used DI, you could pass a mock Emailer object. That way, you can write super-fast unit tests, without bothering about external integrations. You can also swap implementations easily. For example, Google App Engine has a custom sendMail API - so it would be difficult for you to support a GAE version of code and a non-GAE version at the same time. (For the sake of argument, just assume migrating to GAE is that easy. Its not, obviously). Finally, your code is more modular. A particular class (ResetPassword) may just depend on Util.sendMail(), but Util could be a kitchen sink with methods to do everything under the sun. So, if you want to reuse ResetPassword in another project, you have to copy the entire Utils class, plus the several dependent jars that Utils needs to work. Its not a good option.

http://stackoverflow.com/comment/2783393
type: AnswerComment
type: Comment
score: 1
comment on: http://stackoverflow.com/a/2752490
has text: Good answer, but it's called a package in Java, not a namespace (although packages are a kind of namespace).

http://stackoverflow.com/comment/2663961
type: Comment
type: QuestionComment
has text: wonder who upvoted this question ? Basically the poster is asking for a shell but since he's probably never worked on anything other than windows, he has no idea such a beast exists. Hence the ridiculous Java/XML starting point.
score: 0
comment on: http://stackoverflow.com/q/2648110

http://stackoverflow.com/a/2720426
answers question: http://stackoverflow.com/q/2719936
downvote count: 1
has body: Don't use a security manager unless (i) you know you need one and (ii) you have written an appropriate .policy file. If you think both these apply, run your problem with -Djava.security.debug=access,failure to see what is really going wrong. Most likely you haven't granted yourself the required permission or you haven't specified the policy file location correctly.
type: Answer
upvote count: 2
score: 1

http://stackoverflow.com/q/2634647
has title: GRAPH: find an algorithm to determine the shortest path from one point to another in a rectangular maze?
has body: I'm getting such an headache trying to elaborate an appropriate algorithm to go from a START position to a EXIT position in a maze. For what is worth, the maze is rectangular, maxsize 500x500 and, in theory, is resolvable by DFS with some branch and bound techniques ... 10 3 4 7 6 3 3 1 2 2 1 0 2 2 2 4 2 2 5 2 2 1 3 0 2 2 2 2 1 3 3 4 2 3 4 4 3 1 1 3 1 2 2 4 2 2 1 Output: 5 1 4 2 Explanation: Our agent looses energy every time he gives a step and he can only move UP, DOWN, LEFT and RIGHT. Also, if the agent arrives with a remaining energy of zero or less, he dies, so we print something like "Impossible". So, in the input 10 is the initial agent's energy, 3 4 is the START position (i.e. column 3, line 4) and we have a maze 7x6. Think this as a kind of labyrinth, in which I want to find the exit that gives the agent a better remaining energy (shortest path). In case there are paths which lead to the same remaining energy, we choose the one which has the small number of steps, of course. I need to know if a DFS to a maze 500x500 in the worst case is feasible with these limitations and how to do it, storing the remaining energy in each step and the number of steps taken so far. The output means the agent arrived with remaining energy= 5 to the exit pos 1 4 in 2 steps. If we look carefully, in this maze it's also possible to exit at pos 3 1 (column 3, row 1) with the same energy but with 3 steps, so we choose the better one. With these in mind, can someone help me some code or pseudo-code? I have troubles working this around with a 2D array and how to store the remaining energy, the path (or number of steps taken).... EDIT: Larry, as I said, I'me a little bit confused about the code. Here's what I've tried so far, only to determine the shortest path with less steps from START to EXIT, fixing EXIT in the meanwhile... public class exitFromMaze { int energy, startY, startX, xMax, yMax; int adjMatrix[][]; boolean visited[][]; ArrayList&lt;Cell&gt; neighbours; //ArrayList&lt;C…
upvote count: 3
tagged with: java
has answer: http://stackoverflow.com/a/2634656
type: Question
tagged with: graph
has answer: http://stackoverflow.com/a/2634667
has comment: http://stackoverflow.com/comment/2660143
score: 3
tagged with: algorithm
has answer: http://stackoverflow.com/a/31231227
answer count: 3
downvote count: 0
favorite count: 0
type: UnansweredQuestion

jaxb
tags question: http://stackoverflow.com/q/2667724
tags question: http://stackoverflow.com/q/2714588
tags question: http://stackoverflow.com/q/2712854
tags question: http://stackoverflow.com/q/2646965
tags question: http://stackoverflow.com/q/2736220
tags question: http://stackoverflow.com/q/2690055
tags question: http://stackoverflow.com/q/2763218
tags question: http://stackoverflow.com/q/2690206
tags question: http://stackoverflow.com/q/2668121
tags question: http://stackoverflow.com/q/2742336
tags question: http://stackoverflow.com/q/2669632
tags question: http://stackoverflow.com/q/2688878
tags question: http://stackoverflow.com/q/2766347
tags question: http://stackoverflow.com/q/2664991
tags question: http://stackoverflow.com/q/2775349
tags question: http://stackoverflow.com/q/2765876
type: Tag
tag name: jaxb
tags question: http://stackoverflow.com/q/2626771
tags question: http://stackoverflow.com/q/2631984
tags question: http://stackoverflow.com/q/2775514
tags question: http://stackoverflow.com/q/2716916
tags question: http://stackoverflow.com/q/2709788
tags question: http://stackoverflow.com/q/2603778

http://stackoverflow.com/comment/2697620
score: 0
type: QuestionComment
type: Comment
has text: i checked the script, but it doesn't seem to have errors. In fact, it hasn't been changed, and the build still sparkling succeed.
comment on: http://stackoverflow.com/q/2677831

http://stackoverflow.com/comment/2640323
type: Comment
score: 0
type: AnswerComment
has text: This was what I was thinking. Keep it simple, or use RMI and later take advantage of its other features. I'm still not sure, but I just wanted to make sure there were no other frameworks / API's I was unaware of. Cheers.
comment on: http://stackoverflow.com/a/2620726

http://stackoverflow.com/a/2679381
has comment: http://stackoverflow.com/comment/2700194
has body: You can catch anything under Throwable, generally speaking you should only catch subclasses of Exception excluding RuntimeException (though a large portion of developers also catch RuntimeException... but that was never the intent of the language designers). If you were to catch OutOfMemoryError what on earth would you do? The VM is out of memory, basically all you can do is exit. You probably cannot even open a dialog box to tell them you are out of memory since that would take memory :-) The VM throws an OutOfMemoryError when it is truly out of memory (indeed all Errors should indicate unrecoverable situations) and there should really be nothing you can do to deal with it. The things to do are find out why you are running out of memory (use a profiler, like the one in NetBeans) and make sure you don't have memory leaks. If you don't have memory leaks then increase the memory that you allocate to the VM.
score: -1
upvote count: 2
downvote count: 3
has comment: http://stackoverflow.com/comment/3064582
answers question: http://stackoverflow.com/q/2679330
type: Answer
has comment: http://stackoverflow.com/comment/2700612

http://stackoverflow.com/a/2633671
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/2633249
upvote count: 1
type: Answer
has body: will getOwnedWindows() do? It belongs to java.awt.Window which in JDialog's parent lineage.

http://stackoverflow.com/comment/139287174
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/64136129
has text: Really saved my day! Thank you!
score: 0

http://stackoverflow.com/a/2686246
has body: You need to reference ${test.java.bin.dir} in your junit task classpath. Edit: Hmm, if by "still failing" you mean with the same error, then my next guess is that something must be messed up about where the root directory is relative to where the packages start, but I need to know more about your directory structure to be sure.
has comment: http://stackoverflow.com/comment/2707491
has comment: http://stackoverflow.com/comment/2707621
score: 0
has comment: http://stackoverflow.com/comment/2706681
answers question: http://stackoverflow.com/q/2686226
type: Answer

http://stackoverflow.com/q/2639636
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/2654137
upvote count: 1
type: Question
has title: Hudson's FindBugs plugin reports line number "-1" for bugs. Ideas?
tagged with: findbugs
possible better answer: http://stackoverflow.com/a/2640866
answer count: 2
has answer: http://stackoverflow.com/a/2640866
downvote count: 0
tagged with: hudson
has answer: http://stackoverflow.com/a/2639829
favorite count: 0
type: AnsweredQuestion
has body: Greetings, I have a simple test project set up in Hudson and the project's build process (a batch file) generates a findbugs.xml file. This is processed by Hudson's FindBugs plugin but it shows the line number of the bugs as "-1" instead of their actual line number. A coworker suggested I enable debug info for the compiler. I used the -g "Generate all debugging info" option for javac but nothing seemed to change. My build command is: javac -g -classpath C:\testWebApp1\src -d C:\testWebApp1\build C:\testWebApp1\src\*.java The only other thing in the build.bat file is a call to the FindBug tool (text UI). Here is what the FindBugs Plugin says about the first bug: File: GenerateHellos.java, Line: -1, Type: UUF_UNUSED_FIELD, Priority: Normal, Category: PERFORMANCE Any ideas? Thanks a ton!
accepted answer: http://stackoverflow.com/a/2639829

http://stackoverflow.com/q/2666817
tagged with: tomcat
favorite count: 0
possible better answer: http://stackoverflow.com/a/2667400
has comment: http://stackoverflow.com/comment/2684716
has answer: http://stackoverflow.com/a/2667400
linked to: http://stackoverflow.com/q/14191751
has answer: http://stackoverflow.com/a/3343397
answer count: 4
has title: Automatic login after registration
tagged with: authentication
upvote count: 1
has body: I have a webapp with form-based authentication. On the login page, I have placed a link to a public registration form. The registration adds a user in the database that is used for authentication. Now, is is possible to do an automatic login as the new user after the registration is complete, without returning to the login page? UPDATE More info, as requested: DataSource in $CATALINA_BASE/conf/server.xml: ... &lt;GlobalNamingResources&gt; ... &lt;Resource auth="Container" type="javax.sql.DataSource" name="jdbc/gporder" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/gporder" maxActive="100" maxIdle="30" maxWait="10000" username="xxx" password="yyy"/&gt; ... &lt;/GlobalNamingResources&gt; ... Resource links and realm in $MYWAR/META-INF/context.xml: &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;Context path="/gporder"&gt; &lt;ResourceLink global="jdbc/gporder" name="jdbc/gporder" type="javax.sql.DataSource"/&gt; &lt;Realm className="org.apache.catalina.realm.DataSourceRealm" dataSourceName="jdbc/gporder" debug="99" localDataSource="true" digest="MD5" roleNameCol="role" userCredCol="password_hash" userNameCol="username" userRoleTable="rolemap" userTable="users"/&gt; &lt;/Context&gt; What else? there is a JSP with the HTML registration form, and a servlet that handles the POST when the form is submitted. They are both too long to be pasted here, but the servlet builds a new user and save it in the database (via hibernate). After that, a redirect is done on an initial page, which causes tomcat to redirect to the login page instead. So my question is: is there a way to use the username and password entered in the registration form to force a login, and avoid further redirects on the login page? I would like to avoid relying on tomcat's internal classes.
tagged with: registration
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/3594114
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/51048702
accepted answer: http://stackoverflow.com/a/3594114
type: Question
downvote count: 0

http://stackoverflow.com/comment/2646478
comment on: http://stackoverflow.com/a/2632900
type: AnswerComment
score: 0
has text: Just tried the above code, if you ammend the re.getRecord(id) and do recordStoreName.getRecord(id) then it works a treat :) thanks (edit your code and i'll tick your answer) thanks
type: Comment

http://stackoverflow.com/comment/2658057
type: Comment
score: 2
type: AnswerComment
has text: The nice thing about overprinting one line instead of clearing the whole screen is (a) you don't lose the rest of the screen's content and (b) it doesn't flicker when it redraws (okay, that one is pretty obsessive...)
comment on: http://stackoverflow.com/a/2643102

http://stackoverflow.com/q/2658072
linked to: http://stackoverflow.com/q/5558502
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2658183
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/2675068
has comment: http://stackoverflow.com/comment/35995554
has title: Regular Expression to fetch the result between two tags in Java
favorite count: 0
linked to: http://stackoverflow.com/q/1732348
type: Question
tagged with: http://stackoverflow.com/tag/html
tagged with: regex
has comment: http://stackoverflow.com/comment/2675041
accepted answer: http://stackoverflow.com/a/2658183
answer count: 2
upvote count: 1
has body: I have an HTML page and I want to fetch the result between two tags and : Defendants Name:Donahue, Leah A What is the regular expression to fetch the words between these two tags?
possible better answer: http://stackoverflow.com/a/2675593
tagged with: java
has answer: http://stackoverflow.com/a/2675593
has comment: http://stackoverflow.com/comment/35995553

http://stackoverflow.com/comment/2660697
has text: I will print data form my application, to paper.
type: Comment
comment on: http://stackoverflow.com/a/2645476
score: 0
type: AnswerComment

http://stackoverflow.com/comment/9198072
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2741103
score: 4
has text: Just a note: I wrote some [JavaDoc for JSch](http://epaul.github.com/jsch-documentation/simple.javadoc/).

http://stackoverflow.com/a/2676710
type: AcceptedAnswer
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2676672
accepted answer of: http://stackoverflow.com/q/2676672
score: 3
has body: That's not to be decided by the Java program, but by the operating system and the enduser. The enduser has just to configure the operating system so that it get executed during startup or as a scheduled task. You just have to make sure that your program doesn't spawn any UI or so.
upvote count: 3

http://stackoverflow.com/a/17406940
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2660961
score: 14
upvote count: 14
has body: What works for me : Close Eclipse. Go to your bin folder and delete all the contents (not the folder itself). Start Eclipse. Clean your project by going to Project -&gt; Clean. Make sure you check Project -&gt; Build automatically.

http://stackoverflow.com/q/2686226
tagged with: ant
tagged with: java
possible better answer: http://stackoverflow.com/a/2687047
type: Question
upvote count: 4
has comment: http://stackoverflow.com/comment/2714977
accepted answer: http://stackoverflow.com/a/6167849
tagged with: junit
downvote count: 0
score: 4
favorite count: 0
answer count: 3
has comment: http://stackoverflow.com/comment/2708698
has answer: http://stackoverflow.com/a/6167849
has comment: http://stackoverflow.com/comment/2708429
has answer: http://stackoverflow.com/a/2686246
has answer: http://stackoverflow.com/a/2687047
type: AnsweredQuestion
has title: Ant + JUnit = ClassNotFoundExceptions when running tests?
has body: I'm trying to run some tests in Ant presently using JUnit, and all of my tests are failing with the following stacktrace: java.lang.ClassNotFoundException: com.mypackage.MyTestCase It doesn't make too much sense to me. I'm first compiling my test cases using , then directly running the task to run the tests. My buildfile looks like this: <file name="${red5.home}/red5.jar"/> <file name="${red5.home}/boot.jar"/> <file name="${bin.dir}/${ant.project.name}.jar"/> <fileset dir="${red5.lib.dir}" includes="**/*"/> <fileset dir="${main.java.lib.dir}" includes="**/*"/> <fileset dir="${test.java.lib.dir}" includes="**/*"/> <file name="${red5.home}/red5.jar"/> <file name="${red5.home}/boot.jar"/> <file name="${bin.dir}/${ant.project.name}.jar"/> <fileset dir="${red5.lib.dir}" includes="**/*.jar"/> <fileset dir="${main.java.lib.dir}" includes="**/*.jar"/> <fileset dir="${test.java.lib.dir}" includes="**/*.jar"/> <fileset dir="${test.java.bin.dir}" includes="**/*.class"/> <formatter type="xml"/> <fileset dir="${test.java.bin.dir}" includes="**/*TestCase*"/> <fileset dir="${test.java.output.dir}" includes="**/*"/> <report todir="${test.java.report.dir}"/> This is really weird, I can't seem to fix this. Is there something I'm doing wrong here? My project's directory layout looks somewhat like this: ${basedir}/src/test/java # this is "test.java.src.dir" ${basedir}/build/test/java # this is "test.java.bin.dir" ${basedir}/lib/main/java # this is "main.java.lib.dir" ${basedir}/lib/test/java # this is "test.java.lib.dir" ${basedir}/build/test/junit # this is "test.java.output.dir" My complete buildfile is available here: http://pastebin.com/SVnciGKR My properties file is available here: http://pastebin.com/9LCtNQUq UPDATE By modifying my targets to look like below, I was able to get things working. Unfortunately, I have to manually embed ant-junit.jar and junit.jar into my repository, but it works, so I guess this solves it. If anyone can help me get rid of the need to embed ant-junit.…

http://stackoverflow.com/comment/2795527
type: Comment
comment on: http://stackoverflow.com/a/2763140
score: 0
type: AnswerComment
has text: @mousey: see my solution using `String`.

http://stackoverflow.com/comment/2687395
type: Comment
comment on: http://stackoverflow.com/a/2668793
has text: Changing to int reduced it from 8+change to 2+change seconds. However I didn't know at the time that I would only need an int. I am seeing if my original solution can make one static creation of "2" to save any time. Still looking for other answers to optimize the program (not fancy math equations)
score: 0
type: AnswerComment

http://stackoverflow.com/a/2715778
has body: The file management in my archos says it's /storage/Music/
type: Answer
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/2741733
accepted answer of: http://stackoverflow.com/q/2715694
answers question: http://stackoverflow.com/q/2715694
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/2723768
score: 0
comment on: http://stackoverflow.com/a/2700778
type: Comment
has text: it's a NullPointerException in disguise :)
type: AnswerComment

http://stackoverflow.com/a/2763109
type: Answer
score: 6
upvote count: 6
answers question: http://stackoverflow.com/q/2763091
downvote count: 0
has body: Antlr has a grammar file for Java. See this.

http://stackoverflow.com/a/2676103
answers question: http://stackoverflow.com/q/2676078
score: 0
type: Answer
has body: From most any logging framework's perspective, the name you put in the getLogger method is what makes the logger unique, not the class instance. So when you call Logger.getLogger("TestLog"); you get the same logger in each case.

http://stackoverflow.com/a/2726439
has body: A discussion is going on in the #clojure channel on Freenode just now on this very topic. Chris Houser (who was going to post an answer, but ultimately decided he was too busy to do it) has posted a Gist which demonstrates what happens with a boolean vs. Object overloaded method; it turns out that in some scenarios, in addition to a (boolean ...) cast, a type hint is required. The discussion was quite enlightening, with a few dark corners of Clojure compilation process becoming nicely illuminated. (See links to IRC log below.) Basically, if an object is created right in the method-calling form -- (.foo (Foo.) ...), say -- that type hint is not necessary; it is likewise not necessary if the object has been constructed as a value for a local in an enclosing let form (see update 2 below and my version of the Gist). If the object is obtained by Var lookup, though, a type hint is required -- which can be provided either on the Var itself or, at the call site, on the symbol used to refer to the Var. The Java code from the Gist: package mypkg; public class Ugly { public Ugly(){} public String foo(boolean i) { return "bool: " + i; } public String foo(Object o) { return "obj: " + o; } } And the Clojure code: (.foo (mypkg.Ugly.) 5) ;=&gt; "obj: 5" (.foo (mypkg.Ugly.) true) ;=&gt; "obj: true" (.foo (mypkg.Ugly.) (boolean true)) ;=&gt; "bool: true" (def u (mypkg.Ugly.)) (.foo u (boolean true)) ;=&gt; "obj: true" (.foo #^mypkg.Ugly u (boolean true)) ;=&gt; "bool: true" Note how the Clojure compiler needs a type hint on u to be able to compile a direct method call. Otherwise reflection-based code seems to be generated, which apparently loses track of the fact that the argument is meant to be a primitive along the way. My additions follow (and here's my fork of the above Gist). ;; renamed mypkg.Ugly to foo.TestInterop2 when doing my tests user&gt; (let [t (foo.TestInterop2.)] (.foo t (boolean true))) "bool: true" ;;; type-hinting the Var user&gt; (def #^foo.TestInterop2 x (foo.Tes…
downvote count: 0
has comment: http://stackoverflow.com/comment/61654418
type: Answer
accepted answer of: http://stackoverflow.com/q/2722856
has comment: http://stackoverflow.com/comment/2757128
answers question: http://stackoverflow.com/q/2722856
has comment: http://stackoverflow.com/comment/61656384
has comment: http://stackoverflow.com/comment/2756963
upvote count: 15
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/61656074
score: 15

http://stackoverflow.com/q/2719549
tagged with: java
upvote count: 1
has body: I have the following code in a listener method: FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("time", new Date()); When a button is clicked the following code is executed System.out.println(FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("time")); One could except that "time" is null when the listener was not executed while processing the current request, but: it seems like the "time" object survives the request processing. So when "time" has been set sometimes in the past it stays there... can anybody explain this? Thanks.
type: Question
has title: Request attributes in jsf / icefaces behaves strange (survive request end)
downvote count: 0
answer count: 1
favorite count: 0
tagged with: icefaces
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2719807
tagged with: jsf
score: 1

http://stackoverflow.com/a/2636252
accepted answer of: http://stackoverflow.com/q/2635945
has comment: http://stackoverflow.com/comment/2651136
answers question: http://stackoverflow.com/q/2635945
downvote count: 1
has comment: http://stackoverflow.com/comment/2651930
has comment: http://stackoverflow.com/comment/2651064
has comment: http://stackoverflow.com/comment/2650316
upvote count: 4
score: 3
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2651001
has body: You can use the PhoneStateLisenter to listen out for changes in the call state. So you listen for the LISTEN_CALL_STATE change. With the onCallStateChanged method. So when the state changes from RINGING to OFFHOOK you know a phone call has been connected Same principle applies for IDLE to OFFHOOK in your situation, listen out to the change from IDLE to OFFHOOK and you'll know your connected to a call. You can also look into the ACTION_NEW_OUTGOING_CALL intent, Android allows you to "trap" this when a call is dialled and you may be able to get a result code back stating whether the call was connected or not. For DTMF tones look into ToneGenerator, this allows you to create DTMF tones and .startTone() should allow you to play the DTMF tone then. However you cant send DTMF tones through the uplink.
has comment: http://stackoverflow.com/comment/2650397
has comment: http://stackoverflow.com/comment/2651688
has comment: http://stackoverflow.com/comment/2652023
type: Answer

http://stackoverflow.com/comment/2811650
type: AnswerComment
has text: i basically had to redo all the work to find exactly which dependencies were giving me issues. the greader api uses jaxen (org.jaxen.*) which depends on dom4j (org.dom4j.*) which depends on some classes in java.beans that aren't in the Android SDK, so the offending packages are jaxen and dom4j for depending on pieces of the JDK that aren't available in Android. either way, i can probably work around with it. i'll keep tooling around. thanks for the advice.
comment on: http://stackoverflow.com/a/2762039
score: 0
type: Comment

http://stackoverflow.com/a/2763472
has comment: http://stackoverflow.com/comment/2795755
type: Answer
answers question: http://stackoverflow.com/q/2763454
has body: As it says, enable connection validation on the connection pool.
score: 0

http://stackoverflow.com/comment/2715721
comment on: http://stackoverflow.com/a/2687585
type: AnswerComment
score: 0
type: Comment
has text: @Ravi: the key thing here, as you seem to have noticed already, is not to send on the same thread that you receive on. Have one thread for receiving packets and then have as many threads as you find necessary for sending packets. This sort of interaction is demonstrated in my server example where the socket connection blocks on accept. The thread that handles the accepted packet can also be used to send/broadcast something (which it usually does)... I hope that makes sense :).

http://stackoverflow.com/a/2749719
has comment: http://stackoverflow.com/comment/50808446
answers question: http://stackoverflow.com/q/2749689
type: Answer
upvote count: 166
has comment: http://stackoverflow.com/comment/50808454
score: 158
downvote count: 8
has comment: http://stackoverflow.com/comment/113863706
has comment: http://stackoverflow.com/comment/31706488
has comment: http://stackoverflow.com/comment/46547628
has body: You can imagine that the owning side is the entity that has the reference to the other one. In your excerpt, you have an one-to-one relationship. Since it's a symmetric relation, you'll end up having that if object A is in relation with object B then also the vice-versa is true. This means that saving into object A a reference to object B and saving in object B a reference to object A will be redundant: that's why you choose which object "owns" the other having the reference to it. When you have got an one-to-many relationship, the objects related to the "many" part will be the owning side, otherwise you would have to store many references from a single object to a multitude. To avoid that, every object in the second class will have a pointer to the single one they refer to (so they are the owning side). For a many-to-many relationship, since you will need a separate mapping table anyway there won't be any owning side. In conclusion the owning side is the entity that has the reference to the other.

http://stackoverflow.com/a/2717431
score: 80
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2743197
upvote count: 80
answers question: http://stackoverflow.com/q/2717421
has comment: http://stackoverflow.com/comment/2743224
has comment: http://stackoverflow.com/comment/111740714
has comment: http://stackoverflow.com/comment/42914673
accepted answer of: http://stackoverflow.com/q/2717421
type: Answer
downvote count: 0
has body: phoneNumber.replaceAll("[\\s\\-()]", ""); The regular expression defines a character class consisting of any whitespace character (\s, which is escaped as \\s because we're passing in a String), a dash (escaped because a dash means something special in the context of character classes), and parentheses. See String.replaceAll(String, String). EDIT Per gunslinger47: phoneNumber.replaceAll("\\D", ""); Replaces any non-digit with an empty string.

recursion
type: Tag
tags question: http://stackoverflow.com/q/2666717
tags question: http://stackoverflow.com/q/2611573
tags question: http://stackoverflow.com/q/2712313
tags question: http://stackoverflow.com/q/2777446
tag name: recursion
tags question: http://stackoverflow.com/q/2707377
tags question: http://stackoverflow.com/q/2641262
tags question: http://stackoverflow.com/q/2717111
tags question: http://stackoverflow.com/q/2693552
tags question: http://stackoverflow.com/q/2649375
tags question: http://stackoverflow.com/q/2623432
tags question: http://stackoverflow.com/q/2689987
tags question: http://stackoverflow.com/q/2635292
tags question: http://stackoverflow.com/q/2623091
tags question: http://stackoverflow.com/q/2656873

http://stackoverflow.com/a/2728155
answers question: http://stackoverflow.com/q/2728139
score: 0
type: Answer
has body: We use Checkstyle at my company, only for javadoc checks though. It is nice in the way that you can configure different modules to include stuff to check for, and also on what levels (as in protected, public, private etc). A heads-up is that for javadoc-checking you need to explicitly state if a method is allowed to throw several exceptions. This is so because the creators think that it is bad design to have a method throw more than one exception (they are in other words trying to control design, not related IMHO).

http://stackoverflow.com/q/2690206
favorite count: 0
upvote count: 9
has title: JAXB does not call setter when unmarshalling objects
has answer: http://stackoverflow.com/a/2690329
accepted answer: http://stackoverflow.com/a/2690329
has body: I am using JAXB 2.0 JDK 6 in order to unmarshall an XML instance into POJOs. In order to add some custom validation I have inserted a validation call into the setter of a property, yet despite it being private, it seems that the unmarshaller does not call the setter but directly modifies the private field. It is crucial to me that the custom validation occurs for this specific field every unmarshall call. What should I do? Code: @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "LegalParams", propOrder = { "value" }) public class LegalParams { private static final Logger LOG = Logger.getLogger(LegalParams.class); @XmlTransient private LegalParamsValidator legalParamValidator; public LegalParams() { try { WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext(); LegalParamsFactory legalParamsFactory = (LegalParamsFactory) webApplicationContext.getBean("legalParamsFactory"); HttpSession httpSession = SessionHolder.getInstance().get(); legalParamValidator = legalParamsFactory.newLegalParamsValidator(httpSession); } catch (LegalParamsException lpe) { LOG.warn("Validator related error occurred while attempting to construct a new instance of LegalParams"); throw new IllegalStateException("LegalParams creation failure", lpe); } catch (Exception e) { LOG.warn("Spring related error occurred while attempting to construct a new instance of LegalParams"); throw new IllegalStateException("LegalParams creation failure", e); } } @XmlValue private String value; /** * Gets the value of the value property. * * @return * possible object is * {@link String } * */ public String getValue() { return value; } /** * Sets the value of the value property. * * @param value * allowed object is * {@link String } * @throws TestCaseValidationException * */ public void setValue(String value) throws TestCaseValidationException { legalParamValidator.assertValid(value); this.value = value; } }
tagged with: customvalidator
type: AnsweredQuestion
downvote count: 0
tagged with: java
tagged with: jaxb
type: Question
score: 9
tagged with: setter
answer count: 1

http://stackoverflow.com/comment/2794879
type: Comment
comment on: http://stackoverflow.com/a/2667990
type: AnswerComment
has text: I indeed had a code problem in java, your post helped me to pinpoint it. thx a lot!
score: 0

http://stackoverflow.com/q/2629357
has comment: http://stackoverflow.com/comment/2643356
has answer: http://stackoverflow.com/a/2629371
has comment: http://stackoverflow.com/comment/54761982
score: 61
has answer: http://stackoverflow.com/a/2629542
has answer: http://stackoverflow.com/a/38942190
answer count: 12
has answer: http://stackoverflow.com/a/2629545
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/134004267
downvote count: 1
has comment: http://stackoverflow.com/comment/2642875
has body: If Java does not have pointers, then what does the the new keyword do in Java?
has comment: http://stackoverflow.com/comment/2646390
has title: Does Java have pointers?
has comment: http://stackoverflow.com/comment/2646380
tagged with: java
has comment: http://stackoverflow.com/comment/2649884
upvote count: 62
has answer: http://stackoverflow.com/a/17092543
type: Question
has answer: http://stackoverflow.com/a/2629377
has answer: http://stackoverflow.com/a/2629758
has answer: http://stackoverflow.com/a/36809071
tagged with: pointers
has answer: http://stackoverflow.com/a/2629393
has answer: http://stackoverflow.com/a/2629374
favorite count: 0
has answer: http://stackoverflow.com/a/2629375
has answer: http://stackoverflow.com/a/2629444

http://stackoverflow.com/comment/2821770
type: AnswerComment
comment on: http://stackoverflow.com/a/2786075
score: 0
type: Comment
has text: @javaLearner.java - but carriage return is somewhat of a specialized thing - and I don't recall a single question about it in about a year I was on SO; and this week I saw two... Just to be clear, my comment was amazement at the coincidence, not objection to your question :)

http://stackoverflow.com/a/2770275
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/65101460
score: 62
type: Answer
has body: The first allows process of a List&lt;Integer&gt;, a List&lt;Double&gt;, etc. The second doesn't. Generics in Java are invariant. They're not covariant like arrays. That is, in Java, Double[] is a subtype of Number[], but a List&lt;Double&gt; is NOT a subtype of List&lt;Number&gt;. A List&lt;Double&gt;, however, is a List&lt;? extends Number&gt;. There are good reasons for generics being invariant, but that's also why the extends and super type are often necessary for subtyping flexibility. See also Java Tutorials/Generics/Subtyping Explains why generics invariance is a good thing More fun with wildcards Explains some uses of super and extends for bounded wildcards Java Generics: What is PECS? This discusses the "Producer extends Consumer super" principle Effective Java 2nd Edition, Item 28: Use bounded wildcards to increase API flexibility
accepted answer of: http://stackoverflow.com/q/2770264
answers question: http://stackoverflow.com/q/2770264
upvote count: 62

http://stackoverflow.com/a/2714493
downvote count: 0
answers question: http://stackoverflow.com/q/2714353
type: Answer
has body: I guess you have to add the underscore as "letter" here // Find where the word starts int w; for (w = pos; w &gt;= 0; w--) { if (!Character.isLetter(content.charAt(w))) { break; } }
score: 1
upvote count: 1

http://stackoverflow.com/a/2686428
type: AcceptedAnswer
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2685907
score: 2
upvote count: 2
has body: The files may reside on a web server. There is no standard way of listing files (pages) on a web server. So, in general, what you need to do is remember which locales you have resources for (perhaps create a list as part of your build process).
accepted answer of: http://stackoverflow.com/q/2685907

http://stackoverflow.com/comment/38849696
has text: are you sure you need the factory-method attribute? i'm pretty sure Spring knows how to get an instance even if the constructor is private (probably tries calling getInstance)
comment on: http://stackoverflow.com/a/11122919
type: AnswerComment
type: Comment
score: 1

http://stackoverflow.com/comment/39979329
comment on: http://stackoverflow.com/a/16883281
type: Comment
score: 0
has text: Cool, thanks for solution, but In case of DEFAULT it is not working. I even tried setting typeface="normal" but no luck
type: AnswerComment

http://stackoverflow.com/a/45395937
has body: 2017 update: Kryo is used by Flink. So practically anything that is using Flink framework is relying on Kryo. Reference: https://ci.apache.org/projects/flink/flink-docs-release-0.8/programming_guide.html#specifying-keys
type: Answer
answers question: http://stackoverflow.com/q/2725233
downvote count: 0
score: 1
upvote count: 1

http://stackoverflow.com/q/2698002
has answer: http://stackoverflow.com/a/10103106
downvote count: 0
tagged with: java
score: 34
tagged with: resources
type: Question
has answer: http://stackoverflow.com/a/2698287
answer count: 8
has answer: http://stackoverflow.com/a/2698343
has answer: http://stackoverflow.com/a/14314487
upvote count: 34
has answer: http://stackoverflow.com/a/2698030
tagged with: eclipse
has answer: http://stackoverflow.com/a/25529684
has answer: http://stackoverflow.com/a/2698461
has body: How can I get the relative path of the folders in my project using code? I've created a new folder in my project and I want its relative path so no matter where the app is, the path will be correct. I'm trying to do it in my class which extends android.app.Activity. Perhaps something similar to "get file path from asset".
favorite count: 0
has title: How can I get relative path of the folders in my android project?
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/25164408
tagged with: android

http://stackoverflow.com/a/2704325
score: 0
has body: Sounds like "something" has changed between those JRE versions. They have either fixed a bug or introduced a new one. I don't think there's more magic than that. If you are very interested in knowing what exactly has changed, you can check out this link: http://java.sun.com/javase/6/webnotes/ReleaseNotes.html
type: Answer
answers question: http://stackoverflow.com/q/2702333

http://stackoverflow.com/a/2740247
answers question: http://stackoverflow.com/q/2730777
score: 0
type: Answer
has body: I find the issue : In my Library domain, I just add a mapping with "books lazy: false" : class Library { static hasMany = [ books : Book ] String name String adresse Date dateMaturity static constraints = { } static mapping = { books lazy: false } String toString() { return name } } And now, I have my report witout troubles ! The grails jasper plugin use chain to chains the model from one action to the next (chain(controller:'jasper',action:'index',model:[data:library],params:params). After, in jasper controller we get the model by this line : def testModel = this.getProperties().containsKey('chainModel')?chainModel:null For some reason, in Library collection, we have an error on books list, eg : org.hibernate.LazyInitializationException: failed to lazily initialize a collection - no session or session was closed By using "lazy: false", we pull all other instances of the domain class. Is there another way to fix this issue ?

http://stackoverflow.com/comment/2636344
type: Comment
comment on: http://stackoverflow.com/a/2623720
type: AnswerComment
score: 0
has text: Yes I did. But I already build an ESB in ruby (but of course that is very slooooow ;) ) So i am rebuilding the whole thing in java. But al the "features" these open-source solutions provide are just to much for a simple content management system. In my opinion the only thing an esb should do is 1) know where servers are located 2) transform to the appropriate adapter

http://stackoverflow.com/comment/2807651
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2773826
has text: I'm not sure what's the question...how to store those queries?
score: 0

http://stackoverflow.com/a/2733552
score: 8
downvote count: 0
answers question: http://stackoverflow.com/q/2733479
upvote count: 8
has body: Those two reasons you just gave are huge. If you have a 3D volume that's 1k by 1k by 64, and then have many timepoints of that data, and then want to make a movie of maximum intensity projections, the fact that float is half the size of double could be the difference between finishing quickly and thrashing because you ran out of memory. Atomicity is also huge, from a threading standpoint. There's always going to be a tradeoff between speed/performance and accuracy. If you have a number that's smaller than 2^31 and an integer, then an integer is always a better representation of that number than a float, just because of the precision loss. You'll have to evaluate your needs and use the appropriate types for your problems.
type: Answer

http://stackoverflow.com/comment/2728226
type: Comment
has text: This way I can get only folders that are in the package. I need to get a relative path to a folder that I created inside the project (not inside the package). Folder like assets. Can you give me the function that can do it?
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2698343

http://stackoverflow.com/comment/2746287
type: AnswerComment
type: Comment
has text: There's no exam, just a project, and there's no time to do code it by hand.
comment on: http://stackoverflow.com/a/2719170
score: 1

http://stackoverflow.com/comment/122968683
has text: Thanks for editing my brother
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/69554758

http://stackoverflow.com/q/2687911
downvote count: 0
favorite count: 0
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/703737
has title: ArrayList throwing exception on retrieval from google datastore (with gwt, java)
upvote count: 3
has body: I'm using Google Web Toolkit with java and google datastore as database. The entity class has arraylist and on trying to retrieve the data from data base I'm getting the exception: Type 'org.datanucleus.sco.backed.ArrayList' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized. I'm using JPA. Entity code: package com.ver2.DY.client; import java.io.Serializable; import java.util.ArrayList; import javax.jdo.annotations.IdGeneratorStrategy; import javax.jdo.annotations.PersistenceCapable; import javax.jdo.annotations.Persistent; import javax.jdo.annotations.PrimaryKey; import com.google.gwt.user.client.rpc.IsSerializable; @PersistenceCapable public class ChatInfo implements Serializable, IsSerializable{ @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Long topicId; @Persistent private String chatTopic; @Persistent private ArrayList&lt;String&gt; messages = new ArrayList&lt;String&gt;(); @Persistent private boolean isFirstPost; public ChatInfo() { } public Long getTopicId() { return topicId; } public void setTopicId(Long topicId) { this.topicId = topicId; } public String getChatTopic() { return chatTopic; } public void setChatTopic(String chatTopic) { this.chatTopic = chatTopic; } public ArrayList&lt;String&gt; getMessages() { return messages; } public void addMessage(String newMsg) { messages.add(newMsg); } public boolean isFirstPost() { return isFirstPost; } public void setFirstPost(boolean isFirstPost) { this.isFirstPost = isFirstPost; } } Method in db class: @Transactional public ChatInfo[] getAllChat() { PersistenceManager pm = PMF.get().getPersistenceManager(); List&lt;ChatInfo&gt; chats = null; ChatInfo[] infos = null; String query = "select from " + ChatInfo.class.getName(); try{ chats = (List&lt;ChatInfo&gt;) pm.newQuery(query).execute(); infos = new ChatInfo[chats.size()]; for(int i=0;i&lt;chats.size(…
has answer: http://stackoverflow.com/a/6340496
has answer: http://stackoverflow.com/a/3508114
type: Question
tagged with: gwt
score: 3
tagged with: java
has comment: http://stackoverflow.com/comment/3666626
answer count: 2
tagged with: google-cloud-datastore

http://stackoverflow.com/a/13642129
answers question: http://stackoverflow.com/q/2643822
downvote count: 0
score: 9
type: Answer
has body: You can create a word template (just use the Save as... feature in Word). first option The template now contains a number of additional XML files in \word folder: - styles.xml - stylesWithEffects.xml - webSettings.xml - fontTable.xml and a - \theme folder If you copy those files into your original POI generated file then you can reference styles given in the styles.xml file. You can manipulate your original file like a ZIP file, this shouldn't be to much effort. second option Copy styles in code from template to your document: XWPFDocument template = new XWPFDocument(new FileInputStream(new File("Template.dotx"))); XWPFDocument doc = new XWPFDocument(); // let's copy styles from template to new doc XWPFStyles newStyles = doc.createStyles(); newStyles.setStyles(template.getStyle()); XWPFParagraph para = doc.createParagraph(); para.setStyle("Heading1"); XWPFRun run = para.createRun(); run.setText("Heading 1"); return doc; On the plus side you can manipulate your styles separately directly using Word and saving them back to the template file.
upvote count: 9

http://stackoverflow.com/q/2601233
score: 1
tagged with: jvm
favorite count: 0
has title: Java 1.4 Class performance on 1.5 JVM
has body: Switching from JVM 1.4 to 1.5 has performance benefits as per release notes. http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html#performance We have Java 1.4 compiled classes which are run on 1.5 JVM, will these classes suffer in performance because they were compiled using 1.4 ?
linked to: http://stackoverflow.com/q/93049
has comment: http://stackoverflow.com/comment/22225475
has answer: http://stackoverflow.com/a/2675374
has answer: http://stackoverflow.com/a/2601359
upvote count: 1
type: Question
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2675374
tagged with: java
accepted answer: http://stackoverflow.com/a/2601359
answer count: 2
downvote count: 0

http://stackoverflow.com/q/2637515
favorite count: 0
accepted answer: http://stackoverflow.com/a/2638043
tagged with: batch-file
tagged with: scripting
linked to: http://stackoverflow.com/q/298292
possible better answer: http://stackoverflow.com/a/2637532
tagged with: properties
has comment: http://stackoverflow.com/comment/2651671
score: 2
type: AnsweredQuestion
upvote count: 2
type: Question
has answer: http://stackoverflow.com/a/2638043
has body: I'm trying to write a batch script, this script is responsible to launch a jar with one parameters. This parameter indicate to my jar wich property file to use in order to setup some configuration. Then the script will zip the results produced by the jar and send them to a location. But in order to set the name of the zip file I would need to be able to read the property file directly from the batch, is there a way to do so ? Thanks and regards, F
tagged with: java
has title: Accessing property file through batch script
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/2637532

http://stackoverflow.com/a/2726872
downvote count: 0
answers question: http://stackoverflow.com/q/2725495
score: 3
accepted answer of: http://stackoverflow.com/q/2725495
type: AcceptedAnswer
upvote count: 3
type: Answer
has body: JAX-WS. CXF is a good implementation. JAX-WS RI as well. These don't require an application server to run. Both can be run on tomcat (RI example)

http://stackoverflow.com/a/2735277
answers question: http://stackoverflow.com/q/2734119
score: 1
upvote count: 1
has body: Forget about it. If you're dealing with printing or files this kind of micro-optimizaton would save you practically nothing.
downvote count: 0
type: Answer

http://stackoverflow.com/a/37428786
type: Answer
answers question: http://stackoverflow.com/q/2601978
score: 1
upvote count: 1
downvote count: 0
has body: In Android you can check this with utility method isEmpty from TextUtils, public static boolean isEmpty(CharSequence str) { return str == null || str.length() == 0; } isEmpty(CharSequence str) method check both condition, for null and length.

http://stackoverflow.com/q/2597693
tagged with: whiteboard
has body: I have to develop a whiteboard application in which both the local user and the remote user should be able to draw simultaneously, is this possible? If possible then any logic? I have already developed a code but in which i am not able to do this, when the remote user starts drawing the shape which i am drawing is being replaced by his shape and co-ordinates. This problem is only when both draw simultaneously. any idea guys? Here is my code class Paper extends JPanel implements MouseListener,MouseMotionListener,ActionListener { static BufferedImage image; int bpressed; Color color; Point start; Point end; Point mp; Button elipse=new Button("elipse"); Button rectangle=new Button("rect"); Button line=new Button("line"); Button empty=new Button(""); JButton save=new JButton("Save"); JButton erase=new JButton("Erase"); String selected; int ex,ey;//eraser DatagramSocket dataSocket; JButton button = new JButton("test"); Client client; Point p=new Point(); int w,h; public Paper(DatagramSocket dataSocket) { this.dataSocket=dataSocket; client=new Client(dataSocket); System.out.println("paper"); setBackground(Color.white); addMouseListener(this); addMouseMotionListener(this); color = Color.black; setBorder(BorderFactory.createLineBorder(Color.black)); //save.setPreferredSize(new Dimension(100,20)); save.setMaximumSize(new Dimension(75,27)); erase.setMaximumSize(new Dimension(75,27)); } public void paintComponent(Graphics g) { try { g.drawImage(image, 0, 0, this); Graphics2D g2 = (Graphics2D)g; g2.setPaint(Color.black); if(selected==("elipse")) g2.drawOval(start.x, start.y,(end.x-start.x),(end.y-start.y)); else if(selected==("rect")) g2.drawRect(start.x, start.y, (end.x-start.x),(end.y-start.y)); else if(selected==("line")) g2.drawLine(start.x,start.y,end.x,end.y); } catch(Exception e) {} } //Function to draw the shape on image public void draw() { Graphics2D g2 = image.createGraphics(); g2.setPaint(color); if(selected=="line") g2.drawLine(start.x, start.y, end.x, end.y); if(s…
score: 0
has title: Problem with my whiteboard application
possible better answer: http://stackoverflow.com/a/2599758
has answer: http://stackoverflow.com/a/2599758
accepted answer: http://stackoverflow.com/a/2597809
has comment: http://stackoverflow.com/comment/6181290
tagged with: sockets
tagged with: swing
type: AnsweredQuestion
tagged with: java
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/2597809

http://stackoverflow.com/comment/50808446
comment on: http://stackoverflow.com/a/2749719
type: Comment
has text: This answer confuses more than it helps. What good is it to say that "You can imagine that the owning side is the entity that has the reference to the other one" when in bidirectional relationships, both Entity objects will have a reference to each other? Also, "For a many-to-many relationship, since you will need a separate mapping table anyway there won't be any owning side" is just plain incorrect: `@ManyToMany` relationships have owning sides too. Similarly, `@OneToMany` relationships can use join tables, and you still have to specify an owning side.
type: AnswerComment
score: 18

string
tags question: http://stackoverflow.com/q/2642908
tags question: http://stackoverflow.com/q/2673855
tags question: http://stackoverflow.com/q/2735003
tags question: http://stackoverflow.com/q/2644637
tags question: http://stackoverflow.com/q/2748829
tags question: http://stackoverflow.com/q/2612976
tags question: http://stackoverflow.com/q/2770967
tags question: http://stackoverflow.com/q/2721998
tags question: http://stackoverflow.com/q/2769311
tags question: http://stackoverflow.com/q/2704956
tags question: http://stackoverflow.com/q/2781545
tags question: http://stackoverflow.com/q/2638801
tags question: http://stackoverflow.com/q/2674853
tags question: http://stackoverflow.com/q/2653739
tags question: http://stackoverflow.com/q/2705504
tags question: http://stackoverflow.com/q/2683066
tags question: http://stackoverflow.com/q/2712624
tags question: http://stackoverflow.com/q/2608665
tags question: http://stackoverflow.com/q/2734318
tags question: http://stackoverflow.com/q/2740423
tags question: http://stackoverflow.com/q/2768931
tags question: http://stackoverflow.com/q/2750073
tags question: http://stackoverflow.com/q/2601978
tags question: http://stackoverflow.com/q/2755945
tag name: string
tags question: http://stackoverflow.com/q/2778381
tags question: http://stackoverflow.com/q/2709253
tags question: http://stackoverflow.com/q/2745796
tags question: http://stackoverflow.com/q/2683466
tags question: http://stackoverflow.com/q/2713655
tags question: http://stackoverflow.com/q/2772511
tags question: http://stackoverflow.com/q/2744110
tags question: http://stackoverflow.com/q/2626640
tags question: http://stackoverflow.com/q/2678483
tags question: http://stackoverflow.com/q/2692445
tags question: http://stackoverflow.com/q/2608205
type: Tag
tags question: http://stackoverflow.com/q/2637912
tags question: http://stackoverflow.com/q/2667015
tags question: http://stackoverflow.com/q/2690768
tags question: http://stackoverflow.com/q/2598129
tags question: http://stackoverflow.com/q/2657498
tags question: http://stackoverflow.com/q/2688100
tags question: http://stackoverflow.com/q/2602934
tags question: http://stackoverflow.com/q/2708591
tags question: http://stackoverflow.com/q/2784267
tags question: http://stackoverflow.com/q/2639758
tags question: http://stackoverflow.com/q/2712709
tags question: http://stackoverflow.com/q/2774320
tags question: http://stackoverflow.com/q/2777446
tags question: http://stackoverflow.com/q/2741101
tags question: http://stackoverflow.com/q/2673494
tags question: http://stackoverflow.com/q/2709993
tags question: http://stackoverflow.com/q/2615749
tags question: http://stackoverflow.com/q/2740136
tags question: http://stackoverflow.com/q/2758654
tags question: http://stackoverflow.com/q/2652836
tags question: http://stackoverflow.com/q/2611496

http://stackoverflow.com/comment/2745760
type: AnswerComment
comment on: http://stackoverflow.com/a/2719124
has text: this is not entirely true. you can sign Java applets and if the certificate is trusted, they have virtually all permissions of an installed Java application. I just don't know how easy interfacing with scanners is in Java.
type: Comment
score: 0

http://stackoverflow.com/a/2740629
downvote count: 0
type: Answer
score: 2
accepted answer of: http://stackoverflow.com/q/2740423
answers question: http://stackoverflow.com/q/2740423
has body: ScriptEngine engine = new ScriptEngineManager().getEngineByName("beanshell"); Object result = engine.eval("new Object().toString();"); System.out.println(result); You may get close to what you want using BeanShell. I ran the above code with Java 6 with BeanShell 2.0b4 and the JSR 223-based bsh-engine.jar engine on the classpath.
has comment: http://stackoverflow.com/comment/2769547
upvote count: 2
type: AcceptedAnswer

packet
tags question: http://stackoverflow.com/q/2756243
tags question: http://stackoverflow.com/q/2642487
tag name: packet
type: Tag

http://stackoverflow.com/a/2745052
answers question: http://stackoverflow.com/q/2745003
has comment: http://stackoverflow.com/comment/2774546
has comment: http://stackoverflow.com/comment/2774397
has comment: http://stackoverflow.com/comment/2774459
has comment: http://stackoverflow.com/comment/2774426
has comment: http://stackoverflow.com/comment/2774719
has comment: http://stackoverflow.com/comment/2774751
has comment: http://stackoverflow.com/comment/2774302
has body: Managing memory in my own code is not so difficult. It's not difficult - It's impossible. For example: public void foo() { Object o = new Object(); // free(o); // Doh! No "free" keyword in Java. } Without the aid of the garbage collector how can the memory consumed by o be reclaimed? I'm assuming from your question that you might want to avoid the sporadic pauses caused by garbage collection due to the high level of I/O being performed by your app. If this is the case there are techniques for minimising the number of objects created (e.g. re-using objects from a pool). You could also consider enabling the Concurrent Mark Sweep Collector. The concurrent mark sweep collector, also known as the concurrent collector or CMS, is targeted at applications that are sensitive to garbage collection pauses.
has comment: http://stackoverflow.com/comment/42254356
type: AcceptedAnswer
downvote count: 0
score: 8
accepted answer of: http://stackoverflow.com/q/2745003
upvote count: 8
has comment: http://stackoverflow.com/comment/2774474
type: Answer

http://stackoverflow.com/comment/59509216
score: 12
type: AnswerComment
comment on: http://stackoverflow.com/a/2758645
type: Comment
has text: @ElMac - assertions are for the dev/debug/test parts of the cycle - they are not for production. An if block runs in prod. Simple assertions won't break the bank, but expensive assertions that do complex data validation might bring down your production environment, which is why they are turned off there.

http://stackoverflow.com/a/2651218
score: 2
answers question: http://stackoverflow.com/q/2650893
upvote count: 2
has comment: http://stackoverflow.com/comment/2667364
has body: I used to worked with protocol buffer and I was very satisfied. It's really very, very fast. And You can easy integrate it with Java and C++.
has comment: http://stackoverflow.com/comment/2667324
downvote count: 0
type: Answer

http://stackoverflow.com/comment/2610052
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2600759
has text: Since N >> U for any but the briefest texts, O(N) will dominate over O(U log U). Yes, a max-heap shaves some time off, but the gain is very small, and it is not free (extra code complexity).
score: 0

http://stackoverflow.com/comment/55851174
comment on: http://stackoverflow.com/a/2710900
type: Comment
has text: I don't exactly understand how the link between the **private final int** variable **years** works to link with the 15 or 30 value ??
score: 0
type: AnswerComment

http://stackoverflow.com/a/3312392
has comment: http://stackoverflow.com/comment/102006168
has comment: http://stackoverflow.com/comment/126844219
has comment: http://stackoverflow.com/comment/120587161
type: Answer
answers question: http://stackoverflow.com/q/2663115
has comment: http://stackoverflow.com/comment/126844333
score: 1
upvote count: 2
has body: Detecting a loop in a linked list can be done in one of the simplest ways, which results in O(N) complexity using hashmap or O(NlogN) using a sort based approach. As you traverse the list starting from head, create a sorted list of addresses. When you insert a new address, check if the address is already there in the sorted list, which takes O(logN) complexity.
downvote count: 1
has comment: http://stackoverflow.com/comment/120587283
has comment: http://stackoverflow.com/comment/126844169
has comment: http://stackoverflow.com/comment/120587398
has comment: http://stackoverflow.com/comment/126844023
has comment: http://stackoverflow.com/comment/126815123

jsp
tags question: http://stackoverflow.com/q/2733531
tags question: http://stackoverflow.com/q/2743359
tags question: http://stackoverflow.com/q/2731964
tags question: http://stackoverflow.com/q/2725495
tags question: http://stackoverflow.com/q/2703647
tags question: http://stackoverflow.com/q/2782747
tags question: http://stackoverflow.com/q/2636021
tags question: http://stackoverflow.com/q/2785789
tags question: http://stackoverflow.com/q/2751300
tags question: http://stackoverflow.com/q/2776990
tags question: http://stackoverflow.com/q/2738326
tags question: http://stackoverflow.com/q/2674845
tags question: http://stackoverflow.com/q/2658922
tags question: http://stackoverflow.com/q/2740746
tags question: http://stackoverflow.com/q/2754339
tags question: http://stackoverflow.com/q/2632211
tags question: http://stackoverflow.com/q/2764636
tags question: http://stackoverflow.com/q/2632360
tags question: http://stackoverflow.com/q/2764063
tags question: http://stackoverflow.com/q/2600112
tags question: http://stackoverflow.com/q/2746598
tags question: http://stackoverflow.com/q/2631753
tags question: http://stackoverflow.com/q/2754272
tags question: http://stackoverflow.com/q/2721304
tags question: http://stackoverflow.com/q/2690441
tags question: http://stackoverflow.com/q/2604027
type: Tag
tags question: http://stackoverflow.com/q/2662605
tags question: http://stackoverflow.com/q/2741954
tags question: http://stackoverflow.com/q/2701094
tags question: http://stackoverflow.com/q/2667861
tags question: http://stackoverflow.com/q/2635491
tags question: http://stackoverflow.com/q/2605528
tags question: http://stackoverflow.com/q/2704103
tags question: http://stackoverflow.com/q/2623950
tags question: http://stackoverflow.com/q/2705640
tags question: http://stackoverflow.com/q/2651960
tags question: http://stackoverflow.com/q/2618595
tags question: http://stackoverflow.com/q/2656512
tag name: jsp
tags question: http://stackoverflow.com/q/2663079
tags question: http://stackoverflow.com/q/2620799
tags question: http://stackoverflow.com/q/2656545
tags question: http://stackoverflow.com/q/2752949
tags question: http://stackoverflow.com/q/2718742
tags question: http://stackoverflow.com/q/2778957
tags question: http://stackoverflow.com/q/2717561
tags question: http://stackoverflow.com/q/2659282
tags question: http://stackoverflow.com/q/2682018
tags question: http://stackoverflow.com/q/2714906
tags question: http://stackoverflow.com/q/2644297
tags question: http://stackoverflow.com/q/2631368
tags question: http://stackoverflow.com/q/2605801
tags question: http://stackoverflow.com/q/2611758
tags question: http://stackoverflow.com/q/2764031
tags question: http://stackoverflow.com/q/2664989
tags question: http://stackoverflow.com/q/2605111
tags question: http://stackoverflow.com/q/2651913
tags question: http://stackoverflow.com/q/2673819
tags question: http://stackoverflow.com/q/2736787
tags question: http://stackoverflow.com/q/2663096
tags question: http://stackoverflow.com/q/2702272
tags question: http://stackoverflow.com/q/2756410
tags question: http://stackoverflow.com/q/2757592
tags question: http://stackoverflow.com/q/2625340
tags question: http://stackoverflow.com/q/2727371
tags question: http://stackoverflow.com/q/2743704
tags question: http://stackoverflow.com/q/2706100

http://stackoverflow.com/a/2672842
has body: What you want is the Boyer-Moore algorithm. It is the most efficient known general method for this problem.
type: AcceptedAnswer
downvote count: 0
upvote count: 2
has comment: http://stackoverflow.com/comment/2692342
type: Answer
score: 2
accepted answer of: http://stackoverflow.com/q/2672272
answers question: http://stackoverflow.com/q/2672272

http://stackoverflow.com/comment/24257689
has text: @Eagle Please do not make edits that simply add bold formatting like this. Thanks!
type: Comment
comment on: http://stackoverflow.com/a/15954158
score: 0
type: AnswerComment

http://stackoverflow.com/comment/124544213
type: AnswerComment
comment on: http://stackoverflow.com/a/63080356
score: 0
type: Comment
has text: Thank you for the great answer! I have a special case where my code semantics guarantee that the cast is safe. I just needed the Java compiler to stop raising an error...

http://stackoverflow.com/comment/2694002
type: QuestionComment
has text: that doesn't make it a "bad choice"
type: Comment
score: 3
comment on: http://stackoverflow.com/q/2671526

http://stackoverflow.com/q/2700363
has comment: http://stackoverflow.com/comment/2723080
has answer: http://stackoverflow.com/a/2700410
tagged with: switch-statement
type: Question
has answer: http://stackoverflow.com/a/2700387
has title: Why do switch statements continue after case
favorite count: 0
has comment: http://stackoverflow.com/comment/2723349
answer count: 5
linked to: http://stackoverflow.com/q/188461
has answer: http://stackoverflow.com/a/2700373
tagged with: language-agnostic
has answer: http://stackoverflow.com/a/2700416
has body: After evaluating a case in a switch statement in Java (and I am sure other languages) the following case's are also evaluated unless a control statement like break, or return is used. I understand this is probably an implementation detail, but what is/are the reasons for having this functionality happen? Thanks!
has answer: http://stackoverflow.com/a/2700391
duplicate of: http://stackoverflow.com/q/188461
upvote count: 3
type: UnansweredQuestion
downvote count: 1
score: 2
linked to: http://stackoverflow.com/q/252489
tagged with: java

http://stackoverflow.com/a/2700238
has body: Just surround every single load operation with its own try / catch block. try { loadSoundDriver(); } catch (loadSoundDriverFailed) { doSomethingA; } try { loadUsbDriver(); } catch (loadUsbDriverFailed) { doSomethingB; } // ... So you can handle every exception by itself and continue processing the oder operations.
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/2724045
answers question: http://stackoverflow.com/q/2700173

http://stackoverflow.com/a/2673624
upvote count: 8
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2673510
answers question: http://stackoverflow.com/q/2673510
type: Answer
score: 8
has body: You're right to use the ApplicationContext there since if you don't it can cause significant memory leaks. However, the problem you have is that the static variable may not retain its value. Due to the way that Android handles applications it is possible that your application could be killed and then restarted - usually due to the user switching to other applications - in such a way that your static variable will become null and your code which sets it won't be run. Have a look at this question for a more detailed answer. It may be possible to work around this problem but testing all the possibilities that may cause your variable to end up null would be time-consuming and error prone. So in my static preference classes I have made any of the methods which require a Context take it as an argument. For example: static int getSomeIntegerPreference(Context context) { return PreferenceManager.getDefaultSharedPreferences(context).getInt(PREFERENCE_SOME_INTEGER, 0); } It's ugly but it works.
has comment: http://stackoverflow.com/comment/2692889
downvote count: 0
has comment: http://stackoverflow.com/comment/2692589

http://stackoverflow.com/a/2720796
downvote count: 0
score: 1
type: Answer
has body: The '7' in the call test(7); is an int and will not be automatically converted to a short. It works when you declare and initialize short values, but that's a special case for the compiler. This special case doesn't exist for method calls.
upvote count: 1
answers question: http://stackoverflow.com/q/2720738

http://stackoverflow.com/q/2683239
has title: how to know which special character is there in a file?
score: 2
type: AnsweredQuestion
tagged with: java
tagged with: character-encoding
type: Question
tagged with: encoding
downvote count: 0
has answer: http://stackoverflow.com/a/2683262
has answer: http://stackoverflow.com/a/2683257
accepted answer: http://stackoverflow.com/a/2683699
answer count: 3
possible better answer: http://stackoverflow.com/a/2683257
tagged with: utf-8
has body: My app needs to process text files during a batch process. Occassionally I receive a file with some special character at the end of the file. I am not sure what that special character is. Is there anyway I can find what that character is so that I can tell the other team which is producing that file. I have used mozilla's library to guess the file encoding and it says UTF-8.
favorite count: 0
upvote count: 2
has answer: http://stackoverflow.com/a/2683699

http://stackoverflow.com/q/2681161
type: Question
has body: In one of my directories I have all .java files which belong to one package ("game"). Now I want to create one .java file which does not belong to this package and which imports the "game" package. If I create a new file and write import game; then Eclipse complains that it does not know what the "game" package means. Can somebody please help me to solve this problem?
score: 9
upvote count: 9
has comment: http://stackoverflow.com/comment/2700910
downvote count: 0
has answer: http://stackoverflow.com/a/2681178
has answer: http://stackoverflow.com/a/2681236
answer count: 3
has answer: http://stackoverflow.com/a/10798603
favorite count: 0
has title: How to import a package from Eclipse?
type: UnansweredQuestion
tagged with: package
tagged with: java
tagged with: eclipse
tagged with: import

http://stackoverflow.com/q/2743359
type: Question
accepted answer: http://stackoverflow.com/a/2743508
has body: i want to do a select multiple double side like this : http://www.senamion.com/blog/jmultiselect2side.html (Demo2) but i don't know how i can retrieve my data when i click submit button..?
tagged with: struts
score: 0
answer count: 1
tagged with: jsp
has title: select multiple double side
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2743508
tagged with: java
tagged with: select

http://stackoverflow.com/a/9704809
score: 2
downvote count: 0
has body: If you are concerned about the details of converting a solution developed with Jersey to run on CXF, Glen Mazza posted a collection of Jersey samples ported to Apache CXF on GitHub. The README files have notes for each sample regarding necessary changes made.
upvote count: 2
answers question: http://stackoverflow.com/q/2704700
type: Answer
has comment: http://stackoverflow.com/comment/62084138
has comment: http://stackoverflow.com/comment/62092920

http://stackoverflow.com/comment/64007015
comment on: http://stackoverflow.com/q/2629381
type: QuestionComment
type: Comment
has text: I'm looking also for a solution, do you found something?
score: 0

http://stackoverflow.com/comment/2804101
type: AnswerComment
comment on: http://stackoverflow.com/a/2769035
score: 1
has text: I wouldn't say I like this option, because it relies on string constants as map keys. So the something similar to if/elseif/else/if is actually hidden within the map, but it still exists.
type: Comment

http://stackoverflow.com/comment/68853785
has text: new link http://www.oracle.com/technetwork/java/simple-142616.html
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2629512

http://stackoverflow.com/a/2625609
upvote count: 22
downvote count: 0
answers question: http://stackoverflow.com/q/2625579
has comment: http://stackoverflow.com/comment/2644588
score: 22
has comment: http://stackoverflow.com/comment/2643468
has body: return Collections.&lt;ComplexObject&gt; emptyList(); Using this will get rid of warnings from Eclipse about non-generic collections. Having said that, a typed empty list is going to be functionally identical to an untyped empty list due to empty list being immutable and Java erasing generic types at compile time.
has comment: http://stackoverflow.com/comment/2643799
has comment: http://stackoverflow.com/comment/2643574
type: Answer

http://stackoverflow.com/comment/2623765
type: QuestionComment
comment on: http://stackoverflow.com/q/2612895
has text: When i try to run my client code after starting server from the console as follows, i am able to make recognized my own policy file that resides in my home directory: appletviewer -J-Djava.security.policy=mypolicy.policy file:///home/xxx/NetBeansProjects/project/src/index.html But when i try to run from IDE, it fails :s
score: 0
type: Comment

http://stackoverflow.com/comment/32782588
comment on: http://stackoverflow.com/a/2618081
type: Comment
score: 3
type: AnswerComment
has text: ..."Taking square root of negative number is undefined (in arithmetics)"... Its not! its actually `i` and some languages like python deal very well with it... It may be not the case in `java` thou

http://stackoverflow.com/comment/17929538
type: Comment
type: QuestionComment
score: 0
has text: Actually you can use the assembly, provided that you wrap it in JNI, or JNA. It'd be great to see a performance-wise between the proposed solutions.
comment on: http://stackoverflow.com/q/2632392

graphics
tag name: graphics
tags question: http://stackoverflow.com/q/2746334
tags question: http://stackoverflow.com/q/2676719
tags question: http://stackoverflow.com/q/2713589
type: Tag
tags question: http://stackoverflow.com/q/2714233
tags question: http://stackoverflow.com/q/2684123
tags question: http://stackoverflow.com/q/2749191
tags question: http://stackoverflow.com/q/2784063
tags question: http://stackoverflow.com/q/2706310
tags question: http://stackoverflow.com/q/2770443

http://stackoverflow.com/comment/2753296
type: Comment
comment on: http://stackoverflow.com/a/2726135
has text: @HH the `super()` call has to be the first line of the subclass's constructor. If so, the argument can come from an argument to `Sub`'s constructor or wherever.
score: 0
type: AnswerComment

http://stackoverflow.com/a/4313811
answers question: http://stackoverflow.com/q/2664991
has body: In JBoss 5.1.0 GA look at jbossws.deployer/META-INF/jboss-beans.xml and comment the following line ${jboss.bind.address} it is 100% worked or see the following http://community.jboss.org/wiki/JBossWS-UserGuide
type: Answer
score: 0

http://stackoverflow.com/q/2617320
tagged with: web-services
type: Question
accepted answer: http://stackoverflow.com/a/2617348
has title: Most Efficient Way of calling an external webservice in Java?
possible better answer: http://stackoverflow.com/a/2617346
answer count: 3
tagged with: axis
has answer: http://stackoverflow.com/a/2617346
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2617361
has body: In one of our applications we need to call the Yahoo Soap Webservice to Get Weather and other related info. I used the wsdl2java tool from axis1.4 and generated th required stubs and wrote a client. I use jsp's use bean to include the client bean and call methods defined in the client which call the yahoo webservice inturn. Now the problem: When users make calls to the jsp the response time of the webservice differs greatly, like for one user it took less then 10 seconds and the other in the same network took more than a minute. I was just wondering if Axis1.4 queues the requests even though the jsps are multithreaded. And finally is there an efficient way of calling the webservice(Yahoo weather). Typically i get around 200 simultaneous requests from my users.
type: AnsweredQuestion
score: 2
upvote count: 2
tagged with: java
has answer: http://stackoverflow.com/a/2617348

database
tags question: http://stackoverflow.com/q/2709038
tags question: http://stackoverflow.com/q/2713758
tags question: http://stackoverflow.com/q/2784228
tags question: http://stackoverflow.com/q/2662915
tags question: http://stackoverflow.com/q/2743167
tags question: http://stackoverflow.com/q/2674323
tags question: http://stackoverflow.com/q/2710212
tags question: http://stackoverflow.com/q/2706335
tags question: http://stackoverflow.com/q/2653180
tags question: http://stackoverflow.com/q/2749378
type: Tag
tags question: http://stackoverflow.com/q/2624665
tags question: http://stackoverflow.com/q/2618252
tags question: http://stackoverflow.com/q/2703489
tags question: http://stackoverflow.com/q/2602527
tags question: http://stackoverflow.com/q/2723622
tags question: http://stackoverflow.com/q/2736767
tags question: http://stackoverflow.com/q/2603229
tags question: http://stackoverflow.com/q/2695505
tags question: http://stackoverflow.com/q/2677079
tags question: http://stackoverflow.com/q/2622052
tag name: database
tags question: http://stackoverflow.com/q/2737633
tags question: http://stackoverflow.com/q/2666865
tags question: http://stackoverflow.com/q/2733688
tags question: http://stackoverflow.com/q/2745764
tags question: http://stackoverflow.com/q/2768493
tags question: http://stackoverflow.com/q/2601875
tags question: http://stackoverflow.com/q/2746201
tags question: http://stackoverflow.com/q/2628356
tags question: http://stackoverflow.com/q/2603742

http://stackoverflow.com/comment/2679779
has text: I edited the question to show the actual problem. I probably should have done that from the start :)
type: Comment
comment on: http://stackoverflow.com/q/2662333
type: QuestionComment
score: 0

http://stackoverflow.com/a/2735559
accepted answer of: http://stackoverflow.com/q/2735524
has comment: http://stackoverflow.com/comment/2765439
answers question: http://stackoverflow.com/q/2735524
has comment: http://stackoverflow.com/comment/2763678
type: Answer
score: 8
downvote count: 0
upvote count: 8
has comment: http://stackoverflow.com/comment/2765562
has body: The exe will install Tomcat as a Windows Service. The zip file will allow you to start and stop Tomcat using batch files or to manually install the service. If you want to integrate Tomcat with an IDE, you need the zip file, since the required batch files aren't included in the exe version.
type: AcceptedAnswer

http://stackoverflow.com/comment/2630403
has text: @Bozho: Yes, I upvoted you because of the direct link :) My answer in his previous topic however do contain download buttons to both JRE and JDK.
comment on: http://stackoverflow.com/q/2618281
type: Comment
type: QuestionComment
score: 1

http://stackoverflow.com/comment/110439701
type: Comment
comment on: http://stackoverflow.com/a/25068258
has text: The personal name is exactly the part that the OP wants to be converted. So it shouldn't be null in that case and would be encoded by the extended constructor.
score: 0
type: AnswerComment

http://stackoverflow.com/a/2687600
has comment: http://stackoverflow.com/comment/24448914
accepted answer of: http://stackoverflow.com/q/2683914
upvote count: 124
answers question: http://stackoverflow.com/q/2683914
score: 113
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/45422723
downvote count: 11
has comment: http://stackoverflow.com/comment/7844548
type: Answer
has body: Let's assume we're equally comfortable in Scala and Java, and ignore the (huge) language differences except as they pertain to Spring or Lift. Spring and Lift are almost diametrically opposed in terms of maturity and goals. Spring is about five years older than Lift Lift is monolithic and targets only the web; Spring is modular and targets both web and "regular" apps Spring supports a plethora of Java EE features; Lift ignores that stuff In a sentence, Spring is heavyweight and Lift is lightweight. With sufficient determination and resources you can turn that on its head, but you would need a lot of both. Here are concrete differences that stuck in my mind after working with both frameworks. This isn't an exhaustive list, which I can't compile anyhow. Just what seemed most interesting to me... View philosophy Lift encourages placing some view material in snippet/action methods. Snippet code especially will be sprinkled with programmatically generated form elements, &lt;div&gt;s, &lt;p&gt;s, etc. This is powerful and useful, especially since Scala has a builtin language-level XML mode. One can write XML inline within Scala methods, including variable bindings in braces. This can be delightful for very simple XML services or mockups of services -- you can bang out a suite of HTTP response actions all in one splendidly terse file, without templates or much attendant configuration. The downside is complexity. Depending on how far you go, there's either a fuzzy separation of concerns between view and logic, or no separation. In contrast, regular use of Spring for webapps enforces a strong separation between the view and everything else. I think Spring supports several templating engines, but I've only used JSP in anything serious. Doing a Lift-inspired "fuzzy MVC" design with JSP would be madness. This is a good thing on larger projects, where the time to just read and understand can be overwhelming. Object-Relational Mapper Choices Lift's builtin ORM is "Mapper". There'…
has comment: http://stackoverflow.com/comment/3145419
has comment: http://stackoverflow.com/comment/4714711

http://stackoverflow.com/a/2754919
upvote count: 1
downvote count: 0
has body: It doesn't look like you're updating current... try inserting something like this in your loop: current = current.next;
answers question: http://stackoverflow.com/q/2754891
type: Answer
score: 1

http://stackoverflow.com/a/2645837
type: Answer
answers question: http://stackoverflow.com/q/2645783
score: 0
has body: Set numbers = new HashSet() while more numbers { read next number; if not exist in numbers continue else fail validation; } (or I completly misunderstood the question...)

http://stackoverflow.com/comment/2665730
type: Comment
type: QuestionComment
score: 0
has text: Which language of the many you've listed do you want to use?
comment on: http://stackoverflow.com/q/2649664

http://stackoverflow.com/q/2743130
has answer: http://stackoverflow.com/a/38424373
upvote count: 227
has answer: http://stackoverflow.com/a/78735556
possible better answer: http://stackoverflow.com/a/13309318
has answer: http://stackoverflow.com/a/72616686
has answer: http://stackoverflow.com/a/57603564
has answer: http://stackoverflow.com/a/75660465
has answer: http://stackoverflow.com/a/58435647
has answer: http://stackoverflow.com/a/51357670
has answer: http://stackoverflow.com/a/72881726
has answer: http://stackoverflow.com/a/39065345
has answer: http://stackoverflow.com/a/75751558
has answer: http://stackoverflow.com/a/69652869
has answer: http://stackoverflow.com/a/32201073
has answer: http://stackoverflow.com/a/52898619
has answer: http://stackoverflow.com/a/54214215
has answer: http://stackoverflow.com/a/40843350
has answer: http://stackoverflow.com/a/14772423
has body: I get following hibernate error. I am able to identify the function which causes the issue. Unfortunately there are several DB calls in the function. I am unable to find the line which causes the issue since hibernate flush the session at the end of the transaction. The below mentioned hibernate error looks like a general error. It doesn't even mentioned which Bean causes the issue. Anyone familiar with this hibernate error? org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1 at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java:93) at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:79) at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:142) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106) at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:584) at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransacti onManager.java:500) at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManag er.java:473) at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(Transaction AspectSupport.java:267) at org.springframework.transaction.interceptor…
score: 226
has answer: http://stackoverflow.com/a/23384570
has answer: http://stackoverflow.com/a/19422041
favorite count: 0
has answer: http://stackoverflow.com/a/21706388
has answer: http://stackoverflow.com/a/38898118
has answer: http://stackoverflow.com/a/48281698
has answer: http://stackoverflow.com/a/49074692
has answer: http://stackoverflow.com/a/39444288
has answer: http://stackoverflow.com/a/42582924
has title: Hibernate - Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
has answer: http://stackoverflow.com/a/31734897
has comment: http://stackoverflow.com/comment/86441969
has comment: http://stackoverflow.com/comment/10214767
has answer: http://stackoverflow.com/a/26219856
has answer: http://stackoverflow.com/a/73635372
has answer: http://stackoverflow.com/a/62570124
has answer: http://stackoverflow.com/a/2743663
has answer: http://stackoverflow.com/a/45986851
type: AnsweredQuestion
answer count: 47
has answer: http://stackoverflow.com/a/23145389
tagged with: java
tagged with: hibernate
has answer: http://stackoverflow.com/a/37956733
has answer: http://stackoverflow.com/a/37173383
has answer: http://stackoverflow.com/a/18518859
has answer: http://stackoverflow.com/a/46989666
has answer: http://stackoverflow.com/a/78041633
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/75744797
has answer: http://stackoverflow.com/a/70141665
has answer: http://stackoverflow.com/a/23523102
has answer: http://stackoverflow.com/a/48577567
has answer: http://stackoverflow.com/a/77914316
has answer: http://stackoverflow.com/a/13309318
has answer: http://stackoverflow.com/a/67536530
has answer: http://stackoverflow.com/a/62907047
has answer: http://stackoverflow.com/a/74780110
accepted answer: http://stackoverflow.com/a/2743663
has answer: http://stackoverflow.com/a/28552249
has answer: http://stackoverflow.com/a/23411047

http://stackoverflow.com/comment/81544049
score: 0
has text: @Saikat1529 given that this answer is over 7 years old, I'd suggest you ask a new question
type: AnswerComment
comment on: http://stackoverflow.com/a/3191089
type: Comment

http://stackoverflow.com/comment/2680708
score: 59
has text: Wow..I would love to work for this employer `finite amount of space and a reasonable amount of time?` :)
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2663115

http://stackoverflow.com/comment/56204239
type: Comment
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/11999682
has text: The official instructions are useless. They only give generic instructions on how to set environment variables rather than indicating the value that needs to be set. They simply say to set it to “the location of the class” which is confusing and meaningless.

http://stackoverflow.com/comment/2758952
score: 0
type: AnswerComment
type: Comment
has text: From a technological standpoint, seventeen years is a *considerable* amount of time. Not to date myself, but COM was just coming on to the scene while I was still in school. ;-) Simple fact is that it was introduced with COM and it became just a widely accepted practice within that development community. Microsoft was pretty much maintaining the status quo, even if it did not fit in with their other naming guidelines. Because of the "familiarity" it became an official exception to the rule in the class design guidelines, as well.
comment on: http://stackoverflow.com/a/2728221

http://stackoverflow.com/q/2678268
has answer: http://stackoverflow.com/a/2678315
type: UnansweredQuestion
tagged with: swing
has body: I have this action listener: this.newGameButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent a) { MokkiGUI.this.game = newGameQuery(); MokkiGUI.this.AI = new AIPlayer(MokkiGUI.this.game.getBoard()); MokkiGUI.this.boardLabel.setText(""); MokkiGUI.this.boardLabel.repaint(); refreshScreen(); JOptionPane.showMessageDialog(null, "Starting new game", "New game", JOptionPane.PLAIN_MESSAGE); if (MokkiGUI.this.game.getAIIndicator() % 2 == 1) { while (makeAIMove()) { MokkiGUI.this.refreshScreen(); } MokkiGUI.this.refreshScreen(); } } }); public void refreshScreen() { if (javax.swing.SwingUtilities.isEventDispatchThread()) { System.out.println("Is"); } else { System.out.println("Not"); } MokkiGUI.this.boardLabel.setText(MokkiTest.printBoard(MokkiGUI.this.game.getBoard())); MokkiGUI.this.boardLabel.repaint(); MokkiGUI.this.data.setText("X: " + MokkiGUI.this.game.getPlayer1name() + "\n Score: " + MokkiGUI.this.game.getPlayer1score() + "\n\n" + "O: " + MokkiGUI.this.game.getPlayer2name() + "\n Score: " + MokkiGUI.this.game.getPlayer2score()); MokkiGUI.this.data.repaint(); if (!MokkiGUI.this.game.redoable()) { MokkiGUI.this.forwardButton.setEnabled(false); MokkiGUI.this.allForwardButton.setEnabled(false); } else { MokkiGUI.this.forwardButton.setEnabled(true); MokkiGUI.this.allForwardButton.setEnabled(true); } if (!MokkiGUI.this.game.undoable()) { MokkiGUI.this.backButton.setEnabled(false); MokkiGUI.this.allBackButton.setEnabled(false); } else { MokkiGUI.this.backButton.setEnabled(true); MokkiGUI.this.allBackButton.setEnabled(true); } MokkiGUI.this.buttonPanel.repaint(); } The refreshScreen()s don't seem to work. They are apprently running on the Event Dispatcher thread and the changes made only show up when the action listener's execution is over. It works fine when called from the MokkiGUI() constructor, as it is not on the EDT.
tagged with: java
type: Question
answer count: 1
tagged with: edt
score: 0
tagged with: event-dispatch-thread
has title: Trouble getting Swing to refresh JLabel (apparently on event dispatch thread)

http://stackoverflow.com/a/2640151
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2640060
answers question: http://stackoverflow.com/q/2640060
type: Answer
upvote count: 6
has body: There are inconsistencies between the two compilers. I've found similar bugs, sometimes in Eclipse and sometimes in the JDK. I'm not sure which is wrong in this case. The problem appears to be due to the combination of generics and auto-boxing. In any case, if you specify the type parameter explicitly, instead of relying on type inference, it will compile: public boolean argh() { return GenericHelper.&lt;Boolean&gt;fail(); }
score: 6

http://stackoverflow.com/a/2761026
downvote count: 1
has body: Arrays.asList("Ryan", "Julie", "Bob");
upvote count: 33
has comment: http://stackoverflow.com/comment/137220935
has comment: http://stackoverflow.com/comment/137215320
type: Answer
answers question: http://stackoverflow.com/q/2760995
score: 32

http://stackoverflow.com/q/2653918
score: 7
has title: XMLStreamReader and a real stream
tagged with: http://stackoverflow.com/tag/xml
tagged with: streaming
accepted answer: http://stackoverflow.com/a/3843868
upvote count: 7
type: Question
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2940939
tagged with: java
answer count: 6
has answer: http://stackoverflow.com/a/2654098
possible better answer: http://stackoverflow.com/a/2940939
has answer: http://stackoverflow.com/a/2654005
has answer: http://stackoverflow.com/a/55149233
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/3843868
has answer: http://stackoverflow.com/a/2654082
tagged with: stax
has body: Update There is no ready XML parser in Java community which can do NIO and XML parsing. This is the closest I found, and it's incomplete: http://wiki.fasterxml.com/AaltoHome I have the following code: InputStream input = ...; XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance(); XMLStreamReader streamReader = xmlInputFactory.createXMLStreamReader(input, "UTF-8"); Question is, why does the method #createXMLStreamReader() expects to have an entire XML document in the input stream? Why is it called a "stream reader", if it can't seem to process a portion of XML data? For example, if I feed: &lt;root&gt; &lt;child&gt; to it, it would tell me I'm missing the closing tags. Even before I begin iterating the stream reader itself. I suspect that I just don't know how to use a XMLStreamReader properly. I should be able to supply it with data by pieces, right? I need it because I'm processing a XML stream coming in from network socket, and don't want to load the whole source text into memory. Thank you for help, Yuri.

dependency-injection
tags question: http://stackoverflow.com/q/2635406
type: Tag
tags question: http://stackoverflow.com/q/2632033
tags question: http://stackoverflow.com/q/2684171
tags question: http://stackoverflow.com/q/2743704
tags question: http://stackoverflow.com/q/2775958
tags question: http://stackoverflow.com/q/2652126
tags question: http://stackoverflow.com/q/2758879
tags question: http://stackoverflow.com/q/2611495
tags question: http://stackoverflow.com/q/2605198
tag name: dependency-injection
tags question: http://stackoverflow.com/q/2647139

http://stackoverflow.com/a/54653363
score: 1
answers question: http://stackoverflow.com/q/2718786
has body: For Windows Service, you need to run tomcat9w.exe (or 6w/7w/8w) depending on your version of tomcat. First, make sure tomcat is stopped. Then double click on tomcat9w.exe. Navigate to the Java tab. If you know you have 64 bit Windows with 64 bit Java and 64 bit Tomcat, then feel free to set the memory higher than 512. You'll need to do some task manager monitoring to determine how high to set it. For most apps developed in 2019... I'd recommend an initial memory pool of 1024, and the maximum memory pool of 2048. Of course if your computer has tons of RAM... feel free to go as high as you want. Also, see this answer: How to increase Maximum Memory Pool Size? Apache Tomcat 9
downvote count: 0
type: Answer
upvote count: 1

http://stackoverflow.com/a/36250797
answers question: http://stackoverflow.com/q/2777415
score: 0
type: Answer
has body: a much more used case is to merge a single page background pdf with a multi page source pdf file. The background pdf contains only a header and footer for instance. The source pdf is already prepared with upper und lower margins as placeholders for the header and footer of the background pdf template in this scene. If you are looking for this - like I did - you will stumbling over this thread here and you could apply the following approach: tplFile$ = "c:/0/background.pdf" srcFile$ = "c:/0/source1.pdf" destFile$ = "c:/0/newMergedDest.pdf" declare Document destDoc! declare PdfWriter destWriter! declare PdfReader mainDocReader! declare PdfReader singlePageBackgroundReader! declare PdfImportedPage mainDocPage! declare PdfImportedPage backgroundPage! declare PdfContentByte dcb! declare PdfContentByte ucb! destDoc! = new Document() destWriter! = PdfWriter.getInstance(destDoc!, new FileOutputStream(destFile$)) destDoc!.open() dcb! = destWriter!.getDirectContent() ucb! = destWriter!.getDirectContentUnder() mainDocReader! = new PdfReader(srcFile$) singlePageBackgroundReader! = new PdfReader(tplFile$) backgroundPage! = destWriter!.getImportedPage(singlePageBackgroundReader!,1) for i=1 to mainDocReader!.getNumberOfPages() destDoc!.newPage() mainDocPage! = destWriter!.getImportedPage(mainDocReader!,i) dcb!.addTemplate(mainDocPage!,0,0) ucb!.addTemplate(backgroundPage!,0,0) next i destDoc!.close()

http://stackoverflow.com/a/54386963
upvote count: 4
answers question: http://stackoverflow.com/q/2608665
downvote count: 0
type: Answer
has body: Edited: Just realized that I should specify that this works only if both of them exists. Otherwise the string is not considered quoted. Such scenario appeared for me when working with CSV files. org.apache.commons.lang3.StringUtils.unwrap("\"abc\"", "\"") = "abc" org.apache.commons.lang3.StringUtils.unwrap("\"abc", "\"") = "\"abc" org.apache.commons.lang3.StringUtils.unwrap("abc\"", "\"") = "abc\""
score: 4

http://stackoverflow.com/q/2694127
accepted answer: http://stackoverflow.com/a/2720071
answer count: 1
downvote count: 0
has body: I am deploying an application on Tomcat 6, using a war file. I've compiled the source code given by the vendor on the same machine, then moved the war file to {tomcat-home}/webapps/ When I start up the application, I see a error message: The SystemInformationService could not be retrieved from the container. Therefore very limited information is available in this error report. The SystemInformationService could not be retrieved due to the following error: java.lang.IllegalStateException: Spring Application context has not been set Cause java.lang.RuntimeException: Unable to instantiate VelocityEngine! at com.opensymphony.webwork.views.velocity.VelocityManager.newVelocityEngine(VelocityManager.java:333) Stack Trace:[hide] java.lang.RuntimeException: Unable to instantiate VelocityEngine! at com.opensymphony.webwork.views.velocity.VelocityManager.newVelocityEngine(VelocityManager.java:333) at com.opensymphony.webwork.views.velocity.VelocityManager.init(VelocityManager.java:146) at com.opensymphony.webwork.dispatcher.VelocityResult.doExecute(VelocityResult.java:61) I followed the same steps on another machine and it installed correctly. I don't understand what the error is telling me. Could I be missing jar files? ( but it compiled fine ). Have I forgotten to set environment variables? I'm not sure what to make of this, I don't know what the VelocityEngine is, or does.
tagged with: tomcat
favorite count: 0
tagged with: java-war
tagged with: velocity
has answer: http://stackoverflow.com/a/2720071
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2716408
has title: Unable to instantiate VelocityEngine, when deploying war file
tagged with: java
tagged with: tomcat6
type: Question
score: 5
upvote count: 5

http://stackoverflow.com/a/45297091
answers question: http://stackoverflow.com/q/2665993
has comment: http://stackoverflow.com/comment/131336266
has comment: http://stackoverflow.com/comment/119901543
type: Answer
has comment: http://stackoverflow.com/comment/119641536
has comment: http://stackoverflow.com/comment/113420838
downvote count: 1
score: 21
has body: Your can use AtomicBoolean to make sure the task is only called the first time: import java.util.concurrent.atomic.AtomicBoolean; public class Once { private final AtomicBoolean done = new AtomicBoolean(); public void run(Runnable task) { if (done.get()) return; if (done.compareAndSet(false, true)) { task.run(); } } } Usage: Once once = new Once(); once.run(new Runnable() { @Override public void run() { foo(); } }); // or java 8 once.run(() -&gt; foo());
upvote count: 22
has comment: http://stackoverflow.com/comment/121680632

http://stackoverflow.com/a/2785030
has body: You need to use a Dynamic Proxy to implement the SignalHandler interface. The rest is just basic reflection. Update Here's how you do it. Note, I've omitted the try-catch that needs to wrap all of this Class&lt;?&gt; handlerCl = Class.forName("sun.misc.SignalHandler"); Class&lt;?&gt; signalCl = Class.forName("sun.misc.Signal"); Constructor signalCtor = signalCl.getConstructor(String.class); Method signalHandle = signalCl.getMethod("handle", signalCl, handlerCl); // Create a proxy class that implements SignalHandler Class&lt;?&gt; proxyClass = Proxy.getProxyClass(signalCl.getClassLoader(), handlerCl); // This is used by the instance of proxyClass to dispatch method calls InvocationHandler invHandler = new InvocationHandler() { public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { // proxy is the SignalHandler's "this" rederence // method will be the handle(Signal) method // args[0] will be an instance of Signal // If you're using this object for multiple signals, you'll // you'll need to use the "getName" method to determine which // signal you have caught. return null; } }; // Get the constructor and create an instance of proxyClass Constructor&lt;?&gt; proxyCtor = proxyClass.getConstructor(InvocationHandler.class); Object handler = proxyCtor.newInstance(invHandler); // Create the signal and call Signal.handle to bind handler to signal Object signal = signalCtor.newInstance("TERM"); signalHandle.invoke(null, signal, handler);
answers question: http://stackoverflow.com/q/2783595
accepted answer of: http://stackoverflow.com/q/2783595
type: Answer
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/2823936
has comment: http://stackoverflow.com/comment/12202551
has comment: http://stackoverflow.com/comment/2825806
upvote count: 2
type: AcceptedAnswer

http://stackoverflow.com/a/2747148
type: Answer
has body: The short answer is "yes" - if you're using arrays like this: private void foo () { int[][] bar = new int[10][10]; bar[1] = null; //at this point, the array that was in bar[1] is eligible for garbage collection //unless someone else has a reference to it }
has comment: http://stackoverflow.com/comment/2777477
accepted answer of: http://stackoverflow.com/q/2747111
answers question: http://stackoverflow.com/q/2747111
has comment: http://stackoverflow.com/comment/2777641
upvote count: 5
score: 5
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/2616192
has body: See Teleteype.readInt() from the Java Project Template. The basics of it is that you read input as a String, and then you convert it to an integer using Integer.parseInt(), which will throw NumberFormatException if the contents of the String is not an integer, which you can handle by catching the NumberFormatException.
type: Answer
score: 0
answers question: http://stackoverflow.com/q/2616050

loops
tags question: http://stackoverflow.com/q/2667499
type: Tag
tags question: http://stackoverflow.com/q/2624762
tags question: http://stackoverflow.com/q/2671103
tag name: loops
tags question: http://stackoverflow.com/q/2702980
tags question: http://stackoverflow.com/q/2776745
tags question: http://stackoverflow.com/q/2702253
tags question: http://stackoverflow.com/q/2741231
tags question: http://stackoverflow.com/q/2665655

http://stackoverflow.com/q/2732981
score: 18
upvote count: 18
accepted answer: http://stackoverflow.com/a/20530943
answer count: 3
has title: How to disable log4j in 3rd party jar?
downvote count: 0
favorite count: 0
possible better answer: http://stackoverflow.com/a/37855570
has body: I'm experimenting writing a java SE swing application using JBoss weld. Weld configures logging with log4j using the following log4j.xml file in the jar: <?xml version="1.0" encoding="UTF-8"?> <!-- JBoss, Home of Professional Open Source Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors by the @authors tag. See the copyright.txt in the distribution for a full listing of individual contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false"> <priority value="INFO"/> <priority value="INFO"/> <appender-ref ref="CONSOLE"/> </log4j:configuration> I want to disable logging altogether in my application. I tried to disable it providing a log4j.properties file as follows: log4j.debug=FALSE log4j.rootLogger=OFF, CONSOLE No matter what I try to do I cannot prevent the log4j messages from Weld to show up in the console. All I want to do is completely disable logging. But How?
has answer: http://stackoverflow.com/a/37855570
tagged with: log4j
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/20530943
has answer: http://stackoverflow.com/a/3751841
type: Question
tagged with: java

http://stackoverflow.com/q/2764063
favorite count: 0
tagged with: contextpath
has answer: http://stackoverflow.com/a/2764943
possible better answer: http://stackoverflow.com/a/2764848
has comment: http://stackoverflow.com/comment/2796427
upvote count: 1
has body: i have created one hyperlink, and by clicking on that i am redirecting the page to another JSP, but i am not getting the correct URL that i am passing, URL is appended with another string and the page is not redirected, please anybody have any idea about that, help me out &lt;td align='&lt;%=lstrColAlign%&gt;' class="&lt;%=tdclass%&gt; Label2" style="&lt;%=rb.getDataStyleString(rvo,data)%&gt;"&gt; &lt;a href="#" onclick="JavaScript:window.open( '&lt;%=columnUrl%&gt;','newwindow','top=0, left=0, scrollbars=yes,status=1,resizable=yes,height= (screen.availHeight - 10), width= (screen.availWidth-5)')"&gt; &lt;%=rb.getDataValue(data)%&gt;&lt;/a&gt; &lt;/font&gt;&lt;/td&gt; where i should get ...Project1-context-root/servlet/Reports.controller.ReportController?ActionFlag=get............. but instead of that i am getting ...Project1-context-root/servlet/servlet/Reports.controller.ReportController?ActionFlag=get..... so, extra word servlet/ is appended
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2764848
score: 1
tagged with: java
type: Question
answer count: 2
accepted answer: http://stackoverflow.com/a/2764943
has comment: http://stackoverflow.com/comment/2796690
downvote count: 0
tagged with: jsp
has title: contextpath is appended

http://stackoverflow.com/comment/27491432
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2602799
has text: But it doesn't seem to do what I thought it would. I have: if (tsUser.user.id != connectedUser().id) but it does not give me a warning. Both of the id's are Longs.

http://stackoverflow.com/q/2637890
has answer: http://stackoverflow.com/a/2638079
has title: Trying to get the associated value from an Enum at runtime in Java
favorite count: 0
answer count: 5
accepted answer: http://stackoverflow.com/a/2637943
upvote count: 1
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2638055
has answer: http://stackoverflow.com/a/2638013
tagged with: enums
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/10961747
has body: I want to accomplish something like the following (my interest is in the toInt() method). Is there any native way to accomplish this? If not, how can I get the integer associated with an enum value (like in C#) ? enum Rate { VeryBad(1), Bad(2), Average(3), Good(4), Excellent(5); private int rate; private Rate(int rate) { this.rate = rate; } public int toInt() { return rate; } } Thanks
downvote count: 0
has answer: http://stackoverflow.com/a/2637943
possible better answer: http://stackoverflow.com/a/2638079
score: 1

http://stackoverflow.com/a/2738769
accepted answer of: http://stackoverflow.com/q/2738743
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2738743
type: Answer
upvote count: 9
has body: 32 characters is how much you need to represent an int in binary (base-2, shift of 1, used by toBinaryString). It could be sized exactly, but I guess it has never made business sense to attempt that optimisation.
downvote count: 0
score: 9

http://stackoverflow.com/comment/135612572
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/2673864
has text: it's sad to see this
type: Comment

http://stackoverflow.com/q/2665731
type: Question
has title: Interop: HmacSHA1 in Java and dotNet
tagged with: c#
score: 2
tagged with: interop
downvote count: 0
has body: In an app we are calculating a SHA1Hmac in java using the following: SecretKey key = new SecretKeySpec(secret, "HmacSHA1"); Mac m = Mac.getInstance("HmacSHA1"); m.init(key); byte[] hmac = m.doFinal(data); And later, the hmac is verified in C# - on a SmartCard - using: HMACSHA1 hmacSha = new HMACSHA1(secret); hmacSha.Initialize(); byte[] hmac = hmacSha.ComputeHash(data); However, the result is not the same. Did I overlook something important? The inputs seem to be the same. Here some sample inputs: Data: 546573746461746131323341fa3c35 Key: 6d795472616e73616374696f6e536563726574 Result Java: 37dbde318b5e88acbd846775e38b08fe4d15dac6 Result C#: dd626b0be6ae78b09352a0e39f4d0e30bb3f8eb9 I wouldn't mind to implement my own hmacsha1 on both platforms, but using what already exists.... Thanks!
answer count: 1
accepted answer: http://stackoverflow.com/a/2667990
tagged with: cryptography
favorite count: 0
upvote count: 2
type: AnsweredQuestion
tagged with: java
tagged with: hmac
has answer: http://stackoverflow.com/a/2667990
has comment: http://stackoverflow.com/comment/2684638

http://stackoverflow.com/a/2716863
accepted answer of: http://stackoverflow.com/q/2716596
has comment: http://stackoverflow.com/comment/22271353
has comment: http://stackoverflow.com/comment/11438203
score: 36
answers question: http://stackoverflow.com/q/2716596
type: Answer
has body: You can create a ByteArrayOutputStream and write to it, and extract the contents as a byte[] using toByteArray(). Then ByteBuffer.wrap(byte []) will create a ByteBuffer with the contents of the output byte array.
has comment: http://stackoverflow.com/comment/2742522
upvote count: 36
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/2642252
possible better answer: http://stackoverflow.com/a/49824940
answer count: 2
has answer: http://stackoverflow.com/a/49824940
downvote count: 0
accepted answer: http://stackoverflow.com/a/2642273
has comment: http://stackoverflow.com/comment/92563241
has body: Anyone know how I can use httponly cookies for sessions and cookies on the app engine? In the javadoc for the Cookie class, http://java.sun.com/javaee/6/docs/api/javax/servlet/http/Cookie.html#setHttpOnly(boolean) , there is a setHttpOnly method. I get a compiler error when trying to use it when developing for app engine though. The method was introduced in the Servlet 3.0 spec, so its pretty new.
favorite count: 0
tagged with: google-app-engine
type: AnsweredQuestion
tagged with: cookies
tagged with: java
has title: HttpOnly cookies on google app engine java
has answer: http://stackoverflow.com/a/2642273
tagged with: httponly
type: Question
linked to: http://stackoverflow.com/q/16398327
score: 4
upvote count: 4

http://stackoverflow.com/q/2638107
tagged with: android
has title: size or length of a Document object
score: 0
answer count: 2
accepted answer: http://stackoverflow.com/a/2638398
has body: How can i get the size of an Document object? DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); InputStream iStr = urlConnection.getInputStream(); doc = db.parse(iStr); ???? --&gt; Log.i("Bytes",String.valueOf(doc.get????));
possible better answer: http://stackoverflow.com/a/2638293
tagged with: java
has answer: http://stackoverflow.com/a/2638293
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2638398
type: Question

http://stackoverflow.com/comment/40616934
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/2770692
type: Comment
has text: Raw types are very usefull and reduce boilerplate code in case of JNDI lookups for a bean which extends an interface. This resolves the need to write `n` remote beans for each implementing class with identical code.

http://stackoverflow.com/comment/15808002
score: 0
type: AnswerComment
has text: Exists a ready to use root certificates file? (like browsers do)
type: Comment
comment on: http://stackoverflow.com/a/5493452

http://stackoverflow.com/a/2713124
upvote count: 7
has comment: http://stackoverflow.com/comment/2738177
answers question: http://stackoverflow.com/q/2713102
score: 7
has comment: http://stackoverflow.com/comment/2737990
has comment: http://stackoverflow.com/comment/2738406
downvote count: 0
has body: If something else has already called getWriter, it may well have already written some text to the response. Besides, PrintWriter is for text - you want to send arbitrary binary data... getOutputStream is definitely the way forward, so I would try to find the filter which has called getWriter and fix that instead.
has comment: http://stackoverflow.com/comment/2756357
type: Answer

http://stackoverflow.com/comment/2792721
type: Comment
score: 0
has text: I've verified that the singleton is being instantiated twice and when I moved the code into $TOMCAT_HOME/lib I was able to get the singleton to work so it is clearly a class loader issue. My app is just a bunch of JSPs and I don't define any servlet in the web.xml. Do you have any ideas on how to make requests to my app use the same class loader?
comment on: http://stackoverflow.com/a/2758004
type: AnswerComment

http://stackoverflow.com/a/2733805
has comment: http://stackoverflow.com/comment/2761957
type: Answer
upvote count: 7
has comment: http://stackoverflow.com/comment/22223464
score: 7
accepted answer of: http://stackoverflow.com/q/2733735
answers question: http://stackoverflow.com/q/2733735
type: AcceptedAnswer
downvote count: 0
has body: Without any trace, I am just shooting in the dark. Try to add this 2 calls, System.setProperty("http.keepAlive", "false"); connection.setRequestProperty("Connection", "close"); Keep-alive is a common cause for stale connections. These calls will disable it.

http://stackoverflow.com/comment/58445171
type: Comment
has text: One more comment and I will be done. you are assuming that they will specify `Double number = addNumbers...` forcing use of two Doubles for addition but if written like I had above `Number number = addNumbers...` you can now pass any two objects that extend the number class. so long story short even in your method you should still check the type of both a and b.
type: AnswerComment
comment on: http://stackoverflow.com/a/30110482
score: 0

http://stackoverflow.com/q/2704157
score: 1
tagged with: java
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/2704201
has title: How to generate Image at server side in java [ blob-> string_image -> *.png or .jpg ]
tagged with: image
answer count: 1
downvote count: 0
tagged with: server-side
favorite count: 0
accepted answer: http://stackoverflow.com/a/2704201
has body: I want to generate an image on server side. My image is stored in a server database in blob format and I am able to convert it into string_image. Then how can I convert that string_image into actual .jpg or .png format? Actually I am posting attachment as image on users facebook wall. How to generate the image at server side in Java? Is there any sample code to do it?
tagged with: facebook
type: AnsweredQuestion

http://stackoverflow.com/a/19266048
score: 0
has body: Try Mixer2. http://mixer2.org/ Mixer2 has no dependency for servlet-API. You can store the template on String, java.io.File, and java.io.InputStream.
type: Answer
answers question: http://stackoverflow.com/q/2613404

http://stackoverflow.com/a/5594790
upvote count: 1
answers question: http://stackoverflow.com/q/2735539
type: Answer
downvote count: 0
has body: Isn't there some getter which would allow you to get this Treeviewer? Anyway, if there's not, then the only way to get it that comes to my mind is by using reflection.
score: 1

http://stackoverflow.com/comment/2830340
score: 0
comment on: http://stackoverflow.com/a/2783947
type: Comment
has text: @Pascal Am I right if I consider that omitting `inverse="true"` attribute will cause using this line `sessuibDao.saveObject(session);` too?
type: AnswerComment

http://stackoverflow.com/comment/2700019
type: AnswerComment
type: Comment
has text: @binil It doesn't hang, but hibernate complains for trying to flush after the commit since the session is now closed. Flushing before committing makes the test hang again.
comment on: http://stackoverflow.com/a/2679388
score: 0

http://stackoverflow.com/a/2729300
has body: To intercept the keys (without worrying if the specific component is in focus) you should use the InputMap. Read up on for instance: http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html And go for the WHEN_IN_FOCUSED_WINDOW constant. Unless the button in question simply calls a single method, the best way to do "what ever the button does" is to do: SwingUtilities.invokeAndWait(new Runnable() { public void run() { ((AbstractButton) c).doClick(); } });
score: 2
downvote count: 0
upvote count: 2
type: Answer
answers question: http://stackoverflow.com/q/2729269

http://stackoverflow.com/q/2784791
type: Question
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2869948
upvote count: 5
has title: How to avoid "Illegal type in constant pool" using "ldc_w <classname>" in Jasmin?
score: 5
answer count: 1
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2869948
tagged with: jasmin
tagged with: java
has body: I'm writing a compiler that generates Jasmin code and want to invoke a method that takes a Class as a parameter. public class CTest { public static void main(String[] args) throws Exception { java.lang.reflect.Array.newInstance(CTest.class, 0); } } So in Jasmin, I think that should be: .class public CTest2 .super java/lang/Object .method public static main([Ljava/lang/String;)V .limit stack 2 .limit locals 1 ldc_w CTest2 iconst_0 invokestatic java/lang/reflect/Array/newInstance(Ljava/lang/Class;I)Ljava/lang/Object; pop return .end method When I assemble it and run it I get: Exception in thread "main" java.lang.VerifyError: (class: CTest2, method: main signature: ([Ljava/lang/String;)V) Illegal type in constant pool Looking at the disassembled code for both CTest.class (the Java version) and CTest2.class (the Jasmin version) with "javap -c -verbose" they both appear to set up the constant pool the same way: const #2 = class #16; // CTest const #16 = Asciz CTest; 0: ldc_w #2; //class CTest const #14 = Asciz CTest2; const #17 = class #14; // CTest2 0: ldc_w #17; //class CTest2 I've fixed two bugs in Jasmin already, but I can't see what it's doing wrong when putting the class in the constant pool for "ldc_w" it puts classes in the constant pool for other instructions, like "new" and "anewarray" correctly. I've tried looking at the .class files with TraceClassVisitor in ASM, but it doesn't dump the constant pool. Any ideas what I can try next?

http://stackoverflow.com/q/2704050
answer count: 1
favorite count: 0
tagged with: netbeans
upvote count: 2
type: UnansweredQuestion
score: 2
tagged with: java
has title: create jar file with images and database
has comment: http://stackoverflow.com/comment/2727538
type: Question
has comment: http://stackoverflow.com/comment/2727501
has answer: http://stackoverflow.com/a/2704064
tagged with: jar
linked to: http://stackoverflow.com/q/2273040
downvote count: 0
tagged with: image
has body: Hi I am using NetBeans IDE and I have my images (what I am using in my project) in a folder named Images. When I am building jar it doesn't take that images. The code I am using to set image is, buttonObj.setIcon(new ImageIcon("\Images\a.jpg") any help please.

http://stackoverflow.com/a/2603571
accepted answer of: http://stackoverflow.com/q/2603323
type: Answer
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/45146741
has body: The problem is that b was made persistent in another session, which is closed and the query is created in a new session. When a session is closed, all objects in its persistence context become detached. If you want to later reuse them in another session, you need to re-attach them to that session first: session.update(b); Quote from the Hibernate book: The update() operation on the Session reattaches the detached object to the persistence context and schedules an SQL UDPATE. Hibernate must assume that the client modified the object while it was detached. (Otherwise, if you’re certain that it hasn’t been modified, a lock() would be sufficient.) The persistence context is flushed automatically when the second transaction in the conversation commits, and any modifications to the once detached and now persistent object are synchronized with the database. The saveOrUpdate() method is in practice more useful than update(), save(), or lock(): In complex conversations, you don’t know if the item is in detached state or if it’s new and transient and must be saved. The automatic state-detection provided by saveOrUpdate() becomes even more useful when you not only work with single instances, but also want to reattach or persist a network of connected objects and apply cascading options. Note that there is also a merge() method, for cases when the same entity has been loaded into the new persistence context before the older detached instance could be re-attached. In this case, you have two physically distinct instances representing the same entity, thus they should be merged to avoid a NonUniqueObjectException.
has comment: http://stackoverflow.com/comment/2613204
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2603323

http://stackoverflow.com/q/2677798
tagged with: java
tagged with: hibernate
type: Question
has answer: http://stackoverflow.com/a/2693739
score: 2
has title: Changing location of c3p0.properties and hibernate.properties
downvote count: 0
answer count: 1
tagged with: c3p0
favorite count: 0
accepted answer: http://stackoverflow.com/a/2693739
has body: I have a problem regarding the use of hibernate.properties and c3p0.properties. I am dependent upon an API. The API uses Hibernate. As such the API has it's own hibernate.properties and c3p0.properties file included within its delivery jar. I need to ensure I ignore these properties completely when instantiating my Hibernate SessionFactory. I do need these files to remain available on the CLASSPATH so that the API I depend upon can be configured. I simply need a way to instantiate my org.hibernate.SessionFactory so that it doesn't look at these files in any way. I don't mind using an xml configuration or setting my Hibernate properties manually. I just need to ensure that the properties in hibernate.properties and c3p0.properties are not read.
type: AnsweredQuestion
upvote count: 2

http://stackoverflow.com/q/2697667
tagged with: 3des
favorite count: 0
has answer: http://stackoverflow.com/a/2699039
tagged with: bouncycastle
tagged with: encryption
upvote count: 1
has comment: http://stackoverflow.com/comment/2747067
possible better answer: http://stackoverflow.com/a/2698156
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2698156
has title: Creating a Cerificate for Bouncy Castle Encryption
score: 1
tagged with: java
tagged with: certificate
has body: I am trying to create a self-signed certificate to use for encrypting an email using bouncycaste. What would be the best way to generate a certificate? I have tried using openssl but I have had problems with certificate. Here is the code I am using to encrypt, I am using 3des. SMIMEEnvelopedGenerator gen = new SMIMEEnvelopedGenerator(); gen.addKeyTransRecipient(x509Cert); // adds an X509Certificate MimeBodyPart encData = gen.generate(mimeBodyPart, SMIMEEnvelopedGenerator.DES_EDE3_CBC, "BC"); EDIT: Sorry for being vauge but the error message I am getting doesn't seem to be very useful. The message is as follows: org.openas2.WrappedException: org.bouncycastle.mail.smime.SMIMEException: key invalid in message. This is thrown when I call the SMIMEEnvelopedGenerator.generate method. I am currently attaching the source code in Eclipse to see if I can get a more useful error message by stepping through the code.
has comment: http://stackoverflow.com/comment/2746908
accepted answer: http://stackoverflow.com/a/2699039
type: Question
answer count: 2
downvote count: 0

http://stackoverflow.com/comment/3073319
score: 0
has text: 1) will it work in browser 2) will it work on mobile devices 3) have you tried it or just googled it?
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/3007482

http://stackoverflow.com/a/66383590
has comment: http://stackoverflow.com/comment/139797386
has comment: http://stackoverflow.com/comment/139789563
downvote count: 0
score: 1
has body: Apache HttpComponents Core 5 supports HTTP/1.1 pipelining. The example could be found here.
answers question: http://stackoverflow.com/q/2777005
upvote count: 1
type: Answer

http://stackoverflow.com/a/2744947
score: 4
upvote count: 4
type: AcceptedAnswer
downvote count: 0
type: Answer
has body: No. There are some other JVMs with tracing JITs, though: HotPath and Maxine, for example.
accepted answer of: http://stackoverflow.com/q/2744817
answers question: http://stackoverflow.com/q/2744817

http://stackoverflow.com/a/2614097
score: 11
has comment: http://stackoverflow.com/comment/2625242
answers question: http://stackoverflow.com/q/2614072
has body: Declaration is not to declare "value" to a variable; it's to declare the type of the variable. Assignment is simply the storing of a value to a variable. Initialization is the assignment of a value to a variable at the time of declaration. These definitions also applies to fields. int i; // simple declaration i = 42 // simple assignment int[] arr = { 1, 2, 3 }; // declaration with initialization, allows special shorthand syntax for arrays arr = { 4, 5, 6 }; // doesn't compile, special initializer syntax invalid here arr = new int[] { 4, 5, 6 }; // simple assignment, compiles fine However, it should be mentioned that "initialization" also has a more relaxed definition of "the first assignment to a variable", regardless of where it happens. int i; // local variable declaration if (something) i = 42; System.out.println(i); // compile time error: The local variable i may not have been initialized This, however, compiles: int i; // the following also compiles if i were declared final if (something) i = 42; else i = 666; System.out.println(i); Here i can be "initialized" from two possible locations, by simple assignments. Because of that, if i was an array, you can't use the special array initializer shorthand syntax with this construct. So basically "initialization" has two possible definitions, depending on context: In its narrowest form, it's when an assignment is comboed with declaration. It allows, among other things, special array shorthand initializer syntax More generally, it's when an assignment is first made to a variable. It allows, among other things, assignments to a final variable at multiple places. The compiler would do its best to ensure that exactly one of those assignments can happen, thus "initializing" the final variable There's also JVM-context class and instance initialization, OOP-context object initialization, etc.
downvote count: 0
upvote count: 11
has comment: http://stackoverflow.com/comment/2625250
type: Answer

http://stackoverflow.com/a/2720487
type: Answer
has body: I can also recommend JTA, the Java Terminal Adapter. Very nice plugin architecture if you have to add value to it.
answers question: http://stackoverflow.com/q/2715406
score: 0

http://stackoverflow.com/q/2610674
tagged with: http://stackoverflow.com/tag/xml
has comment: http://stackoverflow.com/comment/16015005
has answer: http://stackoverflow.com/a/2610697
upvote count: 1
has body: Take a look at the example code... NodeList folderNodes = document.getElementsByTagName("Folder"); DocumentFragment node = (DocumentFragment) folderNodes.item(0); It was very easy to do "getElementsByTagName" on the document but when I want to do this again on the DocumentFragment it seems I cannot. How do I go about furthering this query?
has title: W3C dom api in Java
type: AnsweredQuestion
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/2610697
downvote count: 0
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/16023483
score: 1

http://stackoverflow.com/a/19231762
has body: public class Test { public class A {} public class B extends A {} public class C extends B {} public void testCoVariance(List&lt;? extends B&gt; myBlist) { B b = new B(); C c = new C(); myBlist.add(b); // does not compile myBlist.add(c); // does not compile A a = myBlist.get(0); } public void testContraVariance(List&lt;? super B&gt; myBlist) { B b = new B(); C c = new C(); myBlist.add(b); myBlist.add(c); A a = myBlist.get(0); // does not compile } }
has comment: http://stackoverflow.com/comment/126464136
upvote count: 35
type: Answer
has comment: http://stackoverflow.com/comment/66776273
has comment: http://stackoverflow.com/comment/126464087
downvote count: 2
has comment: http://stackoverflow.com/comment/62527918
answers question: http://stackoverflow.com/q/2723397
score: 33

http://stackoverflow.com/a/2748336
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2748039
type: Answer
accepted answer of: http://stackoverflow.com/q/2748039
has comment: http://stackoverflow.com/comment/2801100
has comment: http://stackoverflow.com/comment/2791474
score: 1
has body: What about using an abstract super class for the Channel and a TABLE_PER_CLASS inheritance strategy? Something like this: @Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public abstract class Channel { @Id @GeneratedValue private Long id; // ... } @Entity public class Fax extends Channel { } @Entity public class Email extends Channel { } @Entity public class Delivery { @Id @GeneratedValue private Long id; @OneToOne private Channel channel; // ... }
upvote count: 1

http://stackoverflow.com/a/2622794
has body: You want to match a single character and then that character repeated three more times: ([a-z])\1{3} Note: In Java you need to escape the backslashes inside your regular expressions. Update: The reason why it isn't doing what you want is because you are using the method matches which requires that the string exactly matches the regular expression, not just that it contains the regular expression. To check for containment you should instead use the Matcher class. Here is some example code: import java.util.regex.Pattern; import java.util.regex.Matcher; class Program { public static void main(String[] args) { Pattern pattern = Pattern.compile("([a-z])\\1{3}"); Matcher matcher = pattern.matcher("asdffffffasdf"); System.out.println(matcher.find()); } } Result: true
type: Answer
score: 25
downvote count: 0
answers question: http://stackoverflow.com/q/2622776
upvote count: 25

http://stackoverflow.com/q/2657298
tagged with: java
has comment: http://stackoverflow.com/comment/2674253
has comment: http://stackoverflow.com/comment/3902502
has answer: http://stackoverflow.com/a/2658300
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/2674334
has body: I just started learning C++ (coming from Java) and am having some serious problems with doing anything :P Currently, I am attempting to make a linked list, but must be doing something stupid cause I keep getting "void value not ignored as it ought to be" compile errors (I have it marked where it is throwing it below). If anyone could help me with what I'm doing wrong, i would be very grateful :) Also, I am not used to having the choice of passing by reference, address, or value, and memory management in general (currently I have all my nodes and the data declared on the heap). If anyone has any general advice for me, I also wouldn't complain :P Key code from LinkedListNode.cpp LinkedListNode::LinkedListNode() { //set next and prev to null pData=0; //data needs to be a pointer so we can set it to null for //for the tail and head. pNext=0; pPrev=0; } /* * Sets the 'next' pointer to the memory address of the inputed reference. */ void LinkedListNode::SetNext(LinkedListNode&amp; _next) { pNext=&amp;_next; } /* * Sets the 'prev' pointer to the memory address of the inputed reference. */ void LinkedListNode::SetPrev(LinkedListNode&amp; _prev) { pPrev=&amp;_prev; } //rest of class Key code from LinkedList.cpp #include "LinkedList.h" LinkedList::LinkedList() { // Set head and tail of linked list. pHead = new LinkedListNode(); pTail = new LinkedListNode(); /* * THIS IS WHERE THE ERRORS ARE. */ *pHead-&gt;SetNext(*pTail); *pTail-&gt;SetPrev(*pHead); } //rest of class
has comment: http://stackoverflow.com/comment/2674259
downvote count: 0
tagged with: pointers
linked to: http://stackoverflow.com/q/388242
possible better answer: http://stackoverflow.com/a/2658300
favorite count: 0
accepted answer: http://stackoverflow.com/a/2657335
upvote count: 2
tagged with: parameter-passing
tagged with: c++
has answer: http://stackoverflow.com/a/2657335
score: 2
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2674296
tagged with: linked-list
has title: Learning C++ from Java , trying to make a linked list

http://stackoverflow.com/q/2727271
tagged with: spring
downvote count: 0
score: 1
tagged with: java
has body: Can anyone help in architecture design of one of my complex application. Requirement : In web based application, we need to generate Excel kind of report as HTML page and after that we need to perform different kinds of operations like Add manual rows Delete rows Edit rows adding comments based on each cell viewing the added comments. attaching the file based on each cell viewing the attached file. Collapsible functionality for some of rows In the process of design we have come up with DB design and application framework is Spring. and for Web not yet finalized. what is the best approach to implement this kind of UI? --JSF?(keep in mind we need to Excel operations like above mentioned operations) -- Any reporting tool which will provide editing functionality? Please suggest me How can we do it? and what is the best technology for it? or is there any reporting tools?
type: Question
has answer: http://stackoverflow.com/a/2727372
has title: Need help in Architecture design in java
has answer: http://stackoverflow.com/a/2727332
answer count: 3
upvote count: 1
favorite count: 0
type: UnansweredQuestion
tagged with: architecture
has answer: http://stackoverflow.com/a/2727444

http://stackoverflow.com/comment/84515424
type: Comment
comment on: http://stackoverflow.com/a/13017949
has text: I know it's just an example, but HTML can be embedded in markdown. It's how Jekyll works.
type: AnswerComment
score: 0

http://stackoverflow.com/q/2746807
possible better answer: http://stackoverflow.com/a/2747475
has answer: http://stackoverflow.com/a/2747475
has answer: http://stackoverflow.com/a/2746870
tagged with: emacs
type: Question
has answer: http://stackoverflow.com/a/4767811
type: AnsweredQuestion
tagged with: enums
tagged with: java
has body: I'm having a problem with Emacs's indentation of Java enums. While it indents the first member OK, it wants to give all of the rest of the static enum members an additional level of indentation. It looks like this: class MyClass { public enum MyEnum { ONE(1), //good TWO(2), // not good! THREE(3), FOUR(4); private final int value; } } When I run C-c C-s on the line that opens the enum, it gives me ((inclass 1) (topmost-intro 1)), which doesn't seem quite right -- it seems like it should be giving brace-list-open. When I run it on the first enum member, it gives me ((defun-block-intro 21)), which is definitely not right. Every subsequent member gives (statement-cont 50). I'm in java-mode and I'm using the java style of indentation. Does anyone know what the problem might be?
score: 4
upvote count: 4
accepted answer: http://stackoverflow.com/a/2746870
has answer: http://stackoverflow.com/a/2747281
tagged with: indentation
has title: Emacs enum indentation
downvote count: 0
favorite count: 0
answer count: 4

http://stackoverflow.com/a/15057845
type: Answer
upvote count: 3
answers question: http://stackoverflow.com/q/2761543
score: 3
has body: There are several techniques that may need to be used in conjunction with one another to create and manipulate queries for large data-sets where memory is a limitation: Use setFetchSize(some value, maybe 100+) as the default (via JDBC) is 10. This is more about performance and is the single biggest related factor thereof. Can be done in JPA using queryHint available from provider (Hibernate, etc). There does not (for whatever reason) seem to be a JPA Query.setFetchSize(int) method. Do not try to marshall the entire result-set for 10K+ records. Several strategies apply: For GUIs, use paging or a framework that does paging. Consider Lucene or commercial searching/indexing engines (Endeca if the company has the money). For sending data somewhere, stream it and flush the buffer every N records to limit how much memory is used. The stream may be flushed to a file, network, etc. Remember that underneath, JPA uses JDBC and JDBC keeps the result-set on the Server, only fetching N-rows in a row-set group at a time. This break-down can be manipulated to facilitate flushing data in groups. Consider what the use-case is. Typically, an application is trying to answer questions. When the answer is to weed through 10K+ rows, then the design should be reviewed. Again, consider using indexing engines like Lucene, refine the queries, consider using BloomFilters as contains check caches to find needles in haystacks without going to the database, etc.
downvote count: 0

http://stackoverflow.com/comment/2618746
score: 0
type: AnswerComment
type: Comment
has text: oh.. I thought prepareStatement was just for update queries. thank you very much
comment on: http://stackoverflow.com/a/2608469

http://stackoverflow.com/q/2784267
upvote count: 12
answer count: 5
type: UnansweredQuestion
score: 11
has answer: http://stackoverflow.com/a/2784512
has title: Java Optimization String vs Char Arrays
tagged with: java
has comment: http://stackoverflow.com/comment/2820196
downvote count: 1
has answer: http://stackoverflow.com/a/2784454
type: Question
tagged with: arrays
has answer: http://stackoverflow.com/a/2784341
has answer: http://stackoverflow.com/a/2784351
has answer: http://stackoverflow.com/a/2784289
tagged with: optimization
has body: In a program I am writing I am doing a lot of string manipulation. I am trying to increase performance and am wondering if using char arrays would show a decent performance increase. Any suggestions?
tagged with: string
favorite count: 0

http://stackoverflow.com/comment/23747093
type: AnswerComment
comment on: http://stackoverflow.com/a/2748723
has text: The PendingIntent.getBroadcast is very important!
type: Comment
score: 0

http://stackoverflow.com/a/2716011
score: 13
answers question: http://stackoverflow.com/q/2715983
has body: You could also get a null, an ArrayOutOfBoundsException, or something left up to the implementation. HashMaps have been observed to go into an infinite loop in production systems. You don't really need to know what might go wrong, just don't do it. You could use Vector, but it tends to work out the interface is not rich enough. You will probably find that you want a different data structure in most cases.
has comment: http://stackoverflow.com/comment/87346213
downvote count: 0
type: Answer
upvote count: 13

http://stackoverflow.com/q/2661224
score: 0
has answer: http://stackoverflow.com/a/2661258
has comment: http://stackoverflow.com/comment/2678522
has answer: http://stackoverflow.com/a/2661256
type: UnansweredQuestion
has title: Simple Java web application on Tomcat
tagged with: web-applications
tagged with: spring
has comment: http://stackoverflow.com/comment/2678551
has comment: http://stackoverflow.com/comment/2678652
has comment: http://stackoverflow.com/comment/2678545
has comment: http://stackoverflow.com/comment/2678503
has comment: http://stackoverflow.com/comment/2678584
tagged with: java
has body: If we only need to graphically authorize a user, view a few tables representation (from database), ability to change data in the database visually what tools to use to write such a web application that will run on Tomcat? What framework allows to do that in the most straightforward, easy-to-manage and elegant way?
has comment: http://stackoverflow.com/comment/2678508
tagged with: servlets
type: Question
linked to: http://stackoverflow.com/q/1960280
answer count: 3
has answer: http://stackoverflow.com/a/5101078
tagged with: tomcat
linked to: http://stackoverflow.com/q/2631130

http://stackoverflow.com/comment/76103643
type: Comment
score: 1
has text: Clever. :) I worked on a code base in C that did something similar by shifting a pointer to a global `void nil()` method. Seems like the same idea!
comment on: http://stackoverflow.com/a/2666152
type: AnswerComment

http://stackoverflow.com/a/2608042
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2597452
has body: I ended up rewriting the queries so this was no longer an issue, but before that I created this class which seemed to work but your mileage may vary: public class CriteriaContainer implements Serializable { private static final long serialVersionUID = 1L; private Criteria criteria = null; private DetachedCriteria detachedCriteria = null; public CriteriaContainer(Criteria criteria) { this.criteria = criteria; this.detachedCriteria = null; } public CriteriaContainer(DetachedCriteria detachedCriteria) { this.detachedCriteria = detachedCriteria; this.criteria = null; } /** * @param eq * @return */ public CriteriaContainer add(final Criterion eq) { if (criteria != null) { criteria.add(eq); } else if (detachedCriteria != null) { detachedCriteria.add(eq); } return this; } /** * @return the criteria */ public Criteria getCriteria() { return criteria; } /** * @return the detachedCriteria */ public DetachedCriteria getDetachedCriteria() { return detachedCriteria; } /** * @param associationPath * @param alias * @return */ public CriteriaContainer createAlias(final String associationPath, final String alias) { if (criteria != null) { criteria.createAlias(associationPath, alias); } else if (detachedCriteria != null) { detachedCriteria.createAlias(associationPath, alias); } return this; } /** * @param distinctRootEntity * @return */ public CriteriaContainer setResultTransformer(final ResultTransformer transformer) { if (criteria != null) { criteria.setResultTransformer(transformer); } else if (detachedCriteria != null) { detachedCriteria.setResultTransformer(transformer); } return this; } } criteria = addBasicCriteria(new CriteriaContainer(criteria), ...).getCriteria() detachedCriteria = addBasicCriteria(new CriteriaContainer(detachedCriteria), ...).getDetachedCriteria()
type: Answer
upvote count: 1
score: 1
accepted answer of: http://stackoverflow.com/q/2597452

http://stackoverflow.com/a/51387461
answers question: http://stackoverflow.com/q/2649145
score: 0
type: Answer
has body: Load the object in persistence context and call merge if exist and save if not exist. Employee emp = new Employee(); //set emp attribute and members. Session session = ... Transaction transaction = ... Employee db = (Employee) session.get(Employee .class,emp.getId()); if(db != null) session.merge(emp); else session.save(emp); /*session.saveOrUpdate(emp); This will delete the join table and reinsert entry again*/ transaction.commit(); session.close();

http://stackoverflow.com/comment/18093132
type: Comment
has text: your restful api can do whatever you want. For pagination just add a start and end or offset and page size or whatever you need to get the appropriate results.
comment on: http://stackoverflow.com/a/8977522
type: AnswerComment
score: 0

http://stackoverflow.com/a/2646469
has body: The two statements are not exactly mutually exclusive. The Class will only exist in the current ClassLoader's set of loaded classes if the parent ClassLoader had previously failed to find the Class. So, When requested to find (the external data that describes) a class or resource, a ClassLoader instance will delegate the search for (the external data that describes) the class or resource to its parent class loader before attempting to find (the external data that describes) the class or resource itself. Which does not prevent it from short-circuiting if it knows its parent can't find the class but it can (as shown by it previously loading the class)
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/2642606
downvote count: 0

http://stackoverflow.com/a/2723856
has body: You have your grouping wrong. The | needs to be inside the parentheses: GET.*?(\.flv|\.mp4|\.avi).*? I'm also not sure why you have the ? on the end of the final .*?. In most languages, the ? here makes the * non-greedy, so it matches as few characters as possible, while not preventing the pattern from matching. In this case that would mean it matches no characters, since nothing follows it, so you probably want to remove that final ?. GET .*?(\.flv|\.mp4|\.avi).*
type: Answer
upvote count: 5
has comment: http://stackoverflow.com/comment/2750902
has comment: http://stackoverflow.com/comment/2759964
answers question: http://stackoverflow.com/q/2723765
has comment: http://stackoverflow.com/comment/2754998
has comment: http://stackoverflow.com/comment/2752035
score: 5
downvote count: 0

http://stackoverflow.com/a/2727541
upvote count: 10
score: 10
downvote count: 0
has body: Anything that you print to System.out will go to "standard out", and while you can redirect standard out to a file and compare it, what have you, that is very inflexible. Additionally, you cannot filter what goes to standard out if you use System.out... everything will be printed. With log4j, you can set different logging levels, so that logging messages that are below a certain severity/importance threshold are not printed (e.g. if you change the logging level to WARN, then DEBUG and INFO messages will not be displayed anymore). Additionally, log4j allows logging to be controlled on a class-by-class basis, whereas System.out can only be controlled at the granularity of the entire application (if you redirect System.out, you redirect it for the entire program). By contrast, each logger in log4j can be given a different appender. In addition, you can give a log4j logger multiple appenders (so that it goes the system logger, and over the network, for example). You can even have a log4j logger append to a StringBuilder, so that you can easily read what was written. And while System.out can be redirected, this redirection tends to be fairly limited; System.out can be redirected to a file or to a pipe (to another program), but you wouldn't be able to redirect it to a URL, for example; by contrast, it would be very easy to create an appender that transmits logging messages using HTTP POST.
answers question: http://stackoverflow.com/q/2727500
type: Answer

http://stackoverflow.com/q/2620117
type: UnansweredQuestion
score: 3
linked to: http://stackoverflow.com/q/1460371
tagged with: java
has title: error while opening browser with selenium RC using JUnit
tagged with: selenium-rc
type: Question
answer count: 1
has body: I am getting following error while opening browser with selenium RC using JUnit. Plz help. com.thoughtworks.selenium.SeleniumException: XHR ERROR: URL = http://www.google.com/ Response_Code = 403 Error_Message = Forbidden at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:97) at com.thoughtworks.selenium.HttpCommandProcessor.doCommand
favorite count: 0
upvote count: 3
tagged with: junit
has answer: http://stackoverflow.com/a/2620199
downvote count: 0

http://stackoverflow.com/a/2692668
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/36835976
accepted answer of: http://stackoverflow.com/q/2692643
has comment: http://stackoverflow.com/comment/2714835
answers question: http://stackoverflow.com/q/2692643
upvote count: 7
has body: You can fiddle with Eclipse's display in the "Errors/Warnings" section of preferences, but Java requires that you have files in the correct folder to match their package, so it won't be able to build
score: 7
has comment: http://stackoverflow.com/comment/2714673
type: AcceptedAnswer

http://stackoverflow.com/comment/2837222
has text: Since Tibco RV is a JMS implementaton, I assume you mean Hessian used for messaging as part of Resin as opposed to the Hessian binary web services protocol (http://hessian.caucho.com/)?
comment on: http://stackoverflow.com/q/2719545
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/2786511
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2755044
type: Comment
has text: If you're doing `replaceAll`, might as well do it without the `Arrays.toString/toCharArray`: http://stackoverflow.com/questions/2753313/write-a-program-that-allows-the-user-to-enter-a-string-and-then-prints-the-letter/2753331#2753331

http://stackoverflow.com/comment/48910796
type: AnswerComment
has text: but does `int a = -1; b = +a` result in `b = 1`?
type: Comment
comment on: http://stackoverflow.com/a/2624541
score: 0

http://stackoverflow.com/a/49801128
upvote count: 2
has body: Here's a one-liner that will do it: HashMap&lt;String, Object&gt; myMap = gson.fromJson(yourJson, new TypeToken&lt;HashMap&lt;String, Object&gt;&gt;(){}.getType());
answers question: http://stackoverflow.com/q/2779251
type: Answer
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/109231088

http://stackoverflow.com/q/2703971
has answer: http://stackoverflow.com/a/2704011
has title: Java, LinkedList of Strings. Insert in alphabetical order
tagged with: insert
has comment: http://stackoverflow.com/comment/2728822
favorite count: 0
upvote count: 2
has answer: http://stackoverflow.com/a/2704054
accepted answer: http://stackoverflow.com/a/2704011
type: AnsweredQuestion
tagged with: linked-list
has answer: http://stackoverflow.com/a/2703981
tagged with: java
has body: I have a simple linked list. The node contains a string (value) and an int (count). In the linkedlist when I insert I need to insert the new Node in alphabetical order. If there is a node with the same value in the list, then I simply increment the count of the node. I think I got my method really screwed up. public void addToList(Node node){ //check if list is empty, if so insert at head if(count == 0 ){ head = node; head.setNext(null); count++; } else{ Node temp = head; for(int i=0; i&lt;count; i++){ //if value is greater, insert after if(node.getItem().getValue().compareTo(temp.getItem().getValue()) &gt; 0){ node.setNext(temp.getNext()); temp.setNext(node); } //if value is equal just increment the counter else if(node.getItem().getValue().compareTo(temp.getItem().getValue()) == 0){ temp.getItem().setCount(temp.getItem().getCount() + 1); } //else insert before else{ node.setNext(temp); } } } } Ok so this is inserting all my strings, but not in alphabetical order. Do you see any error? public Node findIsertionPoint(Node head, Node node){ if( head == null) return null; Node curr = head; while( curr != null){ if( curr.getValue().compareTo(node.getValue()) == 0) return curr; else if( curr.getNext() == null || curr.getNext().getValue().compareTo(node.getValue()) &gt; 0) return curr; else curr = curr.getNext(); } return null; } public void insert(Node node){ Node newNode = node; Node insertPoint = this.findIsertionPoint(this.head, node); if( insertPoint == null) this.head = newNode; else{ if( insertPoint.getValue().compareTo(node.getValue()) == 0) insertPoint.getItem().incrementCount(); else{ newNode.setNext(insertPoint.getNext()); insertPoint.setNext(newNode); } } count++; }
type: Question
has answer: http://stackoverflow.com/a/2704039
score: 2
has answer: http://stackoverflow.com/a/2704022
has answer: http://stackoverflow.com/a/2704006
downvote count: 0
answer count: 6
possible better answer: http://stackoverflow.com/a/2704039

http://stackoverflow.com/q/2725878
upvote count: 1
has answer: http://stackoverflow.com/a/2725929
type: AnsweredQuestion
has title: Is it possible that EDT violations cause NullPointerException in an external software?
tagged with: java
accepted answer: http://stackoverflow.com/a/2725929
type: Question
tagged with: api
downvote count: 0
answer count: 1
has comment: http://stackoverflow.com/comment/2752763
favorite count: 0
tagged with: edt
tagged with: nullpointerexception
score: 1
has body: I have a Java software that was recently integrated into another Java software (which I will call "external" software). We use listeners and call back mechanisms for "communication" between two softwares. Creators of the "external" software say that they get a NullPointerException because of some EDT violations in my code. Can it be the case?

http://stackoverflow.com/q/2636129
tagged with: exception
possible better answer: http://stackoverflow.com/a/2636476
linked to: http://stackoverflow.com/q/3137944
accepted answer: http://stackoverflow.com/a/2636147
tagged with: constructor
has answer: http://stackoverflow.com/a/2636831
upvote count: 7
has answer: http://stackoverflow.com/a/2636147
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2636476
score: 7
tagged with: java
has body: In C++, the lifetime of an object begins when the constructor finishes successfully. Inside the constructor, the object does not exist yet. Q: What does emitting an exception from a constructor mean? A: It means that construction has failed, the object never existed, its lifetime never began. [source] My question is: Does the same hold true for Java? What happens, for example, if I hand this to another object, and then my constructor fails? Foo() { Bar.remember(this); throw new IllegalStateException(); } Is this well-defined? Does Bar now have a reference to a non-object?
type: Question
has title: Exceptions in constructors
answer count: 3
downvote count: 0
favorite count: 0

http://stackoverflow.com/comment/16189490
type: Comment
type: QuestionComment
has text: [Apache POI](http://poi.apache.org/)
comment on: http://stackoverflow.com/q/2604451
score: 0

http://stackoverflow.com/a/2640301
answers question: http://stackoverflow.com/q/2640231
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/12673929
type: Answer
has comment: http://stackoverflow.com/comment/4833972
has comment: http://stackoverflow.com/comment/22186396
accepted answer of: http://stackoverflow.com/q/2640231
score: 3
downvote count: 11
upvote count: 14
has comment: http://stackoverflow.com/comment/22188590
has body: getElementsByTagName always operates in the context of element it is called on. If called on Element, only child elements by the given tag name would be accessed. I think you are confusing this with Document object (org.w3c.dom.Document) getElementsByTagName method, then all elements by the given tag name in the document will be returned.
has comment: http://stackoverflow.com/comment/26456299

http://stackoverflow.com/comment/88527662
type: AnswerComment
comment on: http://stackoverflow.com/a/2647000
has text: New links have been added.
type: Comment
score: 0

http://stackoverflow.com/q/2722685
has title: Java RegEx API "Look-behind group does not have an obvious maximum length near index ..."
score: 0
answer count: 1
has comment: http://stackoverflow.com/comment/2749044
tagged with: negative-lookbehind
type: UnansweredQuestion
has body: I'm on to some SQL where clause parsing and designed a working RegEx to find a column outside string literals using "Rad Software Regular Expression Desginer" which is using the .NET API. To make sure the designed RegEx works with Java too, I tested it by using the API of course (1.5 and 1.6). But guess what, it won't work. I got the message "Look-behind group does not have an obvious maximum length near index 28". The string that I'm trying to get parsed is Column_1='test''the''stuff''all''day''long' AND Column_2='000' AND TheVeryColumnIWantToFind = 'Column_1=''test''''the''''stuff''''all''''day''''long'' AND Column_2=''000'' AND TheVeryColumnIWantToFind = '' TheVeryColumnIWantToFind = '' AND (Column_3 is null or Column_3 = ''Not interesting'') AND ''1'' = ''1''' AND (Column_3 is null or Column_3 = 'Still not interesting') AND '1' = '1' As you may have guessed, I tried to create some kind of worst case to ensure the RegEx won't fail on more complicated SQL where clauses. The RegEx itself looks like this (?i:(?&lt;!=\s*'(?:[^']|(?:''))*)((?&lt;=\s*)TheVeryColumnIWantToFind(?=(?:\s+|=)))) I'm not sure if there is a more elegant RegEx (there'll most likely be one), but that's not important right now as it does the trick. To explain the RegEx in a few words: If it finds the column I'm after, it does a negative look-behind to figure out if the column name is used in a string literal. If so, it won't match. If not, it'll match. Back to the question. As I mentioned before, it won't work with Java. What will work and result in what I want? I found out, that Java does not seem to support unlimited look-behinds but still I couldn't get it to work. Isn't it right that a look-behind is always putting a limit up on itself from the search offset to the current search position? So it would result in something like "position - offset"?
tagged with: regex
has answer: http://stackoverflow.com/a/2729425
tagged with: java
has comment: http://stackoverflow.com/comment/2748990
type: Question

http://stackoverflow.com/q/2603745
has answer: http://stackoverflow.com/a/2603839
answer count: 1
has title: GAE Entity Groups/Transaction
type: UnansweredQuestion
tagged with: google-app-engine
has comment: http://stackoverflow.com/comment/2613412
tagged with: transactions
tagged with: java
has body: Say you have a Client Buying Card object and a product object. When the client chooses the buy opition you create the object and then add a product. It should be transactional but it's not on the same entity group as the product and the card already been persisted, isn't it? Is there any way to overcome this simple scenario safely and easily? here's a code sample: Transaction tx = pm.currentTransaction(); tx.begin(); Product prod = pm.getObjectById(Product.class, "TV"); prod.setReserved(true); pm.makePersistent(prod); Card card = pm.getObjectById(Card.class, "user123"); /// &lt;--- will thorw an exception as card and prod aren't on the same entity group card.setProd(prod); pm.makePersistent(card); try { tx.commit(); break; }
type: Question
score: 0

http://stackoverflow.com/a/2717473
accepted answer of: http://stackoverflow.com/q/2717459
score: 3
downvote count: 0
answers question: http://stackoverflow.com/q/2717459
has body: So you have a class C network... just attempt to open the particular server applications port on each IP address between 1 and 254. If you want to get fancy, you can do some checks to verify that if the port actually opens, it does what you expect for that application.
has comment: http://stackoverflow.com/comment/2744068
upvote count: 3
type: AcceptedAnswer
type: Answer
has comment: http://stackoverflow.com/comment/2744031

http://stackoverflow.com/comment/2706501
type: QuestionComment
score: 6
comment on: http://stackoverflow.com/q/2686092
has text: What's even better is that two HashMaps that are equal can still have different orderings. They can do it *even if they have the same history of adds/removes* (different capacities would do it).
type: Comment

http://stackoverflow.com/a/2677886
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2677843
type: Answer
answers question: http://stackoverflow.com/q/2677843
has body: With the second example you state very clearly that both conditions are mutually exclusive. With the first one, it is not so clear, and in the (unlikely) event that an assignment to input is added between both ifs, the logic would change. Suppose someone in the future adds input = 0 before the second if. Of course this is unlikely to happen, but if we are talking about maintainability here, if-else says clearly that there are mutually exclusive conditions, while a bunch of ifs don't, and they are not so dependent between each other as are if-else blocks. edit:Now that I see, in this particular example, the return clause forces the mutual exclusivity, but again, we're talking about maintainability and readability. Anyway, about performance, if this is coded in Java you shouldn't care for performance of a couple of if blocks, if it were embedded C in a really slow hardware, maybe, but certainly not with java.
score: 9
upvote count: 9

http://stackoverflow.com/comment/16229390
has text: Works great thank you. When user clicks the pin on the map, it opens page which consists of Maps, Direction and Call. I wish there is a way to make call button available as well.
type: Comment
comment on: http://stackoverflow.com/a/4433117
score: 0
type: AnswerComment

http://stackoverflow.com/comment/2767949
score: 0
has text: Then it seems you can't spit out binary files to the console and expect them to behave. The console does not accurately copy at a byte level, which is what you want to do.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2732639

http://stackoverflow.com/a/42001838
answers question: http://stackoverflow.com/q/2763416
score: 2
downvote count: 0
upvote count: 2
has body: As said Jarle you have to use LevelMatchFilter. I will demonstrate it with one simple exam: log4j.rootLogger = WARN, admin log4j.appender.admin=org.apache.log4j.rolling.RollingFileAppender log4j.appender.admin.rollingPolicy = org.apache.log4j.rolling.TimeBasedRollingPolicy log4j.appender.admin.rollingPolicy.FileNamePattern = Files\\TestLevels-%d{dd-MM-yyy}.txt log4j.appender.admin.layout = org.apache.log4j.PatternLayout log4j.appender.admin.layout.ConversionPattern = Date: %d{dd-MM-yyyy} Time: %d{HH:mm:ss} Message [%m]%n log4j.appender.admin.filter.01=org.apache.log4j.varia.LevelMatchFilter log4j.appender.admin.filter.01.LevelToMatch=FATAL log4j.appender.admin.filter.01.AcceptOnMatch=false log4j.appender.admin.filter.02=org.apache.log4j.varia.LevelMatchFilter log4j.appender.admin.filter.02.LevelToMatch=ERROR log4j.appender.admin.filter.02.AcceptOnMatch=true log4j.appender.admin.filter.03=org.apache.log4j.varia.LevelMatchFilter log4j.appender.admin.filter.03.LevelToMatch=WARN log4j.appender.admin.filter.03.AcceptOnMatch=false In my source I append only ERROR messages to file with name TestLevels.txt
type: Answer

http://stackoverflow.com/comment/2662837
comment on: http://stackoverflow.com/a/2647253
score: 2
type: AnswerComment
has text: If this is something that must be done frequently and the time it takes is a performance drain, than a simple List is the wrong structure to use. Depending on what you're trying to do, perhaps you could modify Item to include a count, and then on adds search for the item and increment the count. Or create another structure to hold the counts. Etc. There's no magic way to search a list faster than a sequential traversal.
type: Comment

http://stackoverflow.com/comment/138712097
type: Comment
type: QuestionComment
has text: I suppose you mean you "lose" `a` not `b`, iff `a==0`.
comment on: http://stackoverflow.com/q/2674707
score: 0

http://stackoverflow.com/q/2695855
tagged with: grails
tagged with: groovy
answer count: 1
has body: I have a grails project with some additional java source files under src/java folder. When compiling/running the server, the files under that directory get compiled into the project's target folder, together with all other groovy/grails classes. So far so good. However, when I try to load one of the java source files (from src/java) using reflection (Class.forName to be exact), a ClassNotFoundException gets thrown. What is peculiar about the whole thing is that if I copy that same class from project's target/ folder into the following location (on windows): &lt;myuser&gt;\.grails\1.2.2\projects\&lt;MyProjectName&gt;\resources then no exception gets thrown and the corresponding class is loaded fine. This seems to indicate to me that the integrated grails server only looks at classes within the user's dynamically generated project folder, and not the actual project's target folder. Is my understanding correct? Is there a way to force grails to copy certain classfiles from target/ folder into the resources folder within the user dir? Is there a different way to load the classfiles using reflection? I was looking at using the grailsApplication's classloader but that didn't seem to work either. Any tips would be more than welcome. Thanks a lot in advance!
type: AnsweredQuestion
tagged with: reflection
has answer: http://stackoverflow.com/a/2696078
score: 0
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/2696078
has title: Grails target folder doesn't appear to be on application's classpath

http://stackoverflow.com/q/2778256
tagged with: aes
score: 0
type: UnansweredQuestion
has title: how to convert byte array to key format?
type: Question
tagged with: java
has answer: http://stackoverflow.com/a/15827736
has answer: http://stackoverflow.com/a/2778343
answer count: 2
tagged with: arrays
tagged with: key
has body: i would like to know how to convert byte array into key. i am doing an AES encryption/decryption. instead of generating a key, i would like to use my generated byte array. byte[] clientCK = Milenage.f3(sharedSecret16, RANDbytes, opc); let say i have a byte array called clientCK, stated above. i want to use it in AES encryption as shown below. Cipher c = Cipher.getInstance("AES"); c.init(Cipher.ENCRYPT_MODE, key); byte[] encValue = c.doFinal(valueToEnc.getBytes()); String encryptedValue = new BASE64Encoder().encode(encValue); therefore, i need to convert that byte array clientCK into key format. please help.
has comment: http://stackoverflow.com/comment/10249172

http://stackoverflow.com/comment/2626526
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2615108
type: Comment
has text: We don't have any calls to `runFinalizersOnExit`, nor do we have a `SecurityManager`, so I think these are not the cause.

http://stackoverflow.com/comment/2682775
comment on: http://stackoverflow.com/q/2664687
type: Comment
type: QuestionComment
has text: How many concurrent clients do you need to support ?
score: 0

http://stackoverflow.com/q/2728893
has answer: http://stackoverflow.com/a/2737927
accepted answer: http://stackoverflow.com/a/2737927
has title: Error in retrieving the name field in symbian using J2ME
has body: I have added the firstname, middlename, lastname, suffix, prefix in symbian and now i want to retrieve each of this attributes of name. I am getting the firstname and lastname together by if(contactlist.isSupportedField(Contact.FORMATTED_NAME) &amp;&amp; contact.countValues(Contact.FORMATTED_NAME)&gt;0) { mycontact.setName(contact.getString(Contact.FORMATTED_NAME, 0)); }
tagged with: java
type: Question
upvote count: 1
answer count: 1
favorite count: 0
tagged with: java-me
downvote count: 0
score: 1
type: AnsweredQuestion

http://stackoverflow.com/q/2642144
tagged with: java
linked to: http://stackoverflow.com/q/37062784
linked to: http://stackoverflow.com/q/2576353
answer count: 2
possible better answer: http://stackoverflow.com/a/2642263
has answer: http://stackoverflow.com/a/2642263
tagged with: user-interface
downvote count: 0
has answer: http://stackoverflow.com/a/2642183
favorite count: 0
has comment: http://stackoverflow.com/comment/2657037
score: 2
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2657003
upvote count: 2
has title: Having a problem getting my ActionListeners, Handlers, and GUI to communicate
accepted answer: http://stackoverflow.com/a/2642183
tagged with: swing
has body: So I am trying to get my GUI to work. When I run the code below, it does nothing, and I'm sure I'm probably just doing something dumb, but I am completely stuck... public void actionPerformed(ActionEvent e){ UI.getInstance().sS++; if((UI.getInstance().sS %2) != 0){ UI.getInstance().startStop.setName("STOP"); UI.getInstance().change.setEnabled(false); }else if(UI.getInstance().sS%2 == 0){ UI.getInstance().startStop.setName("START"); UI.getInstance().change.setEnabled(true); } } public void setStartListener(StartHandler e){ this.startStop.addActionListener(e); } sS is an int that increments every time the button startStop is clicked. change is also a button.
type: Question

http://stackoverflow.com/comment/2741632
score: 0
type: AnswerComment
has text: +1 when you've got what is secretly a three-valued variable, Boolean is definitely the right way to go.
comment on: http://stackoverflow.com/a/2716021
type: Comment

http://stackoverflow.com/a/2756672
has comment: http://stackoverflow.com/comment/2788212
has body: The best advise I can give you is to download an IDE to get started. BlueJ is an IDE aimed at getting people started using java and is used in many universities world wide. take a look at www.bluej.org and you should be up and running in seconds. Karl
downvote count: 2
type: Answer
answers question: http://stackoverflow.com/q/2756387
upvote count: 0
score: -2

http://stackoverflow.com/comment/2688222
type: AnswerComment
comment on: http://stackoverflow.com/a/2660956
score: 0
type: Comment
has text: I'm saved sessionId to temporary database table when running the applet from web-tier and then i just compare it in EJB from db.

graph
tags question: http://stackoverflow.com/q/2625620
tags question: http://stackoverflow.com/q/2784820
tag name: graph
tags question: http://stackoverflow.com/q/2703682
tags question: http://stackoverflow.com/q/2712609
tags question: http://stackoverflow.com/q/2689987
tags question: http://stackoverflow.com/q/2602892
tags question: http://stackoverflow.com/q/2626594
tags question: http://stackoverflow.com/q/2769646
type: Tag
tags question: http://stackoverflow.com/q/2634647
tags question: http://stackoverflow.com/q/2656641
tags question: http://stackoverflow.com/q/2672291
tags question: http://stackoverflow.com/q/2701651
tags question: http://stackoverflow.com/q/2652404

http://stackoverflow.com/q/2598162
type: Question
downvote count: 0
tagged with: javascript
answer count: 1
tagged with: java-me
favorite count: 0
has body: I am developing an application using J2ME to send the GPS coordinates received to the server and i am new to developing client server application. Everything works fine with the use of Nokia N97mini or E71. But when i tried it on HTC HD2, i get the exception from the server. I am using Netbeans 6.5.1 GlassFish V2 as Server. I have no idea why this error occurs only on the HTC HD2. Any help will be greatly appreciated. Thanks... Below is the error message: StandardWrapperValve[FindHospitalServlet]: PWC1406: Servlet.service() for servlet FindHospitalServlet threw exception java.io.IOException: Invalid chunk header at org.apache.coyote.http11.filters.ChunkedInputFilter.doRead(ChunkedInputFilter.java:171) at org.apache.coyote.http11.InternalInputBuffer.doRead(InternalInputBuffer.java:719) at org.apache.coyote.Request.doRead(Request.java:482) at org.apache.coyote.tomcat5.InputBuffer.realReadBytes(InputBuffer.java:342) at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:378) at org.apache.coyote.tomcat5.InputBuffer.readByte(InputBuffer.java:351) at org.apache.coyote.tomcat5.CoyoteInputStream.read(CoyoteInputStream.java:159) at java.io.DataInputStream.readUnsignedShort(DataInputStream.java:320) at java.io.DataInputStream.readUTF(DataInputStream.java:572) at java.io.DataInputStream.readUTF(DataInputStream.java:547) at myPackage.FindHospitalServlet.doPost(FindHospitalServlet.java:28) at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:315) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648) at org.apach…
type: UnansweredQuestion
has title: PWC1406: Servlet.service() threw exception java.io.IOException: Invalid chunk header When client send data to server
has answer: http://stackoverflow.com/a/2599469
score: 3
upvote count: 3
tagged with: midp
tagged with: java
tagged with: servlets

http://stackoverflow.com/a/5870747
answers question: http://stackoverflow.com/q/2723019
score: 0
type: Answer
has body: socialauth is a java library that allows importing contacts from Google, Yahoo, Hotmail and from other providers too. http://code.google.com/p/socialauth/

http://stackoverflow.com/comment/55388272
comment on: http://stackoverflow.com/a/2784576
type: Comment
score: 0
type: AnswerComment
has text: you can use to compare int values like this "return o1.getDistance()-o2.getDistance();"

http://stackoverflow.com/comment/12398422
comment on: http://stackoverflow.com/a/2606673
has text: @foo on the contrary. Java offers the finally {} block.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/65429097
answers question: http://stackoverflow.com/q/2773824
score: -1
downvote count: 1
has body: The main difference between them you can find as follows: HashSet It does not allow duplicate keys. Even it is not synchronized, so this will have better performance. It allows a null key. HashSet can be used when you want to maintain a unique list. HashSet implements Set interface and it is backed by the hash table(actually HashMap instance). HashSet stores objects. HashSet doesn’t allow duplicate elements but null values are allowed. This interface doesn’t guarantee that order will remain constant over time. HashMap It allows duplicate keys. It is not synchronized, so this will have better performance. HashMap does not maintain insertion order. The order is defined by the Hash function. It is not Thread Safe It allows null for both key and value. It allows one null key and as many null values as you like. HashMap is a Hash table-based implementation of the Map interface. HashMap store object as key and value pair. HashMap does not allow duplicate keys but null keys and values are allowed. Ordering of the element is not guaranteed overtime.
type: Answer
upvote count: 0

http://stackoverflow.com/a/41849227
score: 3
answers question: http://stackoverflow.com/q/2780284
upvote count: 3
downvote count: 0
type: Answer
has body: public static ArrayList<String> getTablesList(Connection conn) throws SQLException { ArrayList<String> listofTable = new ArrayList<String>(); DatabaseMetaData md = conn.getMetaData(); ResultSet rs = md.getTables(null, null, "%", null); while (rs.next()) { if (rs.getString(4).equalsIgnoreCase("TABLE")) { listofTable.add(rs.getString(3)); } } return listofTable; }

http://stackoverflow.com/comment/96744091
comment on: http://stackoverflow.com/a/52325174
has text: Also, as to why they are flawed - see the description under binary trees: "Use default GC, use per node allocation or use a library memory pool." So, the top-performing C++ uses a custom memory pool (see the source), but you can't tailor the GC to the task at hand (and the Java just uses standard allocations) - completely flawed - I can probably tailor the GC a lot faster than a developer can write the custom memory pool. They don't show a C++ version that uses malloc/free or standard allocators/de-allocators for every node - they're not comparing apples to apples.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2768332
type: Comment
comment on: http://stackoverflow.com/a/2739668
has text: Cool! Thanks! i directly pasted in source packages folder and it worked like a charm :)
type: AnswerComment
score: 0

http://stackoverflow.com/a/2610223
accepted answer of: http://stackoverflow.com/q/2609948
type: Answer
upvote count: 2
score: 2
has body: I recently experimented with HtmlCleaner and CyberNekoHtml. CyberNekoHtml is a DOM/SAX parser that produces predictable results. HtmlCleaner is a tad faster, but quite often fails to produce accurate results. I would recommend CyberNekoHtml. CyberNekoHtml can do all of the things you mentioned. It is very easy to extract a list of all elements, and their attributes, for example. It would be possible to traverse the DOM tree building each element back into HTML if you wanted to reconstruct the page. There's a list of open source java html parsers here: http://java-source.net/open-source/html-parsers
answers question: http://stackoverflow.com/q/2609948
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/2784652
downvote count: 0
has body: I would like to parse this Gstring with groovy : Format type : Key, Value. def txt = """ &lt;Lane_Attributes&gt; ID,1 FovCount,600 FovCounted,598 ... &lt;/Lane_Attributes&gt; """ And get a map like : Map = [ID:1, FovCount:600, FovCounted:598] How can I : - extract text between tag and ?, - and convert to a map ?
tagged with: grails
has answer: http://stackoverflow.com/a/2784865
accepted answer: http://stackoverflow.com/a/2784865
tagged with: groovy
answer count: 3
possible better answer: http://stackoverflow.com/a/2784989
tagged with: regex
favorite count: 0
has answer: http://stackoverflow.com/a/2784989
type: AnsweredQuestion
score: 3
upvote count: 3
tagged with: java
has answer: http://stackoverflow.com/a/2788280
type: Question
has title: Parsing in groovy between two tags?

http://stackoverflow.com/a/2673105
answers question: http://stackoverflow.com/q/2667873
type: Answer
has body: Your function defines one parameter, but is called with 4. I assume there is a javascript error (check your JS console (firefox)). Get rid of the 3 unused parameters, and call it addClicp(param1)
has comment: http://stackoverflow.com/comment/2691929
score: 0
has comment: http://stackoverflow.com/comment/2691948

http://stackoverflow.com/a/2687499
answers question: http://stackoverflow.com/q/2686733
has body: The code @RequestMapping(method = RequestMethod.POST) is happening after the form is submitted, not before. In other words, when you do a form submission (HTTP POST) from your Spring Form, it's then calling that submit() method. To pass any objects to your JSP in Spring MVC, use a org.springframework.web.servlet.ModelAndView instance and call addObject on it. Then you can actually use plain-old JSTL tags to display the object. For example: &lt;c:out value="${standardizedAddress.streetLine}" /&gt;
score: 0
type: Answer

http://stackoverflow.com/q/2755338
favorite count: 0
has comment: http://stackoverflow.com/comment/2786674
upvote count: 2
has title: Servlet requests are executed sequentially for no apparent reason in Glassfish v3
tagged with: multithreading
has body: I'm using Glassfish 3 Web profile and can't get http workers to execute concurrently requests on a servlet. This is how i observed the problem. I've made a very simple servlet, that writes the current thread name to the standard output and sleep for 10 seconds : protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println(Thread.currentThread().getName()); try { Thread.sleep(10000); // 10 sec } catch (InterruptedException ex) { } } And when i'm running several simultaneous requests, I clearly see in the logs that the requests are sequentially executed (one trace every 10 seconds). INFO: http-thread-pool-8080-(2) (10 seconds later...) INFO: http-thread-pool-8080-(1) (10 seconds later...) INFO: http-thread-pool-8080-(2) etc. All my GF settings are untouched - it's the out-of-the-box config (the default thread pool is 2 threads min, 5 max if I recall properly). I really don't understand why the sleep() block all the others worker threads. Any insight would be greatly appreciated !
score: 2
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2755438
tagged with: glassfish-3
has comment: http://stackoverflow.com/comment/2786547
tagged with: java
possible better answer: http://stackoverflow.com/a/2755444
has answer: http://stackoverflow.com/a/2755444
type: Question
tagged with: jakarta-ee
answer count: 2
has comment: http://stackoverflow.com/comment/2786620
downvote count: 0
has comment: http://stackoverflow.com/comment/2786677
tagged with: servlets
has answer: http://stackoverflow.com/a/2755438

http://stackoverflow.com/q/2610113
possible better answer: http://stackoverflow.com/a/2611711
has answer: http://stackoverflow.com/a/2610533
tagged with: java
tagged with: hibernate
has title: Eager/Lazy loaded member always empty with JPA one-to-many relationship
type: Question
score: 0
answer count: 2
tagged with: jpa
has body: I have two entities, a User and Role with a one-to-many relationship from user to role. Here's what the tables look like: mysql> select * from User; +----+-------+----------+ | id | name | password | +----+-------+----------+ | 1 | admin | admin | +----+-------+----------+ 1 row in set (0.00 sec) mysql> select * from Role; +----+----------------------+---------------+----------------+ | id | description | name | summary | +----+----------------------+---------------+----------------+ | 1 | administrator's role | administrator | Administration | | 2 | editor's role | editor | Editing | +----+----------------------+---------------+----------------+ 2 rows in set (0.00 sec) And here's the join table that was created: mysql> select * from User_Role; +---------+----------+ | User_id | roles_id | +---------+----------+ | 1 | 1 | | 1 | 2 | +---------+----------+ 2 rows in set (0.00 sec) And here's the subset of orm.xml that defines the tables and relationships: <generated-value strategy="AUTO" /> <column name="name" length="100" unique="true" nullable="false"/> <column length="255" nullable="false" /> <one-to-many name="roles" fetch="EAGER" target-entity="Role" /> <generated-value strategy="AUTO"/> <column name="name" length="40" unique="true" nullable="false"/> <column name="summary" length="100" nullable="false"/> <column name="description" length="255"/> Yet, despite that, when I retrieve the admin user, I get back an empty collection. I'm using Hibernate as my JPA provider and it shows the following debug SQL: select user0_.id as id8_, user0_.name as name8_, user0_.password as password8_ from User user0_ where user0_.name=? limit ? When the one-to-many mapping is lazy loaded, that's the only query that's made. This correctly retrieves the one admin user. I changed the relationship to use eager loading and then the following query is made in addition to the above: select roles0_.User_id as User1_1_, roles0_.roles_id as roles2_1_, role1_.id as id9_0_, role1_.description …
accepted answer: http://stackoverflow.com/a/2610533
has answer: http://stackoverflow.com/a/2611711
tagged with: lazy-loading
tagged with: orm
type: AnsweredQuestion

http://stackoverflow.com/a/45147432
has body: This is my opinion, It is due to Thread id. Thread scheduler is identifying the thread through the thread id. It is unique real number. Please find below code, public class StartTwice extends Thread { public void run() { System.out.println("running..."); } public static void main(String[] args) { StartTwice start1 = new StartTwice(); System.out.println("Thread id: " + start1.getId()); start1.start(); start1 = new StartTwice(); System.out.println("Thread id: " + start1.getId()); start1.start(); } } Output is: Thread id: 10 Thread id: 11 running... running... When I re-instantiate the start1 object. A new thread id is created. PS: Even a thread is done, we can't use the same object (thread id) second time. Until or unless the JVM is reuse that id.
score: 1
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/2663426
downvote count: 0

logging
tags question: http://stackoverflow.com/q/2702866
tags question: http://stackoverflow.com/q/2716824
tags question: http://stackoverflow.com/q/2747244
tags question: http://stackoverflow.com/q/2605198
tag name: logging
tags question: http://stackoverflow.com/q/2622937
tags question: http://stackoverflow.com/q/2763925
tags question: http://stackoverflow.com/q/2763416
tags question: http://stackoverflow.com/q/2631644
tags question: http://stackoverflow.com/q/2763740
tags question: http://stackoverflow.com/q/2779003
tags question: http://stackoverflow.com/q/2710524
tags question: http://stackoverflow.com/q/2621701
tags question: http://stackoverflow.com/q/2763956
tags question: http://stackoverflow.com/q/2609925
tags question: http://stackoverflow.com/q/2723280
tags question: http://stackoverflow.com/q/2727500
tags question: http://stackoverflow.com/q/2676078
tags question: http://stackoverflow.com/q/2602415
tags question: http://stackoverflow.com/q/2773941
tags question: http://stackoverflow.com/q/2746578
tags question: http://stackoverflow.com/q/2610068
tags question: http://stackoverflow.com/q/2713148
tags question: http://stackoverflow.com/q/2654698
tags question: http://stackoverflow.com/q/2769280
type: Tag

http://stackoverflow.com/a/2710282
has comment: http://stackoverflow.com/comment/2738061
has comment: http://stackoverflow.com/comment/2734863
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2734839
upvote count: 2
has comment: http://stackoverflow.com/comment/2734866
type: Answer
has comment: http://stackoverflow.com/comment/2734780
score: 2
has body: OK, in order: setClient Looks perfectly fine. Nothing wrong with it. However, you want to avoid setting this.client directly in the CarLoan constructor—you're already calling setClient (thanks to @Gabriel and @Aeth). Sure, you can use super to access the parent class methods as much as you want. What you need to be careful with is calling the superclass' constructor, which you can only do once and at the beginning of the subclass' constructor. super != super(). Nope, this.length = length is fine. The problem is that you don't have a field called length. You might want to add one of those.
has comment: http://stackoverflow.com/comment/2734870
accepted answer of: http://stackoverflow.com/q/2710260
has comment: http://stackoverflow.com/comment/2734874
answers question: http://stackoverflow.com/q/2710260

http://stackoverflow.com/a/2726717
answers question: http://stackoverflow.com/q/2726694
score: 8
upvote count: 8
accepted answer of: http://stackoverflow.com/q/2726694
type: Answer
has comment: http://stackoverflow.com/comment/2753790
type: AcceptedAnswer
downvote count: 0
has body: &lt;(\d+)&gt;(\w+\s\d+\s\d+(?::\d+){2})\s(?!MSWinEventLog)([\w\/\.\-]*)(.*) a negative lookahead (here: '(?!MSWinEventLog)') should be enough: Negative lookahead is indispensable if you want to match something not followed by something else. When explaining character classes, I already explained why you cannot use a negated character class to match a "q" not followed by a "u". Negative lookahead provides the solution: q(?!u).

http://stackoverflow.com/a/2760569
upvote count: 2
answers question: http://stackoverflow.com/q/2675471
type: Answer
has body: Here's a C++ vs Java study. Here's a semi-scientific study of Python/Django vs. C#. And here's one on Java vs. C# vs. Ada. Whatever languages you're interested in comparing, do a Google search for study of [LanguageX] vs [LanguageY] and see what you can glean. But I agree with most everyone else that as long as you're in the right ballpark with your language selection, the rest of your productivity rests with the quality of your tools and people, not with whether you choose Perl or Python.
accepted answer of: http://stackoverflow.com/q/2675471
score: 2
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/2704917
comment on: http://stackoverflow.com/q/2684866
score: 1
has text: If you can use `System` to call an external executable, then use OptiPNG.
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/4357909
type: Comment
comment on: http://stackoverflow.com/a/2736843
score: 10
has text: get your data back again with: String fName = getIntent().getExtras().getInt("fname");
type: AnswerComment

http://stackoverflow.com/a/36695909
has body: To use a Git username and email you can use the variables ${name:git_config(user.name)} and ${email:git_config(user.email)}.
type: Answer
score: 3
downvote count: 1
has comment: http://stackoverflow.com/comment/68343894
upvote count: 4
answers question: http://stackoverflow.com/q/2612633

http://stackoverflow.com/a/2761289
accepted answer of: http://stackoverflow.com/q/2761172
type: Answer
has comment: http://stackoverflow.com/comment/2795453
score: 2
has body: Natural and frequent dilemma. Read about the composition vs inheritance alternative. Your second alternative is basically a composition, if we think that the object A is passed in the constructor instead of passing it in each method - that is, we would be using composition to implement a wrapper or decorator pattern. The issue for class C returning a new instance of class A has no trivial solution, as you guessed, as long as class C decides to take responsability of creating the new instance. This is why one should pause and think before typing a "new" statement inside a class, if there is the possibility that this class will be subclassed. In yout example, it would be nice if you could tell class C what concrete class to return ... but how would it know to create it? Well we could pass him an object who knows how to instantiate an object of class A (or a subclass)... I guess you are enough motivated to read about Factories now, and design patterns in general. There is no unique best answer, but if want a quick one: I'd make a wrapper, B class does not extend A but has a constructor with A as parameter, it delegates its methods (except the own) to the inside object. When you need to call the method in class C (I'm assuming you cant touch class C), you could write: B b = new B(c.func())
upvote count: 2
answers question: http://stackoverflow.com/q/2761172
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2797347

http://stackoverflow.com/q/2601857
type: AnsweredQuestion
tagged with: constructor
has comment: http://stackoverflow.com/comment/2611162
type: Question
has title: Why would one want to use the public constructors on Boolean and similar immutable classes?
upvote count: 5
tagged with: java
has answer: http://stackoverflow.com/a/2601932
has answer: http://stackoverflow.com/a/2601905
score: 5
possible better answer: http://stackoverflow.com/a/2601932
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2601896
has comment: http://stackoverflow.com/comment/3729590
answer count: 3
has body: (For the purposes of this question, let us assume that one is intentionally not using auto(un)boxing, either because one is writing pre-Java 1.5 code, or because one feels that autounboxing makes it too easy to create NullPointerExceptions.) Take Boolean, for example. The documentation for the Boolean(boolean) constructor says: Note: It is rarely appropriate to use this constructor. Unless a new instance is required, the static factory valueOf(boolean) is generally a better choice. It is likely to yield significantly better space and time performance. My question is, why would you ever want to get a new instance in the first place? It seems like things would be simpler if constructors like that were private. For example, if they were, you could write this with no danger (even if myBoolean were null): if (myBoolean == Boolean.TRUE) It'd be safe because all true Booleans would be references to Boolean.TRUE and all false Booleans would be references to Boolean.FALSE. But because the constructors are public, someone may have used them, which means that you have to write this instead: if (Boolean.TRUE.equals(myBoolean)) But where it really gets bad is when you want to check two Booleans for equality. Something like this: if (myBooleanA == myBooleanB) ...becomes this: if ( myBooleanA == myBooleanB || (myBooleanA != null &amp;&amp; myBooleanA.equals(myBooleanB)) ) UPDATE: With the release of Java 7, java.util.Objects makes this simpler construct possible: if (Objects.equals(myBooleanA, myBooleanB)) I can't think of any reason to have separate instances of these objects which is more compelling than not having to do the nonsense above. What say you?
accepted answer: http://stackoverflow.com/a/2601896
tagged with: immutability

http://stackoverflow.com/a/2597127
answers question: http://stackoverflow.com/q/2597106
type: Answer
accepted answer of: http://stackoverflow.com/q/2597106
has comment: http://stackoverflow.com/comment/2605607
has body: Forget about constants, they are not what you want here. Go with a Properties file you read from a file on the disk. That is what I would do if I had to do it by tomorrow. You will have to fiddle with classpaths to make that work, and I am assuming you already covered file IO in Java.
upvote count: 4
type: AcceptedAnswer
downvote count: 0
score: 4

http://stackoverflow.com/a/67599551
upvote count: 1
type: Answer
has body: Extension for converting date to calendar in Kotlin. fun Date?.toCalendar(): Calendar? { return this?.let { date -&gt; val calendar = Calendar.getInstance() calendar.time = date calendar } }
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/2727698

session-timeout
tags question: http://stackoverflow.com/q/2641251
type: Tag
tag name: session-timeout

http://stackoverflow.com/a/2647361
answers question: http://stackoverflow.com/q/2647349
score: 0
type: Answer
has body: When you unmarshal an object with serialization and assign it to a variable you replace the old reference (in your case a new Tournament()) with the new object.. so test2 will be pointing to the original Tournament while test1 will reference to the just unserialized object.. It's like doing: Tournament t1 = new Tournament(); Tournament t2 = t1; t1 = new Tournament(); will t1 == t2? Of course not..

http://stackoverflow.com/a/2768995
answers question: http://stackoverflow.com/q/2768748
upvote count: 2
type: Answer
has body: You are going to have to define the unique logic (assuming that the logic IS unique) for every single combination of battle anyways - it doesn't matter what design pattern you choose to use. The only requirement is to separate this logic from the Ogre and Wizard class and create the battle methods in a different class. I think what you are doing currently is completely fine (once you move the battle logic somewhere else) without requiring a visitor pattern, which is what I would use if this was some enterprise game :) Don't listen to all of this fluff about design patterns...
score: 1
downvote count: 1

http://stackoverflow.com/q/2735167
answer count: 1
has answer: http://stackoverflow.com/a/2735196
tagged with: ejb-3.0
tagged with: jsf
accepted answer: http://stackoverflow.com/a/2735196
type: AnsweredQuestion
has title: By using ejb3 and jsf do I still have to do jndi lookup?
has body: I am not sure jndi lookup is necessary or not in terms of ejb3 technology advantages. Any help would be appreciated, thanks.
tagged with: jndi
tagged with: java
type: Question
score: 0
tagged with: ejb

http://stackoverflow.com/q/2611754
has answer: http://stackoverflow.com/a/2611824
has answer: http://stackoverflow.com/a/2611844
type: AnsweredQuestion
score: 2
tagged with: rmi
tagged with: java
possible better answer: http://stackoverflow.com/a/2611844
type: Question
answer count: 2
downvote count: 0
accepted answer: http://stackoverflow.com/a/2611824
has comment: http://stackoverflow.com/comment/2623349
has title: Java RMI method synchronization
favorite count: 0
tagged with: synchronization
upvote count: 2
has body: I have a class that is stored on the 'server' and multiple clients can call this method. This method returns a class. Now when clients call accessor methods within this class for example a set accessor method. I want the object on the server to be updated and synchronized across all the other clients. How do I use: public synchronized setStatus(String s) { this.status = s; } within java to achieve this. Thanks

http://stackoverflow.com/comment/2794970
score: 0
has text: Definitely the way to go if you can control the API to that level.
comment on: http://stackoverflow.com/a/2762653
type: Comment
type: AnswerComment

http://stackoverflow.com/q/2644847
possible better answer: http://stackoverflow.com/a/29128896
has comment: http://stackoverflow.com/comment/2660017
has answer: http://stackoverflow.com/a/44072167
has body: I'm looking for a solution to generate a checksum for any type of Java object, which remains the same for every execution of an application that produces the same object. I tried it with Object.hashCode(), but the api says ....This integer need not remain consistent from one execution of an application to another execution of the same application.
has answer: http://stackoverflow.com/a/2644899
has answer: http://stackoverflow.com/a/2645266
has title: How to generate a checksum for an java object
tagged with: checksum
tagged with: object
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2645170
has answer: http://stackoverflow.com/a/2644911
has answer: http://stackoverflow.com/a/2644912
has comment: http://stackoverflow.com/comment/2659930
tagged with: java
answer count: 11
has answer: http://stackoverflow.com/a/2645205
has comment: http://stackoverflow.com/comment/2660833
has comment: http://stackoverflow.com/comment/2660005
type: Question
upvote count: 22
has answer: http://stackoverflow.com/a/66253139
downvote count: 0
has answer: http://stackoverflow.com/a/8971603
has answer: http://stackoverflow.com/a/29128896
score: 22
favorite count: 0
has answer: http://stackoverflow.com/a/2644959
has comment: http://stackoverflow.com/comment/2659889
has answer: http://stackoverflow.com/a/2645170
has comment: http://stackoverflow.com/comment/2659906

http://stackoverflow.com/a/2765781
downvote count: 0
answers question: http://stackoverflow.com/q/2765750
type: Answer
has body: From the LinkedList docs: All of the operations perform as could be expected for a doubly-linked list. Operations that index into the list will traverse the list from the beginning or the end, whichever is closer to the specified index. It should be O(1) since a doubly-linked list will have a reference to its own tail. (Even if it doesn't explicitly keep a reference to its tail, it will be O(1) to find its tail.)
score: 1
upvote count: 1

http://stackoverflow.com/comment/2640947
score: 1
type: AnswerComment
has text: @moon Thanks for your link. I got the answer from this link. Very thanks.
type: Comment
comment on: http://stackoverflow.com/a/2627702

http://stackoverflow.com/a/2620693
downvote count: 0
has comment: http://stackoverflow.com/comment/2633004
type: Answer
has comment: http://stackoverflow.com/comment/2633028
upvote count: 3
has comment: http://stackoverflow.com/comment/2633073
has comment: http://stackoverflow.com/comment/2633168
has body: int getTrailingInteger(String str) { int positionOfLastDigit = getPositionOfLastDigit(str); if (positionOfLastDigit == str.length()) { // string does not end in digits return -1; } return Integer.parseInt(str.substring(positionOfLastDigit)); } int getPositionOfLastDigit(String str) { int pos; for (pos=str.length()-1; pos&gt;=0; --pos) { char c = str.charAt(pos); if (!Character.isDigit(c)) break; } return pos + 1; }
has comment: http://stackoverflow.com/comment/2633060
score: 3
has comment: http://stackoverflow.com/comment/2633019
answers question: http://stackoverflow.com/q/2620591

http://stackoverflow.com/q/2612972
answer count: 2
has title: Can we convert any java program into an eclipse plugin?
has answer: http://stackoverflow.com/a/2613198
downvote count: 0
tagged with: eclipse-plugin
has answer: http://stackoverflow.com/a/2613126
favorite count: 0
possible better answer: http://stackoverflow.com/a/2613126
accepted answer: http://stackoverflow.com/a/2613198
upvote count: 2
type: AnsweredQuestion
score: 2
tagged with: java
has body: I want to write a plug-in which tracks the updates to a text file and stores them in a separate file. Should I first write a simple java program which does this and then try to convert it into a plug-in?
type: Question

http://stackoverflow.com/comment/2669518
type: Comment
has text: What OS is this primarily required to run on?
score: 0
comment on: http://stackoverflow.com/q/2653262
type: QuestionComment

http://stackoverflow.com/comment/2674535
score: 0
comment on: http://stackoverflow.com/a/2657537
type: Comment
has text: However, Can this be the reason for Out of Memory error? Time Complexity is something i can look at. I am trying to figure out why the memory usage is so high.
type: AnswerComment

http://stackoverflow.com/q/2686126
answer count: 1
accepted answer: http://stackoverflow.com/a/2699955
favorite count: 0
tagged with: cometd
upvote count: 3
tagged with: android
has body: I'm trying to implement a Cometd/Bayeux server on Android using iJetty. The Jetty implementation itself works just fine serving static pages along with servlets. I am trying to up the ante a bit and create a Bayeux application on the phone but I'm having some trouble. I can hit the page that has the dojo cometd scripts on it, but I am unable to subscribe to the channel. When I view firebug/chome developer tools, I see a series of posts/gets that last a couple of milliseconds (~14). However, when I run a cometd application on a normal machine, the posts/gets last several seconds (~14 seconds) before timing out and reopening the connection. This second scenario makes sense to me with my understanding of how continuation in HTTP works. So I'm thinking that something is not allowing those connections to hang open and prematurely returning a value and consequently closing the connection. I would post my source but I'm not sure what to post short of posting everything...(it is open source though so if you want to have a look it's at http://webtext-android.googlecode.com). So my question is, does anybody think that there could be some underlying limitation imposed by the Android system that is preventing these servlets from working? Are there assumptions that are made by the Jetty Bayeux implementation with regards to the underlying system? Or is it more likely that somehow I have a bad implementation of the ContinuationCometdServelt? I should note that all of the posts/gets from the client return 200 OK messages so I'm not inclined to think that the Android system is simply terminating the connection. I know this is a bit off the wall and I'm definitely trying to do something a bit out of the ordinary but any suggestions or tips would be greatly appreciated.
has answer: http://stackoverflow.com/a/2699955
has comment: http://stackoverflow.com/comment/2706700
tagged with: jetty
tagged with: bayeux
type: AnsweredQuestion
score: 3
has title: System requirements for Cometd/Bayeux Usage on Android
downvote count: 0
has comment: http://stackoverflow.com/comment/2706666
tagged with: java
type: Question

http://stackoverflow.com/a/2687174
answers question: http://stackoverflow.com/q/2686993
type: Answer
has body: The only workaround I can see is to create another Cache instance with the goal to store under a known key an object containing keys, or any more complex structure. This structure is modified in the onPut() and onRemove() methods of the used CacheListener: public void onRemove(Object key) { LOG.log(Level.INFO, key.toString()); Map&lt;Integer, Date&gt; realEstateIdByDate = (Map&lt;Integer, Date&gt;) keyCache.get("realEstateIdByDate"); realEstateIdByDate.remove(key); keyCache.put("realEstateIdByDate", realEstateIdByDate); } @Override public void onPut(Object object) { LOG.log(Level.INFO, object.toString()); Map&lt;Integer, Date&gt; realEstateIdByDate = (Map&lt;Integer, Date&gt;) keyCache.get("realEstateIdByDate"); realEstateIdByDate.put(((RealEstateAd)object).getRealEstateId(), new Date()); keyCache.put("realEstateIdByDate", realEstateIdByDate); } Any feedback more than welcome ;-)
score: 0

http://stackoverflow.com/comment/2741523
comment on: http://stackoverflow.com/a/2716008
score: 0
type: AnswerComment
has text: @Marcus that appears to only be the case if you modify the list while iterating over it. Also, there is no guarantee this exception will be thrown.
type: Comment

http://stackoverflow.com/comment/2685244
score: 3
comment on: http://stackoverflow.com/q/2663426
has text: If you need to do the same thing in multiple threads, you can implement Runnable and pass the same Runnable to multiple instances of the Thread class.
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/2739342
comment on: http://stackoverflow.com/q/2714275
has text: reread your question. And then rephrase it so that it is comprehensible. I didn't understand anything.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/2772250
answers question: http://stackoverflow.com/q/2772152
type: Answer
upvote count: 4
has comment: http://stackoverflow.com/comment/53762850
downvote count: 0
has comment: http://stackoverflow.com/comment/2805853
has comment: http://stackoverflow.com/comment/2806148
has comment: http://stackoverflow.com/comment/2806061
has comment: http://stackoverflow.com/comment/53660091
score: 4
has comment: http://stackoverflow.com/comment/53732443
has body: There are a few reasons: The JIT is unlikely to generate as efficient low level code as a manually written C code. Using low level C can enable a lot of optimizations that are close to impossible to do for a generic JIT compiler. See this link for some tricks and speed comparisons of hand written C implementations (memcpy, but the principle is the same): Check this Optimizing Memcpy improves speed The C version is pretty much independant of the type and size of the array members. It is not possible to do the same in java since there is no way to get the array contents as a raw block of memory (eg. pointer).
has comment: http://stackoverflow.com/comment/2807405

http://stackoverflow.com/comment/2640541
score: 0
has text: asp.net is a good choice. I'm wondering what's your criterion that made you narrow it down to php and java.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2627237

http://stackoverflow.com/a/2678996
score: 13
has body: NaN values are not equal to anything (if one side of an equality is NaN, the equality is false), so NaN != NaN. Obviously every normal double does equal itself
upvote count: 13
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2678985
answers question: http://stackoverflow.com/q/2678985
type: Answer
downvote count: 0

http://stackoverflow.com/comment/8661180
has text: This is **not** the `Factory Method` pattern; This is exactly the pattern used by the original author of the [question](http://stackoverflow.com/questions/806911/is-this-factory-method-creation-pattern) that this OP references. The answers to that question indicate it is a `Simple Factory` and not the GoF "Factory Method". (I found both this and that question because I too am trying to better understand the *real* Factory Method)
type: Comment
comment on: http://stackoverflow.com/a/2659883
score: 0
type: AnswerComment

http://stackoverflow.com/q/2680714
tagged with: vpn
tagged with: ejb
tagged with: jpa
score: 4
upvote count: 4
has title: Is JPA + EJB to much slow (or heavy) for over Internet transactions?
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2680753
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2681953
answer count: 4
has answer: http://stackoverflow.com/a/2686631
tagged with: java
has body: I am developing a stand-alone java client application that connects to a Glassfish v3 application for JPA/EJB facade style transactions. In other words, my client application do not connect directly to the database to CRUD, but it transfers JPA objets using EJB stateless sessions. I have scenarios where this client application will be used in an external network connected with a VPN over Internet with a client connection of 512kbp/DSL, and a simple query takes so much time, I'm seeing the traffic graph and when I merge a entity in the client application I see megabytes of traffic (I couldn't believe how a purchase order entity could weight more than 1 mb). I have LAZY fetch in almost every many-to-many relationship, but I have a lot of many-to-one relationships between entities (but this is the great advantage of JPA!). Could I do something to accelerate the the speed of transactions between JPA/EJB server and the remote java client? Thank you in advance.
has answer: http://stackoverflow.com/a/2681083
type: Question

http://stackoverflow.com/comment/2613033
score: 0
comment on: http://stackoverflow.com/a/2603082
has text: Now sure how you will hand-create the canonical metamodel. Are you using any IDE? if so follow applicable links or for eclipse, take a look at answer below. What version of Java are you using? An implicit understanding among JPA providers is that they'll generate metamodel using the annotation processor integrated in the Java 6 compiler.
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/2735752
type: AnswerComment
comment on: http://stackoverflow.com/a/2710900
has text: @Romain they can be handy but they can also makes things confusing as suddenly when you read the code it might not be clear as to the source of a partciular enum value.
type: Comment
score: 1

http://stackoverflow.com/a/2716814
has comment: http://stackoverflow.com/comment/2748534
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2714985
has body: Does this help ? http://download.oracle.com/docs/cd/E13222_01/wls/docs90/jms/design_best_practices.html
score: 1
upvote count: 1

http://stackoverflow.com/q/2684407
tagged with: web-services
accepted answer: http://stackoverflow.com/a/2685096
has comment: http://stackoverflow.com/comment/2704645
type: AnsweredQuestion
has body: I'm developing a Web Service which will be called by clients which are written by me. In the web service I need to use application-wide objects which eases the load of application on the system. I have implemented my application-wide objects as shown in this question. I can use my object in a jsf page with no problem as follows. MyObject mo = (MyObject) FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().get("MyObjectsName"); But when it comes to use it in a Web Service Request FacesContext.getCurrentInstance() returns null. Is there any way to use the FacesContext in a web service.
tagged with: jsf
tagged with: java
linked to: http://stackoverflow.com/q/315073
type: Question
score: 5
upvote count: 5
has answer: http://stackoverflow.com/a/2685096
has comment: http://stackoverflow.com/comment/2707416
answer count: 1
downvote count: 0
favorite count: 0
has title: Accessing FacesContext from Web Service

http://stackoverflow.com/comment/2807565
has text: @SpikETidE That's a detail of how uniqueness is implemented, but the meaning of HashSet is to implement a set.
score: 3
comment on: http://stackoverflow.com/a/2773854
type: AnswerComment
type: Comment

http://stackoverflow.com/a/2675934
downvote count: 0
has body: You might want to look at ECF for the server portion. You could set up a publish/subscribe model where only the server can publish but each of your clients has access to subscribe to the server. At this point I would look at XMPP as the protocol (ECF supports this protocol out of the box). XMPP plus extensions is what Google uses for Google Voice so it is proven and it looks like it will be around for awhile. Take a look at xmpp.org for some Java libraries. JMF as mentioned by JRL is some pretty old technology but it might be useful for grabbing sound from the microphone and for storing a voice file on the filesystem.
type: Answer
upvote count: 1
accepted answer of: http://stackoverflow.com/q/2675434
score: 1
answers question: http://stackoverflow.com/q/2675434
type: AcceptedAnswer

http://stackoverflow.com/a/2717049
score: 1
upvote count: 1
downvote count: 0
type: Answer
has body: Probably right here: speed = 45/timeInSecs; Make sure that timeInSecs is not zero.
answers question: http://stackoverflow.com/q/2717032

http://stackoverflow.com/a/13435104
score: 2
has body: I know this will sound silly, and possibly too simple to be true, but I solved this exact same error message by: Deleting the entire line of the package name causing the error message. Saving the .java file(this triggers a new error on the same line stating "The declared package "" does not match the expected package"), which it should do. Re-typing the original package name onto the same line. Saving the .java file. Could not tell you why this worked, but it did, and Eclipse stopped throwing a tantrum on the spot. Safe typing and speedy coding. -Goodge
upvote count: 3
has comment: http://stackoverflow.com/comment/134058550
answers question: http://stackoverflow.com/q/2674325
type: Answer
downvote count: 1

http://stackoverflow.com/q/2602636
type: Question
has comment: http://stackoverflow.com/comment/2612253
has answer: http://stackoverflow.com/a/2604092
downvote count: 0
has comment: http://stackoverflow.com/comment/2612167
answer count: 6
has answer: http://stackoverflow.com/a/2602740
favorite count: 0
possible better answer: http://stackoverflow.com/a/2602655
tagged with: autoboxing
has title: Why can't the compiler/JVM just make autoboxing "just work"?
has comment: http://stackoverflow.com/comment/2613080
tagged with: integer
has body: Autoboxing is rather scary. While I fully understand the difference between == and .equals I can't but help have the follow bug the hell out of me: final List&lt;Integer&gt; foo = Arrays.asList(1, 1000); final List&lt;Integer&gt; bar = Arrays.asList(1, 1000); System.out.println(foo.get(0) == bar.get(0)); System.out.println(foo.get(1) == bar.get(1)); That prints true false Why did they do it this way? It something to do with cached Integers, but if that is the case why don't they just cache all Integers used by the program? Or why doesn't the JVM always auto unbox to primitive? Printing false false or true true would have been way better. EDIT I disagree about breakage of old code. By having foo.get(0) == bar.get(0) return true you already broke the code. Can't this be solved at the compiler level by replacing Integer with int in byte code (as long as it is never assigned null)
has answer: http://stackoverflow.com/a/6198283
score: 13
has comment: http://stackoverflow.com/comment/2612144
upvote count: 13
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2602655
has answer: http://stackoverflow.com/a/2602687
has answer: http://stackoverflow.com/a/2602799
tagged with: java
has comment: http://stackoverflow.com/comment/2612285
accepted answer: http://stackoverflow.com/a/2602740
tagged with: caching

mono
tags question: http://stackoverflow.com/q/2610332
type: Tag
tag name: mono

http://stackoverflow.com/q/2725533
tagged with: instanceof
has answer: http://stackoverflow.com/a/59019221
type: Question
has answer: http://stackoverflow.com/a/23568415
has answer: http://stackoverflow.com/a/54315119
linked to: http://stackoverflow.com/q/2721033
has answer: http://stackoverflow.com/a/2725855
answer count: 6
tagged with: gwt
has title: How to see if an object is an array without using reflection?
upvote count: 121
tagged with: java
has answer: http://stackoverflow.com/a/2725688
possible better answer: http://stackoverflow.com/a/2725555
tagged with: arrays
accepted answer: http://stackoverflow.com/a/2725855
has answer: http://stackoverflow.com/a/2725555
has body: How can I see in Java, if an Object is an array and how can I iterate through all items without using reflection? I use Google GWT so I am not allowed to use reflection :-( I would love to implement the following methods without using refelection: private boolean isArray(final Object obj) { //??.. } private String toString(final Object arrayObject) { //??.. } BTW: neither do I want to use JavaScript such that I can use it in non-GWT environments.
type: AnsweredQuestion
score: 121
downvote count: 0
linked to: http://stackoverflow.com/q/2337170
favorite count: 0

http://stackoverflow.com/comment/91471598
score: 0
type: Comment
has text: Super ! Worked for me
comment on: http://stackoverflow.com/a/28619132
type: AnswerComment

http://stackoverflow.com/comment/77701368
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/2606603
type: Comment
has text: You can find good JBoss Drools tutorial here along with source code and Videos-http://javainuse.com/drools

http://stackoverflow.com/comment/17449650
type: QuestionComment
has text: [jsp Runner](http://sourceforge.net/projects/jsprunner/?source=directory) or this [link](https://dz.prosyst.com/pdoc/mToolkit/um/com.prosyst.tools.userdoc/doc/jsp_tool.html) helped me.
comment on: http://stackoverflow.com/q/2635491
score: 0
type: Comment

http://stackoverflow.com/q/2614446
has answer: http://stackoverflow.com/a/2614621
has comment: http://stackoverflow.com/comment/2626312
type: Question
possible better answer: http://stackoverflow.com/a/2614459
score: 5
has answer: http://stackoverflow.com/a/2614518
has answer: http://stackoverflow.com/a/2615438
tagged with: java
tagged with: rtp
accepted answer: http://stackoverflow.com/a/2614621
has answer: http://stackoverflow.com/a/3591026
upvote count: 5
tagged with: arrays
answer count: 5
tagged with: voip
has body: For part of a project I'm working on I am implementing a RTPpacket where I have to fill the header array of byte with RTP header fields. //size of the RTP header: static int HEADER_SIZE = 12; // bytes //Fields that compose the RTP header public int Version; // 2 bits public int Padding; // 1 bit public int Extension; // 1 bit public int CC; // 4 bits public int Marker; // 1 bit public int PayloadType; // 7 bits public int SequenceNumber; // 16 bits public int TimeStamp; // 32 bits public int Ssrc; // 32 bits //Bitstream of the RTP header public byte[] header = new byte[ HEADER_SIZE ]; This was my approach: /* * bits 0-1: Version * bit 2: Padding * bit 3: Extension * bits 4-7: CC */ header[0] = new Integer( (Version &lt;&lt; 6)|(Padding &lt;&lt; 5)|(Extension &lt;&lt; 6)|CC ).byteValue(); /* * bit 0: Marker * bits 1-7: PayloadType */ header[1] = new Integer( (Marker &lt;&lt; 7)|PayloadType ).byteValue(); /* SequenceNumber takes 2 bytes = 16 bits */ header[2] = new Integer( SequenceNumber &gt;&gt; 8 ).byteValue(); header[3] = new Integer( SequenceNumber ).byteValue(); /* TimeStamp takes 4 bytes = 32 bits */ for ( int i = 0; i &lt; 4; i++ ) header[7-i] = new Integer( TimeStamp &gt;&gt; (8*i) ).byteValue(); /* Ssrc takes 4 bytes = 32 bits */ for ( int i = 0; i &lt; 4; i++ ) header[11-i] = new Integer( Ssrc &gt;&gt; (8*i) ).byteValue(); Any other, maybe 'better' ways to do this?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2614459
downvote count: 0
has title: Filling a byte array in Java
favorite count: 0

http://stackoverflow.com/a/2698794
downvote count: 0
has body: You can store values as Integer/String (without precision) internally and use scale (this is a transcript from Scala REPL): scala&gt; val Scale = 2 Scale: Int = 2 scala&gt; val x = BigDecimal(110, Scale) x: scala.math.BigDecimal = 1.10 scala&gt; val y = BigDecimal(303, Scale) y: scala.math.BigDecimal = 3.03 scala&gt; (x+y, (x+y).scale) res0: (scala.math.BigDecimal, Int) = (4.13,2) scala&gt; (x*2, (x*2).scale) res1: (scala.math.BigDecimal, Int) = (2.20,2) Or if you want to parse a string, you can control rounding: scala&gt; val z = BigDecimal("8.937").setScale(Scale, BigDecimal.RoundingMode.FLOOR) z: scala.math.BigDecimal = 8.93 scala&gt; val z = BigDecimal("8.937").setScale(Scale, BigDecimal.RoundingMode.CEILING) z: scala.math.BigDecimal = 8.94
type: Answer
answers question: http://stackoverflow.com/q/2697638
has comment: http://stackoverflow.com/comment/5759957
upvote count: 7
score: 7
has comment: http://stackoverflow.com/comment/5761355

http://stackoverflow.com/q/2714480
type: Question
upvote count: 2
answer count: 2
has body: I want to encode a UTF-8 string to a ISO 8859- string in Java I have this: String title = new String(item.getTitle().getText().getBytes("ISO-8859-1")); But it isn't working, the output is SÃ¸rensen for example
has title: Convert string from UTF-8 to ISO 8859-1 in Java
tagged with: java
tagged with: character-encoding
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2714497
score: 2
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2714503

http://stackoverflow.com/a/3600459
has comment: http://stackoverflow.com/comment/12841670
downvote count: 0
score: 7
has body: Here is a blog post from John Rose, a HotSpot architect: http://blogs.oracle.com/jrose/entry/longjumps_considered_inexpensive It is about "abusing" exceptions for flow control. Slightly different use case, but.. In short, it works really well - if you preallocate/clone your exceptions to prevent stack traces being created. I think that this technique is justifiable if "hidden" from clients. IE, your FlyingPig should never be able to leave your library (all public methods should transitively guarantee not to throw it). One way to guarantee this would be to make it a checked Exception. I think the only justification for extending Throwable is because you want to allow people to pass in callbacks that have catch(Exception e) clauses , and you wish your result to be ignored by them. I can just about buy that...
answers question: http://stackoverflow.com/q/2755972
upvote count: 7
type: Answer

orm
tags question: http://stackoverflow.com/q/2748431
tags question: http://stackoverflow.com/q/2722095
tags question: http://stackoverflow.com/q/2605594
tags question: http://stackoverflow.com/q/2701861
tags question: http://stackoverflow.com/q/2742039
tags question: http://stackoverflow.com/q/2713584
tags question: http://stackoverflow.com/q/2638248
tags question: http://stackoverflow.com/q/2685293
tags question: http://stackoverflow.com/q/2725111
tags question: http://stackoverflow.com/q/2687690
tags question: http://stackoverflow.com/q/2698665
tags question: http://stackoverflow.com/q/2746756
tags question: http://stackoverflow.com/q/2682525
tags question: http://stackoverflow.com/q/2686863
tags question: http://stackoverflow.com/q/2622424
tags question: http://stackoverflow.com/q/2780230
tags question: http://stackoverflow.com/q/2700047
tags question: http://stackoverflow.com/q/2783292
tags question: http://stackoverflow.com/q/2704914
tags question: http://stackoverflow.com/q/2695861
tags question: http://stackoverflow.com/q/2648422
tags question: http://stackoverflow.com/q/2641239
tags question: http://stackoverflow.com/q/2617898
tags question: http://stackoverflow.com/q/2751733
tags question: http://stackoverflow.com/q/2752780
tags question: http://stackoverflow.com/q/2667837
tags question: http://stackoverflow.com/q/2777017
tags question: http://stackoverflow.com/q/2627777
tags question: http://stackoverflow.com/q/2673180
tags question: http://stackoverflow.com/q/2694151
tag name: orm
tags question: http://stackoverflow.com/q/2783602
tags question: http://stackoverflow.com/q/2747887
tags question: http://stackoverflow.com/q/2773595
tags question: http://stackoverflow.com/q/2776942
tags question: http://stackoverflow.com/q/2768511
tags question: http://stackoverflow.com/q/2711408
tags question: http://stackoverflow.com/q/2768493
tags question: http://stackoverflow.com/q/2715874
tags question: http://stackoverflow.com/q/2610113
tags question: http://stackoverflow.com/q/2740452
tags question: http://stackoverflow.com/q/2759618
tags question: http://stackoverflow.com/q/2775507
tags question: http://stackoverflow.com/q/2649145
tags question: http://stackoverflow.com/q/2703933
tags question: http://stackoverflow.com/q/2751941
tags question: http://stackoverflow.com/q/2762681
type: Tag
tags question: http://stackoverflow.com/q/2716433
tags question: http://stackoverflow.com/q/2750208
tags question: http://stackoverflow.com/q/2742809
tags question: http://stackoverflow.com/q/2715568
tags question: http://stackoverflow.com/q/2779857
tags question: http://stackoverflow.com/q/2625600
tags question: http://stackoverflow.com/q/2744335
tags question: http://stackoverflow.com/q/2702707
tags question: http://stackoverflow.com/q/2714034
tags question: http://stackoverflow.com/q/2600021
tags question: http://stackoverflow.com/q/2643037
tags question: http://stackoverflow.com/q/2613347
tags question: http://stackoverflow.com/q/2616878
tags question: http://stackoverflow.com/q/2597686
tags question: http://stackoverflow.com/q/2749689
tags question: http://stackoverflow.com/q/2746623
tags question: http://stackoverflow.com/q/2702266
tags question: http://stackoverflow.com/q/2762936
tags question: http://stackoverflow.com/q/2726300
tags question: http://stackoverflow.com/q/2738787
tags question: http://stackoverflow.com/q/2638538
tags question: http://stackoverflow.com/q/2779381
tags question: http://stackoverflow.com/q/2668449
tags question: http://stackoverflow.com/q/2679225
tags question: http://stackoverflow.com/q/2754452
tags question: http://stackoverflow.com/q/2643470
tags question: http://stackoverflow.com/q/2641172
tags question: http://stackoverflow.com/q/2673732
tags question: http://stackoverflow.com/q/2757350
tags question: http://stackoverflow.com/q/2639729
tags question: http://stackoverflow.com/q/2727382
tags question: http://stackoverflow.com/q/2741402

http://stackoverflow.com/a/2635096
has body: I think this is an area where unit tests can really help. I had a similar thing some time ago where I wanted to break a string up in a number of complex ways and create a number of tests, each of which tested against a different source string, helped me to isolate the regex and also quickly see when I got it wrong. Certainly if you gave us an example of a test string and the result it would help us to give you better answers.
answers question: http://stackoverflow.com/q/2635082
upvote count: 2
type: Answer
score: 2
downvote count: 0

http://stackoverflow.com/comment/138631506
comment on: http://stackoverflow.com/a/6381074
score: 0
type: AnswerComment
type: Comment
has text: Where is this dispose() method located?

http://stackoverflow.com/a/2754617
has comment: http://stackoverflow.com/comment/2786003
upvote count: 1
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2754452
answers question: http://stackoverflow.com/q/2754452
has body: The problem is not really Course, the problem is the many-to-many association between Course and Module, the later being not recognized as a mapped class. Do you see any noticeable error messages when you create the SessionFactory? Nothing about Module? Can you show Module.hbm.xml?
type: Answer
has comment: http://stackoverflow.com/comment/2793500
downvote count: 0
has comment: http://stackoverflow.com/comment/2785691
score: 1

http://stackoverflow.com/q/2629786
has body: I'm trying to make this code generic: public final Object unwrap(Class arg0) { throw new UnsupportedOperationException(); } It comes from the Wrapper class (java.sql) and looks originally like this: &lt;T&gt; T unwrap(java.lang.Class&lt;T&gt; iface) throws java.sql.SQLException;
has comment: http://stackoverflow.com/comment/2642854
has answer: http://stackoverflow.com/a/2629804
type: Question
tagged with: java-6
type: AnsweredQuestion
tagged with: generics
has comment: http://stackoverflow.com/comment/2790198
accepted answer: http://stackoverflow.com/a/2629804
answer count: 1
has title: Implementing generics for java 1.6
score: 0
tagged with: java

http://stackoverflow.com/q/2739911
type: UnansweredQuestion
score: 1
tagged with: java
tagged with: blackberry
type: Question
has comment: http://stackoverflow.com/comment/8915271
upvote count: 1
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/2740730
has title: Blackberry JDE generating bad .jad file (does not match compiled .cod file)
tagged with: jde
downvote count: 0
has body: I Have a BB application that gets compiled into 3 siblings cod file. ( actualy one cod fil contaning 3 sub cod files). app.cod |--app.cod |--app-1.cod |--app-2.cod which is normal. the jad refers to those 3 inner .cod files. Now I have add some feature to my app, it is getting a little bit bigger. the jad now refers to 4 inner .cod files. but there is still 3 inside the app.cod that is generated. so I now still have app.cod |--app.cod |--app-1.cod |--app-2.cod but with the jad referring to app.cod, app-1.cod, app-2.cod, AND app-3.cod. this is causing OTA download to fail with the following error: 907 invalid COD HTTP Error 404 : not found what is wrong the my compiled program? is it a bug from the JDE? I am using JDE 4.5

http://stackoverflow.com/a/10087315
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/23193834
upvote count: 21
answers question: http://stackoverflow.com/q/2632684
score: 21
has comment: http://stackoverflow.com/comment/108779593
has body: I suggest using the native org.apache.wicket.ajax.AjaxRequestTarget#focusComponent(). For example: /** * Sets the focus in the browser to the given component. The markup id must be set. If * the component is null the focus will not be set to any component. * * @param component * The component to get the focus or null. */ org.apache.wicket.ajax.AjaxRequestTarget#focusComponent(Component component)

http://stackoverflow.com/a/2619636
has body: Consider using the SVN Kit Library - http://svnkit.com/. It gives you a programmatic way to perform SVN operations. If you just want to store that in a file, you can redirect the output to a file like this svn log --xml &gt; log.xml
type: Answer
upvote count: 3
answers question: http://stackoverflow.com/q/2619622
score: 3
downvote count: 0

http://stackoverflow.com/comment/2692612
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2667647
has text: so people no i am not trying to scam homework answers as people get funny about it

http://stackoverflow.com/a/2745051
answers question: http://stackoverflow.com/q/2744511
has body: I've wondered why they don't support this also. Sure, if you ignore the return value, the compiler would have no way to know which you wanted. But that's the same ambiguity that arises with passing nulls. Like: String doSomething(String s) { ... } String doSomething(Integer s) { ... } ... String out=doSomething(null); In this case, the compiler just complains that the call is ambiguous, and you have to resolve it by casting the null, like: String out=doSomething((String)null); You could do the same thing with overloading by return type: String getSomething() { ... } Integer getSomething() { ... } ... Integer n=getSomething(); would presumably call the second function. getSomething(); would be ambiguous (and in this example, probably useless, unless it had side effects, but that's another story), so you'd have to say: (String) getSomething(); More realistically, perhaps: if ((String) getSomething()==null) ... But that's the easy case. I can see a compiler-writer not wanting to support this because it could get very complicated to figure out in anything other than a simple assignment. For example, consider: String getSomething() { ... }; Integer getSomething() { ... }; String getOtherthing() { ... }; ... if (getSomething().equals(getOtherthing())) ... The compiler would have to figure out that both String and Integer have equals functions, so either one is valid at that point. Then it would have to notice that getOtherthing is a String, and Integer.equals(String) is unlikely, so probably what the writer wanted was String.equals(String). Do-able, but at that point I'm starting to see that in the general case, this could be a beast. And then suppose we add: Integer getOtherthing() { ... }; Now what does the compiler do with that IF statement? It could use the String versions of both functions, or the Integer, but not the String of one and the Integer of the other. At that point it would have to insist on a cast to tell it which, I guess. But the complexity is really get…
type: Answer
has comment: http://stackoverflow.com/comment/23878928
score: 15
upvote count: 15
has comment: http://stackoverflow.com/comment/23853654
downvote count: 0

http://stackoverflow.com/q/2737486
tagged with: dependencies
has answer: http://stackoverflow.com/a/2737503
favorite count: 0
tagged with: buildpath
accepted answer: http://stackoverflow.com/a/2737532
type: AnsweredQuestion
upvote count: 46
has answer: http://stackoverflow.com/a/2737532
tagged with: java
has comment: http://stackoverflow.com/comment/42396245
tagged with: eclipse
possible better answer: http://stackoverflow.com/a/2737503
score: 46
type: Question
answer count: 2
linked to: http://stackoverflow.com/q/13942628
has body: What is the use of Order And Export tab in Java Build Path
has title: What is the use of Order And Export tab in Java Build Path
downvote count: 0

http://stackoverflow.com/comment/2633848
type: Comment
comment on: http://stackoverflow.com/a/2621580
has text: you meant if `(rs != null && rs.next())` probably
score: 0
type: AnswerComment

http://stackoverflow.com/comment/89033534
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2779674
has text: I have only `Thread.currentThread().wait();` in the `main` function surrounded by try-catch for `InterruptedException`. Without `synchronized` block, it gives me the same exception `IllegalMonitorStateException`. What makes it reach illegal state now? It works inside `synchronized` block though.

http://stackoverflow.com/comment/2649889
has text: What am I being asked here? I've stated my position and by implication I disagree with the counter-position.
score: 0
comment on: http://stackoverflow.com/a/2624237
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/92110912
score: 0
type: AnswerComment
type: Comment
has text: yes. that httpClient when used will not validate https certificates
comment on: http://stackoverflow.com/a/37530625

http://stackoverflow.com/q/2779857
tagged with: persistence
favorite count: 0
accepted answer: http://stackoverflow.com/a/2780067
has title: How to know if a detached JPA entity has already been persisted or not?
score: 28
has answer: http://stackoverflow.com/a/2780067
upvote count: 28
type: AnsweredQuestion
downvote count: 0
has body: I have a JPA entity instance in the web UI layer of my application. I'd like to know at anytime if this entity has been already persisted in database or if it is only present in the user session. It would be in the business layer, I would use entitymanager.contains(Entity) method, but in my UI layer I think I need an extra attribute indicating whether the entity has been saved or not. How implement that ? I'm considering following option for the moment: a JPA attribute with a default value set by the database, but would force a new read after each update ? a non JPA attribute manually set in my code or automatically set by JPA? Any advice / other suggestions ? I'm using JPA 1 with Hibernate 3.2 implementation and would prefer stick to the standard.
tagged with: java
tagged with: hibernate
tagged with: orm
type: Question
tagged with: jpa
answer count: 1

http://stackoverflow.com/q/2602757
answer count: 3
accepted answer: http://stackoverflow.com/a/2603129
tagged with: jpa
has comment: http://stackoverflow.com/comment/2612266
downvote count: 0
has answer: http://stackoverflow.com/a/7106143
tagged with: jpa-2.0
favorite count: 0
has answer: http://stackoverflow.com/a/2603082
has title: Creating queries using Criteria API (JPA 2.0)
type: AnsweredQuestion
tagged with: java
possible better answer: http://stackoverflow.com/a/2603082
tagged with: criteria-api
has answer: http://stackoverflow.com/a/2603129
upvote count: 10
type: Question
tagged with: metamodel
score: 10
has body: I'm trying to create a query with the Criteria API from JPA 2.0, but I can't make it work. The problem is with the "between" conditional method. I read some documentation to know how I have to do it, but since I'm discovering JPA, I don't understand why it does not work. First, I can't see "creationDate" which should appear when I write "Transaction_." I thought it was maybe normal, since I read the metamodel was generated at runtime, so I tried to use 'Foo_.getDeclaredSingularAttribute("value")' instead of 'Foo_.value', but it still doesn't work at all. Here is my code : public List&lt;Transaction&gt; getTransactions(Date startDate, Date endDate) { EntityManager em = getEntityManager(); try { CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery&lt;Transaction&gt; cq = cb.createQuery(Transaction.class); Metamodel m = em.getMetamodel(); EntityType&lt;Transaction&gt; Transaction_ = m.entity(Transaction.class); Root&lt;Transaction&gt; transaction = cq.from(Transaction.class); // Error here. cannot find symbol. symbol: variable creationDate cq.where(cb.between(transaction.get(Transaction_.creationDate), startDate, endDate)); // I also tried this: // cq.where(cb.between(Transaction_.getDeclaredSingularAttribute("creationDate"), startDate, endDate)); List&lt;Transaction&gt; result = em.createQuery(cq).getResultList(); return result; } finally { em.close(); } } Can someone help me to figure this out? Thanks. EDIT : here is the Transaction source (almost nothing in it, since it was automatically generated by Netbeans, from my database) package projetjava.db; import java.io.Serializable; import java.util.Date; import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.Table; import javax.persistence.Temporal; import javax…

macos
tags question: http://stackoverflow.com/q/2614378
tags question: http://stackoverflow.com/q/2776359
tags question: http://stackoverflow.com/q/2666438
tags question: http://stackoverflow.com/q/2762492
tags question: http://stackoverflow.com/q/2641254
tags question: http://stackoverflow.com/q/2767220
tags question: http://stackoverflow.com/q/2598791
tags question: http://stackoverflow.com/q/2679413
tags question: http://stackoverflow.com/q/2759484
tags question: http://stackoverflow.com/q/2677194
type: Tag
tags question: http://stackoverflow.com/q/2746539
tags question: http://stackoverflow.com/q/2689453
tags question: http://stackoverflow.com/q/2707793
tags question: http://stackoverflow.com/q/2773454
tag name: macos
tags question: http://stackoverflow.com/q/2645140
tags question: http://stackoverflow.com/q/2732402
tags question: http://stackoverflow.com/q/2601124

http://stackoverflow.com/comment/109274908
type: Comment
has text: @SevastyanSavanyuk are you saying the Javadocs are incorrect? The `equals` method is said to returns `true` if and only if the list contains at least one element `e` such that `Objects.equals(o, e)`. Meanwhile, the Javadocs say that for `o` non-null, `Objects.equals(o,e)` is determined by using the equals method of the first argument. So according to the Javadocs, `hashCode` is irrelevant here.
comment on: http://stackoverflow.com/a/2642709
type: AnswerComment
score: 0

http://stackoverflow.com/a/5496920
has body: int in = Integer.valueOf(et.getText().toString()); //or int in2 = new Integer(et.getText().toString());
downvote count: 1
score: 51
type: Answer
answers question: http://stackoverflow.com/q/2709253
upvote count: 52

http://stackoverflow.com/comment/2808498
has text: Quite simply, it's lightweight. Although a full caching solution may be our only option, but we don't need the majority of it. Thanks for the thoughts though.
type: Comment
score: 0
comment on: http://stackoverflow.com/q/2773864
type: QuestionComment

http://stackoverflow.com/q/2690768
answer count: 2
downvote count: 0
tagged with: shell
tagged with: string
favorite count: 0
tagged with: buffer
tagged with: linux
type: UnansweredQuestion
score: 5
has body: I am trying to read the output of a shell command into a string buffer, the reading and adding the values is ok except for the fact that the added values are every second line in the shell output. for example, I have 10 rows od shell output and this code only stores the 1, 3, 5, 7, 9, row . Can anyone point out why i am not able to catch every row with this code ??? any suggestion or idea is welcomed :) import java.io.*; public class Linux { public static void main(String args[]) { try { StringBuffer s = new StringBuffer(); Process p = Runtime.getRuntime().exec("cat /proc/cpuinfo"); BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); while (input.readLine() != null) { //System.out.println(line); s.append(input.readLine() + "\n"); } System.out.println(s.toString()); } catch (Exception err) { err.printStackTrace(); } } }
has answer: http://stackoverflow.com/a/2691268
has answer: http://stackoverflow.com/a/2690778
tagged with: java
type: Question
has title: Storing Shell Output
upvote count: 5

http://stackoverflow.com/comment/2665423
has text: B.do() never finishes, once it implicitly always call B.Do() again. You should end up with a stackoverflow exception some time
type: QuestionComment
type: Comment
score: 1
comment on: http://stackoverflow.com/q/2649375

http://stackoverflow.com/a/2715313
score: 2
has comment: http://stackoverflow.com/comment/2741970
answers question: http://stackoverflow.com/q/2714327
downvote count: 0
has comment: http://stackoverflow.com/comment/2740935
has comment: http://stackoverflow.com/comment/2741358
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2741028
upvote count: 2
accepted answer of: http://stackoverflow.com/q/2714327
type: Answer
has comment: http://stackoverflow.com/comment/2740652
has body: In principle the code looks OK -- I would put some logging in to make sure the key you're generating is genuinely the one that is then read from the file (you're not doing something silly like generating data with a new key, then trying to read it with an old one, for example?)

http://stackoverflow.com/a/14007691
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/19339816
has body: This is all great, but what program are you using to write your java? Maybe you should consider using an IDE like Eclipse, as it can detect errors automatically and also adds imports. (I'm not sure if yours does this) It also tells you what the problem with your program is 'in english'. Also, consider this class as maybe an easier and less complicated way of doing a calculator: public class Calculator { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("Enter an Operator: "); String in = sc.next(); char oper = in.charAt(0); System.out.print("Enter a number: "); in = sc.next(); double num1 = Double.parseDouble(in); System.out.print("Enter another number: "); in = sc.next(); double num2 = Double.parseDouble(in); if(oper == '+') { double result = num1 + num2; System.out.println(result); } else if(oper == '-') { double result = num1 - num2; System.out.println(result); } else if(oper == 'x') { double result = num1 * num2; System.out.println(result); } else if(oper == '/') { double result = num1 / num2; System.out.println(result); } else { double result = num1 % num2; System.out.println(result); } System.out.println("Hope this helped your mathmatical troubles!"); } } And as a matter of habit, instead of doing: import java.util.*; it is better to do: import java.util.Scanner; This probably doesn't make much of a difference here, but if you are running a much bigger program importing the whole of java.util will considerably slow down your program. Hope this helps!
has comment: http://stackoverflow.com/comment/19345176
answers question: http://stackoverflow.com/q/2734227
downvote count: 0
has comment: http://stackoverflow.com/comment/19348814
type: Answer

http://stackoverflow.com/comment/104681038
score: 2
type: AnswerComment
type: Comment
has text: This is virtually identical to the accepted answer. It is redundant.
comment on: http://stackoverflow.com/a/58112587

http://stackoverflow.com/a/2603443
has comment: http://stackoverflow.com/comment/2613235
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/2613167
has body: I suggest to take a look at web application frameworks such as Spring's Roo or Grails. Sadly I have no experience with Roo. But I do have some experience with Grails. With Grails you will be working mostly with Groovy, a language similar to Python, but still using the JVM. You'll still have the option to use Java anywhere you like (I think). Grails (and maybe Roo too?) manages Spring and Hibernate for you. As for books on Grails, I recommend "Grails in Action". I have read a little of "Grails 1.1 Web Application Development" and it also seems to be a good reference. BTW, netbeans supports Grails too.
downvote count: 0
answers question: http://stackoverflow.com/q/2603229
type: Answer

http://stackoverflow.com/a/2622733
has body: You can implement queueing by hand, using MySQL or some other persistent mechanism, but you could also use JMS for queueing. It's pretty much a perfect match for just this kind of situations. In that case I would be tempted by splitting the mail component off from the main app, and let the two communicate using JMS. The main app puts a message in the JMS and the mailer app would subscribe to the queue and try to process the messages. JMS can be made persistent (to e.g. MySQL) pretty easily by configuration. The advantage of spliting the webapp is that you abstract away the notification mechanism and could in the future implement e.g. Google Wave or IRC or whatever without having to touch your main app. Someone else suggested to use a postfix or sendmail and let them handle the queueing. That is also a great solution, especially if you put the postfix or sendmail on localhost and let it route the messages further. Do try to configure that mailer program such that only mail from localhost is allowed to be routed, to prevent creating an open mailer :) EDIT clarified the use of JMS + comment on local mailer daemon
has comment: http://stackoverflow.com/comment/2635835
has comment: http://stackoverflow.com/comment/2635139
upvote count: 1
has comment: http://stackoverflow.com/comment/2635457
type: Answer
answers question: http://stackoverflow.com/q/2622721
downvote count: 0
score: 1

http://stackoverflow.com/a/2748915
has comment: http://stackoverflow.com/comment/2778840
downvote count: 4
has comment: http://stackoverflow.com/comment/2778851
has comment: http://stackoverflow.com/comment/2778844
has body: Edit: Not quite. See comments below. Java doesn't directly run on anything. It needs to be converted to bytecode by a JVM. Because JVMs exist for all major platforms, this makes Java platform-independent THROUGH the JVM.
upvote count: 1
answers question: http://stackoverflow.com/q/2748910
score: -3
type: Answer

http://stackoverflow.com/a/65920039
downvote count: 0
has body: I found a nice description, when to use static methods: There is no hard and fast, well written rules, to decide when to make a method static or not, But there are few observations based upon experience, which not only help to make a method static but also teaches when to use static method in Java. You should consider making a method static in Java : If a method doesn't modify state of object, or not using any instance variables. You want to call method without creating instance of that class. A method is good candidate of being static, if it only work on arguments provided to it e.g. public int factorial(int number){}, this method only operate on number provided as argument. Utility methods are also good candidate of being static e.g. StringUtils.isEmpty(String text), this a utility method to check if a String is empty or not. If function of method will remain static across class hierarchy e.g. equals() method is not a good candidate of making static because every Class can redefine equality. Source is here
type: Answer
answers question: http://stackoverflow.com/q/2671496
score: 4
upvote count: 4

http://stackoverflow.com/comment/35405409
type: Comment
score: 0
type: AnswerComment
has text: I believe a system of max number of login tries per minute is more user-friendly. If the user tries to login too fast, it will always fail. This could require a handler BEFORE the authentication. Does anyone know how to do this instead?
comment on: http://stackoverflow.com/a/2686268

http://stackoverflow.com/a/12228578
type: Answer
answers question: http://stackoverflow.com/q/2613404
score: 0
has body: What about Snippetory? It's full java, (even your logic is written in java!) Templates are loaded by the UriResolver, with implementations for calsspath, file system and URL. It can be used outside Servlets, for example as ad hoc template like String.format. It's entirely based on parametrized inclusion of templates. The docs are ok and it's much simpler than the script based engines, so you really don't need that much. And a new version with great new freatures is coming soon, I think

http://stackoverflow.com/a/2775157
has comment: http://stackoverflow.com/comment/2818474
has body: Such complex SQL should be in a prepared statement, not put together by a String.format to avoid SQL injection issues. I do one of two things: Wrap it in a callable statement or put it in a configuration/xml file. Java source files are a bad place for complex SQL. That being said, IDEA has a language formatting feature which will format strings in Java to look like a different language (based on the method they are passed to or based on an annotation), so that can help. Edit: Given your scenario, I agree callable statements may not be workable. Prepared statements are still worth it, even for internal development, just because a parameter with an apostrophe can blow everything up (even if there is no attacker), so it is still worth it, IMO, to do the extra effort to create the string dynamically (String.format or anything else) in code only for the parts that cannot be passed as parameters (such temporary table names as in your example), and then use that as a prepared statement passing proper parameters for the rest. As for keeping it less ugly, it looks like a configuration/xml type file is what I would go for.
score: 0
answers question: http://stackoverflow.com/q/2775113
type: Answer
has comment: http://stackoverflow.com/comment/2809584
has comment: http://stackoverflow.com/comment/2816760
has comment: http://stackoverflow.com/comment/2818980
has comment: http://stackoverflow.com/comment/2818939

http://stackoverflow.com/comment/97926883
comment on: http://stackoverflow.com/a/43532092
type: AnswerComment
type: Comment
has text: This example seems to still keep the whole workbook in memory before streaming it out. Interesting, whether the wb.write(out) call can be placed into the for loop in order to address the initial question.
score: 1

web.xml
tags question: http://stackoverflow.com/q/2669375
tag name: web.xml
type: Tag
tags question: http://stackoverflow.com/q/2768500
tags question: http://stackoverflow.com/q/2741366

http://stackoverflow.com/q/2626012
has answer: http://stackoverflow.com/a/2627451
tagged with: eclipse
type: Question
has title: How to manage Libraries/jar files in eclipse?
has body: I might be missing something but how do you manage Java projects in eclipse that need a lot of Jar files. I know maven manages libraries well if there are new updates but maybe I'm missing something, is there a way that eclipse can update new jar files (it would be especially useful for projects using apache-commons, say). I don't want to sound like asking for a feature request, but I'm looking at if there are ways to keep libraries jar files that a Java project uses to keep them updated automatically the way maven does. With more languages coming with this type of features, finding the right Jar files probably should be easier than this.
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/2626097
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2627451
tagged with: java
accepted answer: http://stackoverflow.com/a/2626097

http://stackoverflow.com/q/2756430
has body: I have to draw a line graph for some inputs (x/y), what is the best java client library for graph plotting
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2756436
upvote count: 6
has title: Java graph plotting library
tagged with: java
downvote count: 1
type: Question
score: 5
answer count: 1

http://stackoverflow.com/a/41447549
upvote count: 4
score: 2
has body: I came across this question and thought I'd add something that was not mentioned. In general, I agree with Pascal's answer here. However, I don't think constants on an interface are "always" an antipattern. For example, if the constants that you are defining are part of a contract for that interface, I think the interface is a great place for the constants. In some cases, its just not appropriate to privately validate your parameters without exposing the contract to the users of your implementation. Without a public facing contract, users can only guess what your validating with, short of decompiling the class and reading your code. So if you implement an interface and the interface has the constants you use in ensuring your contracts (like integer ranges for example), then a user of your class can be sure they are using the interface instance correctly by checking against the constants in the interface themselves. This would be impossible if the constants were private to your implementation or your implementation was package private or something.
has comment: http://stackoverflow.com/comment/98464976
has comment: http://stackoverflow.com/comment/98413049
has comment: http://stackoverflow.com/comment/83413974
has comment: http://stackoverflow.com/comment/134661674
answers question: http://stackoverflow.com/q/2659593
downvote count: 2
type: Answer

http://stackoverflow.com/comment/24452233
type: Comment
comment on: http://stackoverflow.com/a/2634490
score: 0
type: AnswerComment
has text: problem with this solution is that once you attached it then everytime it is refreshed (AjaxRequestTarget#addComponent) it's focused (or at least focus javascript is evaluated) using AjaxRequestTarget#focusComponent is one shot focus so it's better suited for behaviour requested in question ("radio button is selected")

http://stackoverflow.com/comment/2780981
type: AnswerComment
has text: @josefx yes it is not clear in most cases , but is there any ambiguity when you say "throw new RuntimeException();" ??
comment on: http://stackoverflow.com/a/2750645
type: Comment
score: 0

http://stackoverflow.com/q/2721258
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2721525
tagged with: java
tagged with: memory
type: Question
has title: Java Memory Overhead
downvote count: 0
score: 4
possible better answer: http://stackoverflow.com/a/2721467
has body: I would like to ask about Memory Overhead in java, I have a large ArrayList (61,770 items), and trying to calculate the amount of memory taken by each item (counting the object and its ArrayList entry), by profiling the app i get that after all the data is loaded, the heap takes ~ 25Mb. when the ArrayList has only 2 items the heap takes ~1Mb , so roughly: (24*1024*1024)/61,768 = 407 bytes. however, when i count the fields of the each object, i get 148 bytes(not including the ArrayList, and assuming int=4,float=4,reference=4), I am curious to know where did all of those extra bytes came from... i can guess that since the objects I store in the ArrayList are implementing an interface, they store extra values, maybe the VM stores a 4byte function pointer for each implemented method? the interface they implement have 20 functions so thats 80 more bytes, totaling 228 bytes, still not close to the 400 bytes measured. any help would be appreciated. wow, thanks for all the great answers. @Bolo: thanks for the link ,with this class i measure ~350 bytes per object so I can least confirm the source of the large memory usage. @Yuval A: thank you for that presentation, a valuable source of information. @Ukko: point noted. @Jayan: right now NetBeans profiler is giving me errors when i try to dump the heap, will try later again.
upvote count: 4
tagged with: arraylist
has answer: http://stackoverflow.com/a/2721467
has comment: http://stackoverflow.com/comment/2747473
has comment: http://stackoverflow.com/comment/2747424
tagged with: overhead
favorite count: 0
has answer: http://stackoverflow.com/a/2721498
has comment: http://stackoverflow.com/comment/2747624
has answer: http://stackoverflow.com/a/2721435
answer count: 5
has answer: http://stackoverflow.com/a/2721950
tagged with: interface
accepted answer: http://stackoverflow.com/a/2721498

http://stackoverflow.com/comment/9074193
has text: The quartz issue is fixed with Quartz 2.1. Unfortunately, Spring 3.1 is based on Quartz 1.8 and an update to 2.0 is considered for Spring 3.2 at the earliest. Source: https://jira.springsource.org/browse/SPR-7987
comment on: http://stackoverflow.com/a/6772253
type: AnswerComment
type: Comment
score: 2

http://stackoverflow.com/a/28900749
answers question: http://stackoverflow.com/q/2711858
score: 28
has comment: http://stackoverflow.com/comment/53767393
type: Answer
has comment: http://stackoverflow.com/comment/49477294
has comment: http://stackoverflow.com/comment/94684555
has comment: http://stackoverflow.com/comment/54007976
upvote count: 29
has body: I would like to improve weston's answer for API 21 Android 5.0. Cause Under API 21, most of the text styles include fontFamily setting, like: Which applys the default Roboto Regular font: sans-serif The original answer fails to apply monospace font, because android:fontFamily has greater priority to android:typeface attribute (reference). Using Theme.Holo.* is a valid workaround, because there is no android:fontFamily settings inside. Solution Since Android 5.0 put system typeface in static variable Typeface.sSystemFontMap (reference), we can use the same reflection technique to replace it: protected static void replaceFont(String staticTypefaceFieldName, final Typeface newTypeface) { if (isVersionGreaterOrEqualToLollipop()) { Map<String, Typeface> newMap = new HashMap<String, Typeface>(); newMap.put("sans-serif", newTypeface); try { final Field staticField = Typeface.class .getDeclaredField("sSystemFontMap"); staticField.setAccessible(true); staticField.set(null, newMap); } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } else { try { final Field staticField = Typeface.class .getDeclaredField(staticTypefaceFieldName); staticField.setAccessible(true); staticField.set(null, newTypeface); } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } }
has comment: http://stackoverflow.com/comment/58696493
downvote count: 1

http://stackoverflow.com/comment/2692871
type: AnswerComment
comment on: http://stackoverflow.com/a/2671777
type: Comment
has text: Your answer is not incorrect. It just focuses on the SDK/KDK. My question is about all the computer science in the kindle, including the general things that are not specific to Amazon.
score: 0

http://stackoverflow.com/q/2607515
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/2617753
has comment: http://stackoverflow.com/comment/2617856
has comment: http://stackoverflow.com/comment/2617643
score: 3
has comment: http://stackoverflow.com/comment/2617685
downvote count: 0
tagged with: outputstream
favorite count: 0
has comment: http://stackoverflow.com/comment/2617894
has answer: http://stackoverflow.com/a/2607724
type: Question
tagged with: sockets
answer count: 2
has body: I have this code: public void post(String message) { output.close(); final String mess = message; (new Thread() { public void run() { while (true) { try { output.println(mess); System.out.println("The following message was successfully sent:"); System.out.println(mess); break; } catch (NullPointerException e) { try {Thread.sleep(1000);} catch (InterruptedException ie) {} } } } }).start(); } As you can see I close the socket in the very beginning of the code and then try to use it to send some information to another computer. The program writes me "The following message was successfully sent". It means that the NullPointerException was not thrown. So, does Java throw no exception if it tries to use a closed output stream of a socket? Is there a way to check if a socket is closed or opened? ADDED I initialize the socket in the following way: clientSideSocket = new Socket(hostname,port); PrintWriter out = new PrintWriter(clientSideSocket.getOutputStream(), true); browser.output = out;
upvote count: 3
tagged with: java
has answer: http://stackoverflow.com/a/2611552
tagged with: network-programming
has title: How do I check if output stream of a socket is closed?
has comment: http://stackoverflow.com/comment/2617778

http://stackoverflow.com/comment/2661644
type: Comment
comment on: http://stackoverflow.com/a/2641677
score: 0
type: AnswerComment
has text: Er, sorry, I suppose you didn't make that choice, you're just going with what writeLong() did.

http://stackoverflow.com/q/2742237
has body: I am writing a windows batch file to do the following things: Display a picture in the middle of the screen, showing the beautiful icon of my software. Kick of the launch of the web server. Finish displaying the picture. Point the browser to the start page. I have already know how to do it in step 2 and 4. However, I have the following questions in writing the windows batch file: 1. How do I know that the launch of the web server is finished, taking jetty as the example? 2. How do I display a picture and stop displaying it when I want to? Here is what I have got so far: ::here I would like to display the picture start javaw -jar start.jar ::Starting jetty here ::here I would like to stop displaying the picture start http://localhost:8080/myApp ::Pointing the browser to the page Thank you in advance for your help.
type: Question
has title: How to launch a web server and point the browser to it when it finishes?
has answer: http://stackoverflow.com/a/2748452
tagged with: batch-file
answer count: 1
tagged with: windows
accepted answer: http://stackoverflow.com/a/2748452
tagged with: jetty
type: AnsweredQuestion
score: 0
tagged with: java

http://stackoverflow.com/a/33759918
upvote count: 2
downvote count: 0
type: Answer
has body: Most of the answers on this forum have been talking about the Exception hierarchy and the Java compiler not catching them but I would try to answer this more from the design perspective and why perhaps things were designed like this. Basically when you call a function(or write some code) an exception can be thrown out of it based on three different situations: Based on an unavoidable condition like unavailability of network or some expected file missing on the file system. Based on an avoidable but known condition like Integer.parseInt(String) can throw NumberFormatException if the caller passes a unconvertible string like "Hello", but the caller may ensure proper validations in place before passing in any string to the function and completely do away with the possibility of generating the exception. A common use case could be validating the form field age on a web page before passing it to deeper layers that make the conversion. An unknown or unexpected condition Any time some line of code can throw an exception in your code because there was some mistake that you did and didn't observe the error condition until it blasted off in production, generally happens with NullPointer Reference, IndexOutOfBounds etc, which if observed would possibly fall in category 2. Exceptions of category 1 are generally designed as Checked Exceptions because it needs to enforce the check for unavoidable error conditions, and to enforce their fallbacks. For examples IOException is checked exception, because in case you are opening a file, there can be a lot many things that may go wrong(like file may be deleted, permissions etc.)and pre validating all of them can be very cumbersome. Exceptions of the 2nd type are generally modeled as Unchecked Exceptions because you might have your pre validation in place and it might be irritating to be forced to use try and catch for situations that you have already have taken care of. Exceptions of the 3rd type need not be even worried about generally…
answers question: http://stackoverflow.com/q/2750638
score: 2

http://stackoverflow.com/q/2784703
tagged with: jms
favorite count: 0
has answer: http://stackoverflow.com/a/2815312
has title: JMS message. Model to include data or pointers to data?
has answer: http://stackoverflow.com/a/2787697
has answer: http://stackoverflow.com/a/2785079
linked to: http://stackoverflow.com/q/2418292
possible better answer: http://stackoverflow.com/a/2784939
answer count: 4
accepted answer: http://stackoverflow.com/a/2787697
type: AnsweredQuestion
upvote count: 3
type: Question
tagged with: jakarta-ee
score: 3
tagged with: java
has body: I am trying to resolve a design difference of opinion where neither of us has experience with JMS. We want to use JMS to communicate between a j2ee application and the stand-alone application when a new event occurs. We would be using a single point-to-point queue. Both sides are Java-based. The question is whether to send the event data itself in the JMS message body or to send a pointer to the data so that the stand-alone program can retrieve it. Details below. I have a j2ee application that supports data entry of new and updated persons and related events. The person records and associated events are written to an Oracle database. There are also stand-alone, separate programs that contribute new person and event records to the database. When a new event occurs through any of 5-10 different application functions, I need to notify remote systems through an outbound interface using an industry-specific standard messaging protocol. The outbound interface has been designed as a stand-alone application to support scalability through asynchronous operation and by moving it to a separate server. The j2ee application currently has most of the data in memory at the time the event is entered. The data would consist of approximately 6 different objects; a person object and some with multiple instances for an average size in the range of 3000 to 20,000 bytes. Some special cases could be many times this amount. From a performance and reliability perspective, should I model the JMS message to pass all the data needed to create the interface message, or model the JMS message to contain record keys for the data and have the stand-alone Java application retrieve the data to create the interface message?
downvote count: 0
has answer: http://stackoverflow.com/a/2784939

http://stackoverflow.com/comment/26827623
comment on: http://stackoverflow.com/a/2629393
score: 1
has text: @EJP did you by any chance read your "reference"? Because it says "Managed pointers in the Java heap point to objects which are aligned on 8-byte address boundaries", which is precisely what I said: Java pointers/references point directly to objects on the heap. It is up to the GC to then keep them in sync if/when it moves an object. And no, I am sorry to burst your bubble, but it is not "incumbent on me" to teach you how compilers work. I... don't... care. If you want to believe that the designers of the JVM *wanted* to make it slower than necessary, feel free. Not. My. Problem.
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2671045
type: QuestionComment
has text: what is a "disk based (Hash)Map"?
comment on: http://stackoverflow.com/q/2654709
type: Comment
score: 1

http://stackoverflow.com/a/2748080
has body: For a pure-java solution that can scale to support concurrent rendering, you could use a java HTML4/CSS2 browser, such as Cobra, that provides a Swing component for the GUI. When you instantiate this component, you can call it's paint(Graphics g) method to draw itself into an off-screen image E.g. Component c = ...; // the browser component BufferedImage bi = new BufferedImage(c.getWidth(), c.getHeight(), TYPE_INT_RGB) Graphics2d g = bi.createGraphics(); c.paint(g); You can then use the java image API to save this as a JPG. JPEGImageEncoder encoder = JPEGCodec.createEncoder(new FileOutputStream("screen.jpg")); enncoder.encode(bi); // encode the buffered image Java-based browsers typically pale in comparison with the established native browsers. However, as your goal is static images, and not an interactive browser, a java-based browser may be more than adequate in this regard.
type: Answer
score: 3
upvote count: 3
downvote count: 0
answers question: http://stackoverflow.com/q/2746289

http://stackoverflow.com/comment/39971738
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2749445
has text: @Pacerier - not really; consider irrational numbers.
type: Comment

http://stackoverflow.com/a/2746782
has comment: http://stackoverflow.com/comment/2776418
has comment: http://stackoverflow.com/comment/2776465
answers question: http://stackoverflow.com/q/2746744
has comment: http://stackoverflow.com/comment/2776316
has comment: http://stackoverflow.com/comment/2776496
score: 4
has body: edit - Looks like I was wrong, but leaving my original answer here anyway: Are you sure that it works with a List&lt;Integer&gt;? It shouldn't. The method subList() returns a separate List. If you remove elements from that list, it shouldn't affect the original list. The API docs for List.subList() say this: Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal, the returned list is empty.) The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. Clearing a list is not a non-structural change; only changing the elements in the list are non-structural changes. This has nothing to do with whether your POJO has equals or hashCode methods or not. edit - I just tried it out with an ArrayList and it does work (not only with Integer, but also with my own object as a list element).
has comment: http://stackoverflow.com/comment/2777676
downvote count: 1
upvote count: 5
has comment: http://stackoverflow.com/comment/2777531
has comment: http://stackoverflow.com/comment/2776299
type: Answer
has comment: http://stackoverflow.com/comment/2776325

http://stackoverflow.com/a/2699379
answers question: http://stackoverflow.com/q/2699181
has body: To do this, I need to use my webapp config .xml files to inject the controller, however, all my configuration (and other associated files that the configs reference) are in the src/main/webapp directory What are those files that you also need during unit tests exactly? I do not want to have to copy my entire webapp in to my src/test/resources folder just for the purpose of testing - is there any other way to be able to access them? No. If you want them to be on the classpath, put them either in src/main/resources or src/test/resources, files under src/main/webapp are not on the classpath because they're not supposed to.
has comment: http://stackoverflow.com/comment/105706696
score: 0
has comment: http://stackoverflow.com/comment/2721960
type: Answer

http://stackoverflow.com/comment/2738091
comment on: http://stackoverflow.com/q/2713216
type: Comment
score: 1
type: QuestionComment
has text: Should a line like 'key1 valueA, valueB, valueC' map to 1 key/value pair ('key1' => 'valueA, valueB, valueC') or 3 key/value pairs ('key1' => 'valueA' and 'key1' => 'valueB and 'key1' => 'valueC')?

http://stackoverflow.com/comment/2686952
type: Comment
comment on: http://stackoverflow.com/a/2668702
score: 0
has text: The first example is actually hypothetical. I can hardly imagine something like this in my code :) Regarding the second example. Can I say in my documentation that class CustomException is thread-safe, and sleep well after?
type: AnswerComment

http://stackoverflow.com/comment/2726224
score: 0
has text: +1... log4j, used with good Exception handling, does the job very well.
type: AnswerComment
comment on: http://stackoverflow.com/a/2702907
type: Comment

http://stackoverflow.com/a/2657828
answers question: http://stackoverflow.com/q/2657819
upvote count: 6
type: Answer
downvote count: 0
score: 6
has body: Its the Assignment by bitwise OR v1 |= v2; is short for: v1 = v1 | v2;

http://stackoverflow.com/comment/2802266
comment on: http://stackoverflow.com/a/2769058
has text: Binary dependencies are dangerous things to recommend. I helped a customer last week debug a class loader issue caused by having 2 copies of the same binary jar in 2 different bundles. When they tried to pass instances of objects from the binary jar from one bundle to the other there were class cast exception. It is much better to use the import/export package statements as they were intended. In the customer's case the solution was to make a bundle from the binary jar that exported the required packages. Then both customer bundles imported the packages they needed from the new bundle.
score: 0
type: AnswerComment
type: Comment

jsf
tags question: http://stackoverflow.com/q/2735098
tags question: http://stackoverflow.com/q/2713364
tags question: http://stackoverflow.com/q/2686664
tags question: http://stackoverflow.com/q/2720457
tags question: http://stackoverflow.com/q/2673716
type: Tag
tags question: http://stackoverflow.com/q/2667873
tags question: http://stackoverflow.com/q/2696455
tags question: http://stackoverflow.com/q/2740892
tags question: http://stackoverflow.com/q/2713079
tags question: http://stackoverflow.com/q/2731964
tags question: http://stackoverflow.com/q/2744633
tags question: http://stackoverflow.com/q/2760832
tags question: http://stackoverflow.com/q/2697347
tags question: http://stackoverflow.com/q/2689245
tags question: http://stackoverflow.com/q/2773225
tags question: http://stackoverflow.com/q/2691003
tags question: http://stackoverflow.com/q/2692324
tags question: http://stackoverflow.com/q/2620942
tags question: http://stackoverflow.com/q/2606249
tags question: http://stackoverflow.com/q/2719549
tags question: http://stackoverflow.com/q/2693373
tags question: http://stackoverflow.com/q/2605287
tags question: http://stackoverflow.com/q/2753775
tags question: http://stackoverflow.com/q/2683889
tags question: http://stackoverflow.com/q/2756772
tags question: http://stackoverflow.com/q/2700567
tags question: http://stackoverflow.com/q/2766287
tags question: http://stackoverflow.com/q/2631130
tags question: http://stackoverflow.com/q/2684407
tags question: http://stackoverflow.com/q/2735167
tags question: http://stackoverflow.com/q/2725812
tags question: http://stackoverflow.com/q/2673487
tags question: http://stackoverflow.com/q/2632451
tags question: http://stackoverflow.com/q/2701094
tags question: http://stackoverflow.com/q/2764150
tags question: http://stackoverflow.com/q/2691393
tag name: jsf
tags question: http://stackoverflow.com/q/2779320
tags question: http://stackoverflow.com/q/2699583
tags question: http://stackoverflow.com/q/2747422
tags question: http://stackoverflow.com/q/2656512
tags question: http://stackoverflow.com/q/2743483
tags question: http://stackoverflow.com/q/2654712
tags question: http://stackoverflow.com/q/2773432
tags question: http://stackoverflow.com/q/2626666
tags question: http://stackoverflow.com/q/2678207
tags question: http://stackoverflow.com/q/2714050
tags question: http://stackoverflow.com/q/2727672
tags question: http://stackoverflow.com/q/2714508
tags question: http://stackoverflow.com/q/2777852
tags question: http://stackoverflow.com/q/2661329
tags question: http://stackoverflow.com/q/2682196
tags question: http://stackoverflow.com/q/2721451

http://stackoverflow.com/comment/82867898
has text: I think there is a more significant readability issues in that code that the condition. Look at strcmp. Not exactly effortless IMO.
comment on: http://stackoverflow.com/a/14753618
score: 1
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2698665
comment on: http://stackoverflow.com/q/2679085
type: Comment
type: QuestionComment
has text: @giri: you could check out how some Open Source Java project does actually send an email. *JForum* for example is written in Java and does send confirmation/verification email: http://jforum.net (this is not really answer, hence I made it a comment ; )
score: 0

http://stackoverflow.com/a/2651727
has comment: http://stackoverflow.com/comment/2667860
upvote count: 10
has comment: http://stackoverflow.com/comment/2667834
downvote count: 0
has body: Java conveniently has the instanceof operator (JLS 15.20.2) to test if a given object is of a given type. if (x instanceof List&lt;?&gt;) { List&lt;?&gt; list = (List&lt;?&gt;) x; // do something with list } else if (x instanceof Collection&lt;?&gt;) { Collection&lt;?&gt; col = (Collection&lt;?&gt;) x; // do something with col } One thing should be mentioned here: it's important in these kinds of constructs to check in the right order. You will find that if you had swapped the order of the check in the above snippet, the code will still compile, but it will no longer work. That is the following code doesn't work: // DOESN'T WORK! Wrong order! if (x instanceof Collection&lt;?&gt;) { Collection&lt;?&gt; col = (Collection&lt;?&gt;) x; // do something with col } else if (x instanceof List&lt;?&gt;) { // this will never be reached! List&lt;?&gt; list = (List&lt;?&gt;) x; // do something with list } The problem is that a List&lt;?&gt; is-a Collection&lt;?&gt;, so it will pass the first test, and the else means that it will never reach the second test. You have to test from the most specific to the most general type.
type: Answer
answers question: http://stackoverflow.com/q/2651632
score: 10

http://stackoverflow.com/comment/2815172
has text: Constructor of class that extended Thread class ...
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2780255
score: 1

http://stackoverflow.com/comment/2725301
score: 0
type: AnswerComment
has text: That fixed the issue! - It's odd how it randomly stopped working, and didn't pick up the libraries from the build path... hmm
type: Comment
comment on: http://stackoverflow.com/a/2702204

http://stackoverflow.com/comment/77134951
type: Comment
has text: `Matchers` is now deprecated in order to avoid a name clash with `org.hamcrest.Matchers` class and will likely be removed in mockito v3.0. Use `ArgumentMatchers` instead.
type: AnswerComment
score: 5
comment on: http://stackoverflow.com/a/2634588

http://stackoverflow.com/comment/2677000
type: Comment
has text: What regex flavor are you using? Javascript? Java? .NET? PERL? Python?
score: 0
comment on: http://stackoverflow.com/q/2659853
type: QuestionComment

http://stackoverflow.com/a/2762451
type: Answer
has comment: http://stackoverflow.com/comment/2794704
has body: Try using UTF-8 for the characterEncoding param in your JDBC url, rather than UTF8 (notice the dash). That happened to me before.
upvote count: 1
has comment: http://stackoverflow.com/comment/2794734
answers question: http://stackoverflow.com/q/2762416
downvote count: 0
score: 1

http://stackoverflow.com/comment/33022028
score: 0
comment on: http://stackoverflow.com/q/2777509
type: Comment
type: QuestionComment
has text: This question appears to be off-topic because it is about number theory. Try math.stackexchange.com.

http://stackoverflow.com/comment/2606466
type: AnswerComment
type: Comment
has text: How to place it one above the other? plz
comment on: http://stackoverflow.com/a/2597809
score: 0

http://stackoverflow.com/q/2598380
has body: I have a ManyToMany relationship between two classes: ClassA and ClassB, but when the table for this relationship (table called objectA_objectB) there is no primary key on it. In my ClassA I have the following: @ManyToMany(fetch=FetchType.LAZY) @OrderBy(value="name") @JoinTable(name="objectA_objectB", joinColumns= @JoinColumn(name="idObjectA", referencedColumnName="id"), inverseJoinColumns= @JoinColumn(name="idObjectB", referencedColumnName="id") ) private List&lt;ClassB&gt; objectsB; and in my ClassB I have the reversed relation @ManyToMany List&lt;ClassA&gt; objectsA; I just want to make a primary key of both id's but I need to change the name of the columns as I do. Why is the PK missing? How can I define it? I use JPA 2.0 Hibernate implementation, if this helps. Thanks.
linked to: http://stackoverflow.com/q/1212058
type: Question
downvote count: 0
answer count: 1
tagged with: persistence
favorite count: 0
tagged with: jpa-2.0
has answer: http://stackoverflow.com/a/2598618
type: UnansweredQuestion
upvote count: 1
has title: ManyToMany Relation does not create the primary key
score: 1
tagged with: java
tagged with: hibernate

http://stackoverflow.com/a/2662942
has body: You sound like you want to be able to change both objects and schema according to user input at runtime. This sounds like a chaotic recipe for disaster to me. I've never seen it done. I have seen general schemas that incorporate foreign key relationships to generic tables of name/value pairs, but these tend to become infinitely flexible abstractions that can neither be easily understood nor get out of their own way when it comes to performance. I'm betting that your users really don't want infinite flexibility. I'd caution you against taking this direction. Better to get your real use cases straight. Anything is possible, of course. My direct experience tells me that it's a bad idea that your users will hate if you can pull it off. Best of luck.
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/2662915
upvote count: 2
type: Answer

http://stackoverflow.com/comment/2810495
type: Comment
comment on: http://stackoverflow.com/q/2775401
score: 0
type: QuestionComment
has text: I know you said you double checked but... are you exporting with a particular key, or using a debug keystore? And are you using the correct API key for whichever process you're using? Because otherwise your code looks fine.

http://stackoverflow.com/comment/2791368
score: 0
has text: @DJClayworth: That distinction does indeed make asserts seem MUCH more viable in my own head, thank you.
comment on: http://stackoverflow.com/q/2759199
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2746561
has body: I want to show an image on a jasper report. I have the following on the .jrxml: &lt;image&gt; &lt;reportElement x="181" y="0" width="209" height="74"/&gt; &lt;imageExpression class="java.lang.String"&gt;&lt;![CDATA["logo.jpg"]]&gt;&lt;/imageExpression&gt; &lt;/image&gt; The image logo.jpg is in the same directory as the .jrxml. By just putting that it didn't work for me. I googled a bit and found out that jasper report considers what i put on the .jrxml as a relative path to the JVM directory and that to change this I need to pass as a "REPORT_FILE_RESOLVER" parameter a FileResolver that returns the file. So, I did the following in my .java (is located in same place as the .jrxml and the image) FileResolver fileResolver = new FileResolver() { @Override public File resolveFile(String fileName) { return new File(fileName); } }; HashMap&lt;String, Object&gt; parameters = new HashMap&lt;String, Object&gt;(); parameters.put("REPORT_FILE_RESOLVER", fileResolver); ... Which should return the expected file, but I still get a net.sf.jasperreports.engine.JRException: Error loading byte data : logo.jpg at net.sf.jasperreports.engine.util.JRLoader.loadBytes(JRLoader.java:301) at net.sf.jasperreports.engine.util.JRLoader.loadBytesFromLocation(JRLoader.java:479) at net.sf.jasperreports.engine.JRImageRenderer.getInstance(JRImageRenderer.java:180) ... What am I doing wrong? Thanks!
tagged with: jasper-reports
has title: How to show an image on jasper report?
score: 35
tagged with: java
has answer: http://stackoverflow.com/a/7843533
accepted answer: http://stackoverflow.com/a/2759295
answer count: 4
type: AnsweredQuestion
upvote count: 35
linked to: http://stackoverflow.com/q/33547588
downvote count: 0
has answer: http://stackoverflow.com/a/2746768
favorite count: 0
type: Question
has comment: http://stackoverflow.com/comment/69046973
has answer: http://stackoverflow.com/a/10574189
has answer: http://stackoverflow.com/a/2759295
possible better answer: http://stackoverflow.com/a/10574189

http://stackoverflow.com/q/2700680
has answer: http://stackoverflow.com/a/3017146
accepted answer: http://stackoverflow.com/a/3017146
score: 8
has answer: http://stackoverflow.com/a/2701431
has body: Suppose a Table per subclass inheritance relationship which can be described bellow (From wikibooks.org - see here) Notice Parent class is not abstract @Entity @Inheritance(strategy=InheritanceType.JOINED) public class Project { @Id private long id; // Other properties } @Entity @Table(name="LARGEPROJECT") public class LargeProject extends Project { private BigDecimal budget; } @Entity @Table(name="SMALLPROJECT") public class SmallProject extends Project { } I have a scenario where i just need to retrieve the Parent class. Because of performance issues, What should i do to run a HQL query in order to retrieve the Parent class and just the Parent class without loading any subclass ???
type: AnsweredQuestion
tagged with: performance
downvote count: 0
has answer: http://stackoverflow.com/a/50261712
tagged with: java
tagged with: hibernate
tagged with: hql
upvote count: 8
type: Question
has title: Table per subclass inheritance relationship: How to query against the Parent class without loading any subclass ??? (Hibernate)
possible better answer: http://stackoverflow.com/a/2701431
tagged with: inheritance
favorite count: 0
answer count: 3

http://stackoverflow.com/a/2756277
accepted answer of: http://stackoverflow.com/q/2756243
downvote count: 0
answers question: http://stackoverflow.com/q/2756243
has comment: http://stackoverflow.com/comment/2829403
upvote count: 3
type: AcceptedAnswer
has body: You'd be able to do network programming using almost any language you want to. If you are equally comfortable in all of the languages you've mentioned, you should determine what system libraries or APIs will you be interfacing with. For example, if you will be doing packet-level network programming on a Unix system, C would probably be your best best. If you want to integrate with Wireshark, go with C++. If you want to use an Apache Commons component, use Java. I suggest you come up with a more specific set of requirements for your actual program before trying to decide which language to use.
has comment: http://stackoverflow.com/comment/2829140
has comment: http://stackoverflow.com/comment/2787729
type: Answer
score: 3

http://stackoverflow.com/comment/2669248
type: QuestionComment
has text: You are not supposed to throw exceptions that way either, it's more like `throw new IndexOutOfBoundsException();` than throwing a class field that you have explicitly set to `null`.
score: 0
type: Comment
comment on: http://stackoverflow.com/q/2653040

http://stackoverflow.com/q/2715118
has title: How to change the size of the font of a JLabel to take the maximum size
accepted answer: http://stackoverflow.com/a/2715279
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/59928277
tagged with: fonts
tagged with: java
has comment: http://stackoverflow.com/comment/2740455
has answer: http://stackoverflow.com/a/2715279
has answer: http://stackoverflow.com/a/70724181
has comment: http://stackoverflow.com/comment/2740383
upvote count: 95
type: Question
answer count: 8
linked to: http://stackoverflow.com/q/4437806
has body: I have a JLabel in a Container. The defaut size of the font is very small. I would like that the text of the JLabel to take the maximum size. How can I do that?
tagged with: containers
has answer: http://stackoverflow.com/a/79274012
has answer: http://stackoverflow.com/a/25595298
linked to: http://stackoverflow.com/q/9814616
possible better answer: http://stackoverflow.com/a/2715127
has comment: http://stackoverflow.com/comment/11244103
has answer: http://stackoverflow.com/a/2715127
downvote count: 1
favorite count: 0
tagged with: jlabel
has comment: http://stackoverflow.com/comment/2740325
score: 94
has answer: http://stackoverflow.com/a/29148550
tagged with: size
has answer: http://stackoverflow.com/a/30724991
has comment: http://stackoverflow.com/comment/2740335

http://stackoverflow.com/comment/2710782
type: Comment
comment on: http://stackoverflow.com/a/2689852
type: AnswerComment
score: 0
has text: I know, but that would require a fit function to call `setParameters(parameters)` and `getValue(x)` everytime instead of simply `getValue(x, parameters)`. On the other hand, setParameters would be called only for a new fit and passing the parameters for every evaluation is a waste... I see. +1

http://stackoverflow.com/comment/2746798
has text: @Mohammed_Q If you want your stuff in GWT to be both visible to both the client and the server you need to put the files under the client folder
type: Comment
comment on: http://stackoverflow.com/a/2716291
score: 0
type: AnswerComment

http://stackoverflow.com/comment/31138086
type: AnswerComment
type: Comment
has text: Wouldn't this cause a performance bottleneck? I mean the performance hit could cause the GUI to seem like it's frozen. I guess I've tested this method( in other languages ) and wasn't so great. Although I'm not sure, if works, it's a pretty good solution, I'm gonna test now
comment on: http://stackoverflow.com/a/17508103
score: 0

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

http://stackoverflow.com/comment/2629543
has text: @Jules Olléon: also note the second reason why you may no want to use these L&F on OS X is that doing so would likely break the Apple guidelines (by default, without messing with anything, the Java JButton *does* look very nice on OS X).
type: Comment
comment on: http://stackoverflow.com/q/2616448
type: QuestionComment
score: 0

http://stackoverflow.com/a/2762839
upvote count: 1
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2762769
accepted answer of: http://stackoverflow.com/q/2762769
has comment: http://stackoverflow.com/comment/23110369
type: Answer
downvote count: 0
score: 1
has body: If it is self-signed you also need to add the certificate into windows certificate store. If you use a Certificate Authority such as Verisign then you will not have the problem. See here for an explanation (from Verisign) on why to sign from them.

http://stackoverflow.com/q/2673251
type: Question
has answer: http://stackoverflow.com/a/2673269
has body: I want to execute a query using hibernate where the requirment is like select * from user where regionname='' that is select all the users from user where region name is some data How to write this in hibernate The below code is giving result appropraitely Criteria crit= HibernateUtil.getSession().createCriteria(User.class); crit.add(Restrictions.eq("regionName", regionName));
tagged with: java
tagged with: hibernate
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/2673278
type: UnansweredQuestion
has title: HIbernate query

http://stackoverflow.com/a/2770624
upvote count: 2
type: Answer
answers question: http://stackoverflow.com/q/2770443
has comment: http://stackoverflow.com/comment/2812110
accepted answer of: http://stackoverflow.com/q/2770443
score: 2
type: AcceptedAnswer
downvote count: 0
has body: When you say new Sprite[10] is creates an array of ten Sprite references, which are all equal to null by default. It does not create any new Sprite objects. After this, you'll likely want to create a new Sprite object to stick in each of these ten places. For example: Sprite[] rgSprite = new Sprite[10]; for (int i = 0; i &lt; rgSprite.length; i++) { rgSprite[i] = new Sprite(mContext, R.drawable.icon); }

servlets
tags question: http://stackoverflow.com/q/2635406
tags question: http://stackoverflow.com/q/2687441
tags question: http://stackoverflow.com/q/2728877
tags question: http://stackoverflow.com/q/2770672
tags question: http://stackoverflow.com/q/2661224
tags question: http://stackoverflow.com/q/2712750
tags question: http://stackoverflow.com/q/2629910
tags question: http://stackoverflow.com/q/2678035
tags question: http://stackoverflow.com/q/2636432
tags question: http://stackoverflow.com/q/2763273
tags question: http://stackoverflow.com/q/2648984
tags question: http://stackoverflow.com/q/2694136
tags question: http://stackoverflow.com/q/2713102
tags question: http://stackoverflow.com/q/2745972
tags question: http://stackoverflow.com/q/2754230
tags question: http://stackoverflow.com/q/2609925
tags question: http://stackoverflow.com/q/2737027
tags question: http://stackoverflow.com/q/2760959
tags question: http://stackoverflow.com/q/2673371
tags question: http://stackoverflow.com/q/2739821
tags question: http://stackoverflow.com/q/2723829
tags question: http://stackoverflow.com/q/2655718
tags question: http://stackoverflow.com/q/2779984
tags question: http://stackoverflow.com/q/2751300
tags question: http://stackoverflow.com/q/2776990
tags question: http://stackoverflow.com/q/2680938
tags question: http://stackoverflow.com/q/2673487
tags question: http://stackoverflow.com/q/2658922
tags question: http://stackoverflow.com/q/2604027
tags question: http://stackoverflow.com/q/2643384
tags question: http://stackoverflow.com/q/2638389
tags question: http://stackoverflow.com/q/2657655
tags question: http://stackoverflow.com/q/2673751
tags question: http://stackoverflow.com/q/2749528
tags question: http://stackoverflow.com/q/2736466
tags question: http://stackoverflow.com/q/2782066
tags question: http://stackoverflow.com/q/2767841
tags question: http://stackoverflow.com/q/2654161
tags question: http://stackoverflow.com/q/2599284
tags question: http://stackoverflow.com/q/2758873
tags question: http://stackoverflow.com/q/2659183
tags question: http://stackoverflow.com/q/2690198
tags question: http://stackoverflow.com/q/2721304
tags question: http://stackoverflow.com/q/2725812
tags question: http://stackoverflow.com/q/2690441
tags question: http://stackoverflow.com/q/2741151
tags question: http://stackoverflow.com/q/2741366
tags question: http://stackoverflow.com/q/2760867
tags question: http://stackoverflow.com/q/2755338
tags question: http://stackoverflow.com/q/2701094
tags question: http://stackoverflow.com/q/2667861
tags question: http://stackoverflow.com/q/2602264
tags question: http://stackoverflow.com/q/2704103
tags question: http://stackoverflow.com/q/2663204
tag name: servlets
tags question: http://stackoverflow.com/q/2630466
tags question: http://stackoverflow.com/q/2755306
tags question: http://stackoverflow.com/q/2641251
type: Tag
tags question: http://stackoverflow.com/q/2597217
tags question: http://stackoverflow.com/q/2663079
tags question: http://stackoverflow.com/q/2676246
tags question: http://stackoverflow.com/q/2620799
tags question: http://stackoverflow.com/q/2666086
tags question: http://stackoverflow.com/q/2639464
tags question: http://stackoverflow.com/q/2598162
tags question: http://stackoverflow.com/q/2663096
tags question: http://stackoverflow.com/q/2707374
tags question: http://stackoverflow.com/q/2647745
tags question: http://stackoverflow.com/q/2645975

http://stackoverflow.com/comment/35523164
has text: Michael, it sure was necessary. The misleading blanket statements are really what are not necessary.
score: 2
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2618327

http://stackoverflow.com/a/40200706
upvote count: 5
score: 3
has comment: http://stackoverflow.com/comment/98570942
has body: RPC is an old protocol based on C.It can invoke a remote procedure and make it look like a local call.RPC handles the complexities of passing that remote invocation to the server and getting the result to client. Java RMI also achieves the same thing but slightly differently.It uses references to remote objects.So, what it does is that it sends a reference to the remote object alongwith the name of the method to invoke.It is better because it results in cleaner code in case of large programs and also distribution of objects over the network enables multiple clients to invoke methods in the server instead of establishing each connection individually.
downvote count: 2
type: Answer
answers question: http://stackoverflow.com/q/2728495
has comment: http://stackoverflow.com/comment/105284498

http://stackoverflow.com/a/2699370
downvote count: 0
has comment: http://stackoverflow.com/comment/2721880
answers question: http://stackoverflow.com/q/2699299
score: 4
has comment: http://stackoverflow.com/comment/2721898
has comment: http://stackoverflow.com/comment/2721921
type: Answer
has body: The used final locals (and any outer this references) are copied to synthetic fields of the inner class during construction. References and primitives are, as always, treated the same. Both are (shallow) copied. You can use javap from the JDK to see what is being generated.
has comment: http://stackoverflow.com/comment/3115316
upvote count: 4
accepted answer of: http://stackoverflow.com/q/2699299
type: AcceptedAnswer

http://stackoverflow.com/a/2673571
has body: but the 26! words is 4.03291461 × 1026 how to write the program in java You don't write that program in Java or any other language. It would be pointless because it would literally take billions of years to finish. But the number is also completely wrong for your intended result in the comments. 26! is the number of permutations, i.e. the different ways to order 26 elements without repetition. The number of words would be 26^n, where n is the length.
has comment: http://stackoverflow.com/comment/2692469
answers question: http://stackoverflow.com/q/2673494
type: Answer
score: 3
has comment: http://stackoverflow.com/comment/18382130
upvote count: 3
downvote count: 0

http://stackoverflow.com/q/2641386
tagged with: image
type: Question
answer count: 3
has answer: http://stackoverflow.com/a/2641397
has title: How to add an image dynamically at runtime in java
has answer: http://stackoverflow.com/a/2641497
tagged with: dynamic
type: UnansweredQuestion
score: 0
has answer: http://stackoverflow.com/a/2641843
linked to: http://stackoverflow.com/q/299495
tagged with: java
tagged with: jpanel
has body: I've been trying to load up an image dynamically in runtime for the longest time and have taken a look at other posts on this site and have yet to find exactly the thing that will work. I am trying to load an image while my GUI is running (making it in runtime) and have tried various things. Right now, I have found the easiest way to create an image is to use a JLabel and add an ImageIcon to it. This has worked, but when I go to load it after the GUI is running, it fails saying there is a "NullPointerException". Here is the code I have so far: p = Runtime.getRuntime().exec("python C:\\FaceVACS\\roc.py " + "C:/FaceVACS/OutputCMC_" + target + ".txt " + "C:/FaceVACS/ROC_" + target + ".png"); Icon graph = new ImageIcon("C:\\FaceVACS\\OutputCMC_" + target + ".png"); roc_image.setIcon(graph); panel.add(roc_image); panel.revalidate(); gui.frame.pack(); I tried panel.validate(), panel.revalidate(), and I've also tried gui.getRootPane(), but I can't seem to find anything that will work. Any ideas would be helpful! Thanks

http://stackoverflow.com/comment/2811427
type: Comment
has text: @chris-gr: it takes much longer and uses more memory than necessary.
comment on: http://stackoverflow.com/a/2776274
score: 0
type: AnswerComment

http://stackoverflow.com/q/2692066
has title: looking for good solution to invoke http client method in a bean (i.e. MDB, session)
has answer: http://stackoverflow.com/a/5563084
score: 0
has body: I would like to invoke http client method (HTTP PUT, GET, et al) within a bean, but I want these beans, either MDB or stateless session bean, run as quick as possible (with extreme short life time). ---[ejb request]--&gt; bean -----[http request]----&gt; host Problem is, the HTTP connection is too slow (especially when connecting to slow hosts). Take MDB for example, due to HTTP latency, the MDB run too long, and the queue is quickly stalled with continuing coming messages. (Message producer is faster than http method invocation.) How can I solve such problem? using NIO http client? would it help? open extra Threads to execute http invocation? (but running explicit thread in bean is not recommended in Java EE) some async http client? is there any such libs? don't they use Thread?
answer count: 1
tagged with: asynchronous
tagged with: javabeans
type: UnansweredQuestion
tagged with: java
tagged with: http
type: Question
tagged with: nio

http://stackoverflow.com/a/2648906
score: 41
downvote count: 0
has comment: http://stackoverflow.com/comment/28398892
has body: What joekutner said + a recent 1hr Fosdem "introduction" video. Despite the comments, it's actually really good, but what you have to have is the slides, so that you can follow through in a sane fashion. Here is a link to the Youtube-Video. It is fast, you'll have to pause, but I found that I was learning stuff at the 25 minute mark after having done a few days playing and reading drools docs. I can't emphasise how good this was helping me get the "feel" of drools, and just how to use the power.
answers question: http://stackoverflow.com/q/2606603
upvote count: 41
has comment: http://stackoverflow.com/comment/29625649
type: Answer

http://stackoverflow.com/comment/2732265
has text: @palto: if you're genuinely doing nothing with the stream then I guess it's safe... but pretty pointless. How often do you open a stream and then just close it? Personally I'd still use a finally block in that case, so that it's easier to modify the code later without introducing a bug.
comment on: http://stackoverflow.com/a/2708232
type: AnswerComment
type: Comment
score: 2

http://stackoverflow.com/comment/2769097
type: QuestionComment
has text: Make a full scale load testing part of your daily routine so you can see as early as possible if you will have problems conforming to specifications.
score: 0
comment on: http://stackoverflow.com/q/2739983
type: Comment

http://stackoverflow.com/a/2767097
type: AcceptedAnswer
downvote count: 0
type: Answer
has body: Spring supports ant-style class path resource matching. http://static.springsource.org/spring/docs/2.5.x/reference/resources.html Examples like : classpath:com/mycompany/**/applicationContext.xml, /WEB-INF/*-context.xml See if you can use spring for your project. If it is not possible then you can always pull down the source code to see what they are doing, and do that yourself :)
accepted answer of: http://stackoverflow.com/q/2766933
has comment: http://stackoverflow.com/comment/2800095
answers question: http://stackoverflow.com/q/2766933
upvote count: 7
score: 7

http://stackoverflow.com/comment/2665657
score: 0
comment on: http://stackoverflow.com/a/2649602
type: Comment
has text: Foo would be a class you create. But it could be anything for the first example (including primitive datatypes). In the second example with the ArrayList it cant be a primitive datatype.
type: AnswerComment

http://stackoverflow.com/q/2766347
score: 5
has title: Customizing error handling of JAXB unmarshall process
has answer: http://stackoverflow.com/a/2766567
upvote count: 5
tagged with: unmarshalling
answer count: 1
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/2766567
tagged with: http://stackoverflow.com/tag/xml
type: AnsweredQuestion
tagged with: java
tagged with: jaxb
has body: Assuming I have a schema that describes a root element class Root that contains a List where the Entry class has a required field name. Here is how it looks in code: @XmlRootElement class Root{ @XmlElement(name="entry") public List entries = Lists.newArrayList(); } @XmlRootElement class Entry{ @XmlElement(name="name",required=true) public String name; } If I supply the following XML for unmarshalling: ekeren I have a problem because the second entry does not contain a name. So unmarshall produces null. Is there a way to customize JAXB to unmarshall a Root object that will only contain the "good" entry?
type: Question

http://stackoverflow.com/comment/2647479
type: Comment
comment on: http://stackoverflow.com/a/2632918
type: AnswerComment
has text: @Tom I look at it and go "oh, another student who doesn't understand what is going on"... but I can see that if there is something surprising going on perhaps it would be useful. Of course I'd rather there be nothing surprising...
score: 0

http://stackoverflow.com/comment/2788333
has text: Don't copy parts of the JRE around, you'll end up with a confusing mess. I'd guess it's an environment variable issue. When you say you "run" your program what, exactly, are you doing?
type: QuestionComment
type: Comment
score: 1
comment on: http://stackoverflow.com/q/2756387

http://stackoverflow.com/a/2738293
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2738256
type: Answer
has body: After ensuring that the SOAPMonitor is actually enabled in the web.xml configuration file, I noticed that it used a port of 5001. I used 'netstat.exe' and noted that nothing was already listening on this port but... Changed it anyway to another unused port, 8081. After restarting my app server once more this seemed to work. Note that the TCPMonitor application which also comes with Axis has similar functionality and was easier to set up!
downvote count: 0
score: 1
accepted answer of: http://stackoverflow.com/q/2738256
upvote count: 1

http://stackoverflow.com/a/9646401
answers question: http://stackoverflow.com/q/2669926
score: 0
type: Answer
has body: I found an interesting project for lightweight Jetty+Guice+Jackson web services: https://github.com/talis/jersey-common/

constraints
type: Tag
tags question: http://stackoverflow.com/q/2711071
tag name: constraints

http://stackoverflow.com/comment/2741810
type: AnswerComment
score: 0
type: Comment
has text: Thanks BalusC, extremely informative. Will make the changes and give it a shot. What is interesting, is that most of the time the XML parses without a hitch. It's almost a luck of the draw to have an exception thrown...though it seems to happen frequently enough to be a problem.
comment on: http://stackoverflow.com/a/2716150

http://stackoverflow.com/comment/2806061
has text: I agree that sometimes JITed code will be better localy optimised since it knows which processor it is runnimg on. However, since it is "just in time" it will never be able to use all those non-local optimisations that take longer to execute. Also, it will never be able to match the hand crafted C code (which could also take the processor in account and partially negate the JIT advantages, either by compilng for a specific processor or by some kind of runtime check).
comment on: http://stackoverflow.com/a/2772250
type: AnswerComment
type: Comment
score: 1

http://stackoverflow.com/q/2598423
tagged with: c#
has title: An equivalent of -javaagent in C#? Or: ways to use a java framework in C#
tagged with: code-injection
answer count: 1
has answer: http://stackoverflow.com/a/11363534
favorite count: 0
tagged with: javaagents
has comment: http://stackoverflow.com/comment/139236621
upvote count: 2
type: UnansweredQuestion
score: 1
tagged with: java
tagged with: cross-platform
has body: The issue: I'm translating a system from Java to C#, and they use a java framework that I'd really like to use, since it takes care of the most complex parts of the system, which I would otherwise have to implement myself. I have the source code of this framework. So far, I've thought of using IKVM.NET to generate a .dll, but I'm not sure what to do next, because in Java, in order to run the framework with your code, you're supposed to use the option -javaagent by adding -javaagent:bin/deuceAgent.jar (where deuceAgent is the framework) to your java command line. I don't know what the equivalent in C# would be once I have my .dll, or whether there's an equivalent at all. How do I do this?
downvote count: 1
type: Question

http://stackoverflow.com/q/2656641
tagged with: adjacency-matrix
has title: Graph representation benchmarking
tagged with: graph
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2656665
tagged with: java
has body: Currently am developing a program that solves (if possible) any given labyrinth of dimensions from 3X4 to 26x30. I represent the graph using both adj matrix (sparse) and adj list. I would like to know how to output the total time taken by the DFS to find the solution using one and then the other method. Programatically, how could i produce such benchmark?
type: Question
answer count: 2
tagged with: benchmarking
tagged with: adjacency-list
upvote count: 6
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2656665
has answer: http://stackoverflow.com/a/2656667
accepted answer: http://stackoverflow.com/a/2656667
score: 6

http://stackoverflow.com/comment/2669342
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2653118
has text: @asalamon74: this is generally fine for homework assignments tho, unless of course exception handling is the focus (but it's obviously semaphores here)

http://stackoverflow.com/comment/2618987
type: QuestionComment
score: 0
has text: @Lord Torgamus: In, say, your first example, 01000, what about the 'element' '-' at "01-00", how can you decide it's part (or not) of the rhombus? If you want to solve if for an arbitrary angle then we're not talking about a discrete problem anymore and I'm afraid that *a)* I don't have my less-than-15 lines solution (see my answer) and *b)* only approximate answer exist, due to the non-discrete nature that the problem would acquire :)
type: Comment
comment on: http://stackoverflow.com/q/2607959

http://stackoverflow.com/comment/4972115
type: QuestionComment
has text: can anybody please elaborate approach to find the node which has loop. eg: In above example node 3 is required node.
comment on: http://stackoverflow.com/q/2663115
score: 0
type: Comment

http://stackoverflow.com/comment/2703786
score: 0
type: Comment
has text: i'm trying to add jQuery.fn.jgrid = $.jgrid; to the end of the $(document).ready(function() function in my velocity template but I can't seem to escape the $ sign probably. as it is the $ sign disappears even with a backslash in front of it
comment on: http://stackoverflow.com/a/2683790
type: AnswerComment

http://stackoverflow.com/comment/2738893
score: 1
type: AnswerComment
type: Comment
has text: @D'Nabre I don't think so. If they ask you to explain how are these utility methods implemented, you'd always be able to explain, but thus you are increasing the elegance of your code. What if these methdos were present in `java.util.Arrays`?
comment on: http://stackoverflow.com/a/2713676

http://stackoverflow.com/q/2617920
has title: Setting Background of a Jbutton
has answer: http://stackoverflow.com/a/12567890
type: Question
has answer: http://stackoverflow.com/a/2617991
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/2629867
favorite count: 0
has answer: http://stackoverflow.com/a/42970627
has comment: http://stackoverflow.com/comment/2637953
answer count: 4
accepted answer: http://stackoverflow.com/a/2617991
has body: I have 5 JButtons: b1, b2, b3, b4, b5. By default, their color is gray. When I click on any button, the background of that button changes to white. When I click another button, I want that previous clicked button to change its background to gray, and this newly clicked button to change its background to white. Here is the code that I wrote: int liveButton = 0; //holds the value of the button that is last clicked. //0 indicates no button clicked (in the beginning) private void ChangeInUsersList(int clickedButton) { switch(liveButton) { case 1 : b1.setBackground(Color.GRAY); break; case 2 : b2.setBackground(Color.GRAY); break; case 3 : b3.setBackground(Color.GRAY); break; case 4 : b4.setBackground(Color.GRAY); break; case 5 : b5.setBackground(Color.GRAY); break; default: System.out.println("No button to change"); } liveButton = clickedButton;// store the clicked button to change its //background later } private void b1ActionPerformed(java.awt.event.ActionEvent evt) { ChangeInUsersList(1); b1.setBackground(new java.awt.Color(255,255,255)); } private void b2ActionPerformed(java.awt.event.ActionEvent evt) { ChangeInUsersList(2); b2.setBackground(new java.awt.Color(255,255,255)); } private void b3ActionPerformed(java.awt.event.ActionEvent evt) { ChangeInUsersList(3); b3.setBackground(new java.awt.Color(255,255,255)); } private void b4ActionPerformed(java.awt.event.ActionEvent evt) { ChangeInUsersList(4); b4.setBackground(new java.awt.Color(255,255,255)); } private void b5ButtonActionPerformed(java.awt.event.ActionEvent evt) { ChangeInUsersList(5); b5.setBackground(new java.awt.Color(255,255,255)); } However, its not working as expected. When i click on a button, its background does change to white. However, if i click on some other button after that, the former button's background doesnt change to grey. I tried replacing Color.GREY with new java.awt.Color(236,233,216) - the rgb for grey but it still doesnt work.
upvote count: 1
tagged with: swing
has answer: http://stackoverflow.com/a/2618117
tagged with: jbutton
type: AnsweredQuestion
tagged with: java
possible better answer: http://stackoverflow.com/a/12567890

http://stackoverflow.com/q/2650180
tagged with: java
possible better answer: http://stackoverflow.com/a/2650221
has comment: http://stackoverflow.com/comment/2666296
has answer: http://stackoverflow.com/a/2650255
accepted answer: http://stackoverflow.com/a/2650255
tagged with: sql
upvote count: 1
has answer: http://stackoverflow.com/a/2650702
has answer: http://stackoverflow.com/a/2650986
tagged with: external
has title: Java is there any IDE/Tool that can pull SQL statements out in to a file?
favorite count: 0
has body: Hi is there any tool available in Java world that will parse/read a source file and pull SQL statements out in to a text file. This is a complex task given that you can write SQL statements in different fashion within the source (ex: using + sign or using .append()) or even conditional building of SQL.
answer count: 4
type: AnsweredQuestion
downvote count: 0
score: 1
has answer: http://stackoverflow.com/a/2650221
type: Question
has comment: http://stackoverflow.com/comment/2666277

http://stackoverflow.com/q/2603149
has answer: http://stackoverflow.com/a/2603272
has answer: http://stackoverflow.com/a/2603394
downvote count: 0
has comment: http://stackoverflow.com/comment/2612918
type: Question
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/2603411
tagged with: date
has answer: http://stackoverflow.com/a/2603275
accepted answer: http://stackoverflow.com/a/2603275
score: 4
favorite count: 0
has body: I'm using java.text.SimpleDateFormat to parse string representations of date/time values inside an XML document. I'm seeing all times that have an hour value of 12 shifted by 12 hours into the future, i. e. 20 minutes past noon gets parsed to mean 20 minutes past midnight the following day. I wrote a unit test which seems to confirm that the error is made upon parsing (I checked the return values from getTime() with the linux shell command date). Now I'm wondering: is there a bug in the parse() method? is there something wrong with the input string? am I using the wrong format string for the input? The input data is taken from Yahoo's YWeather service. Here's the test and its output: public class YWeatherReaderTest { public static final String[] rgDateSamples = { "Thu, 08 Apr 2010 12:20 PM CEST", "Thu, 08 Apr 2010 12:20 AM CEST" }; public void dateParsing() throws ParseException { DateFormat formatter = new SimpleDateFormat("EEE, dd MMM yyyy K:m a z", Locale.US); for (String dtsSrc : YWeatherReaderTest.rgDateSamples) { Date dt = formatter.parse(dtsSrc); String dtsDst = formatter.format(dt); System.out.println(dtsSrc); System.out.println(dtsDst); System.out.println(); } } } Thu, 08 Apr 2010 12:20 PM CEST Fri, 09 Apr 2010 0:20 AM CEST Thu, 08 Apr 2010 12:20 AM CEST Thu, 08 Apr 2010 0:20 PM CEST The second output line of the second iteration is slightly weird, because 00:20 isn't PM. The milliseconds value of the Date object, however, corresponds to the (wrong) time of 20 minutes past noon.
has title: Why does 12:20 PM parse to 0:20 on the next day?
upvote count: 4
possible better answer: http://stackoverflow.com/a/2603272
answer count: 4
tagged with: parsing

http://stackoverflow.com/q/2657819
tagged with: ternary-operator
has answer: http://stackoverflow.com/a/2657829
accepted answer: http://stackoverflow.com/a/2657829
favorite count: 0
tagged with: operators
tagged with: compound-assignment
tagged with: c++
has body: I have the following code and I can't understand what does it mean: var1 |= var2&gt;0 ? 1 : 2; Anyone can help me please!
has answer: http://stackoverflow.com/a/2657850
has answer: http://stackoverflow.com/a/2657920
score: 11
has answer: http://stackoverflow.com/a/2657835
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2675043
downvote count: 0
possible better answer: http://stackoverflow.com/a/2657833
tagged with: java
has comment: http://stackoverflow.com/comment/2676944
type: Question
answer count: 8
upvote count: 11
has answer: http://stackoverflow.com/a/2657828
has comment: http://stackoverflow.com/comment/3017177
has comment: http://stackoverflow.com/comment/2833708
has answer: http://stackoverflow.com/a/2657849
has answer: http://stackoverflow.com/a/2657833
has answer: http://stackoverflow.com/a/2657914
has title: What does "|=" operation mean in C++?

http://stackoverflow.com/comment/2724355
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2701194
type: Comment
has text: question is does he want to have this button be scrolled with the content or not. By his layout design, he intended whole layout to be scrolled including the button.

http://stackoverflow.com/comment/2622644
has text: This is pretty close. The domain is still off a bit; it does not make sense for a transcript to have a teacher (a teacher teaches collection of students for a given class).
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2610660
type: Comment

http://stackoverflow.com/a/18165425
downvote count: 0
score: 8
upvote count: 8
answers question: http://stackoverflow.com/q/2736389
type: Answer
has body: I am using parcelable to send data from one activity to another acivity. Here is my code that works fine in my project. public class Channel implements Serializable, Parcelable { /** */ private static final long serialVersionUID = 4861597073026532544L; private String cid; private String uniqueID; private String name; private String logo; private String thumb; /** * @return The cid */ public String getCid() { return cid; } /** * @param cid * The cid to set */ public void setCid(String cid) { this.cid = cid; } /** * @return The uniqueID */ public String getUniqueID() { return uniqueID; } /** * @param uniqueID * The uniqueID to set */ public void setUniqueID(String uniqueID) { this.uniqueID = uniqueID; } /** * @return The name */ public String getName() { return name; } /** * @param name * The name to set */ public void setName(String name) { this.name = name; } /** * @return the logo */ public String getLogo() { return logo; } /** * @param logo * The logo to set */ public void setLogo(String logo) { this.logo = logo; } /** * @return the thumb */ public String getThumb() { return thumb; } /** * @param thumb * The thumb to set */ public void setThumb(String thumb) { this.thumb = thumb; } public Channel(Parcel in) { super(); readFromParcel(in); } public static final Parcelable.Creator&lt;Channel&gt; CREATOR = new Parcelable.Creator&lt;Channel&gt;() { public Channel createFromParcel(Parcel in) { return new Channel(in); } public Channel[] newArray(int size) { return new Channel[size]; } }; public void readFromParcel(Parcel in) { String[] result = new String[5]; in.readStringArray(result); this.cid = result[0]; this.uniqueID = result[1]; this.name = result[2]; this.logo = result[3]; this.thumb = result[4]; } public int describeContents() { return 0; } public void writeToParcel(Parcel dest, int flags) { dest.writeStringArray(new String[] { this.cid, this.uniqueID, this.name, this.logo, this.thumb}); } } In activityA use it like this: Bundle bundle = new Bundle(); bundle.putP…

http://stackoverflow.com/comment/2690542
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2671777
has text: @danke then I do not understand the question

http://stackoverflow.com/q/2683914
upvote count: 150
has answer: http://stackoverflow.com/a/2687600
accepted answer: http://stackoverflow.com/a/2687600
type: Question
has answer: http://stackoverflow.com/a/2702104
has answer: http://stackoverflow.com/a/9859775
has answer: http://stackoverflow.com/a/2683932
downvote count: 0
score: 150
has title: Why would I use Scala/Lift over Java/Spring?
has answer: http://stackoverflow.com/a/13253551
has answer: http://stackoverflow.com/a/9726899
answer count: 10
has answer: http://stackoverflow.com/a/3067319
has answer: http://stackoverflow.com/a/2685962
favorite count: 0
has answer: http://stackoverflow.com/a/2702831
tagged with: scala
has answer: http://stackoverflow.com/a/2684349
tagged with: spring
has body: I know this question is a bit open but I have been looking at Scala/Lift as an alternative to Java/Spring and I wonder what are the real advantages that Scala/Lift has over it. From my perspective and experience, Java Annotations and Spring really minimizes the amount of coding that you have to do for an application. Does Scala/Lift improve upon that?
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/65671087
tagged with: java
tagged with: lift
possible better answer: http://stackoverflow.com/a/3067319

http://stackoverflow.com/q/2679918
tagged with: spring
type: AnsweredQuestion
score: 3
has answer: http://stackoverflow.com/a/2680047
tagged with: java
has comment: http://stackoverflow.com/comment/2699734
type: Question
tagged with: api
downvote count: 0
has answer: http://stackoverflow.com/a/2680720
favorite count: 0
possible better answer: http://stackoverflow.com/a/2680047
has body: I'm currently designing an API where I wish to allow configuration via a variety of methods. One method is via an XML configuration schema and another method is through an API that I wish to play nicely with Spring. My XML schema parsing code was previously hidden and therefore the only concern was for it to work but now I wish to build a public API and I'm quite concerned about best-practice. It seems that many favor javabean type PoJo's with default zero parameter constructors and then setter injection. The problem I am trying to tackle is that some setter methods implementations are dependent on other setter methods being called before them in sequence. I could write anal setters that will tolerate themselves being called in many orders but that will not solve the problem of a user forgetting to set the appropriate setter and therefore the bean being in an incomplete state. The only solution I can think of is to forget about the objects being 'beans' and enforce the required parameters via constructor injection. An example of this is in the default setting of the id of a component based on the id of the parent components. My Interface public interface IMyIdentityInterface { public String getId(); /* A null value should create a unique meaningful default */ public void setId(String id); public IMyIdentityInterface getParent(); public void setParent(IMyIdentityInterface parent); } Base Implementation of interface: public abstract class MyIdentityBaseClass implements IMyIdentityInterface { private String _id; private IMyIdentityInterface _parent; public MyIdentityBaseClass () {} @Override public String getId() { return _id; } /** * If the id is null, then use the id of the parent component * appended with a lower-cased simple name of the current impl * class along with a counter suffix to enforce uniqueness */ @Override public void setId(String id) { if (id == null) { IMyIdentityInterface parent = getParent(); if (parent == null) { // this may be the top level compo…
has title: Constructor versus setter injection
has answer: http://stackoverflow.com/a/2680097
accepted answer: http://stackoverflow.com/a/2680097
answer count: 4
has answer: http://stackoverflow.com/a/2680540
tagged with: constructor
upvote count: 3

http://stackoverflow.com/q/2644805
tagged with: richfaces
tagged with: el
accepted answer: http://stackoverflow.com/a/2644839
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/2028958
tagged with: java
has body: When I use (1) in my xhtml, I get an error as in (2). How can I access the size of an array in my bean? (1) A List of objects of a custom class type, accessed through the following h:outputText in a rich:column in a rich:subTable in a rich:dataTable: &lt;h:outputText value="Info: #{f.filemask.size()}" /&gt; (2) Caused by: com.sun.facelets.tag.TagAttributeException: /nodeConfig.xhtml @190,91 value="Info: #{f.filemask.size()" Error Parsing: Info: #{f.filemask.size()} at com.sun.facelets.tag.TagAttribute.getValueExpression(TagAttribute.java:259) ... Caused by: org.apache.el.parser.ParseException: Encountered " "(" "( "" at line 1, column 41. Was expecting one of: "}" ... "." ... "[" ... "&gt;" ... "gt" ... "&lt;" ... "lt" ... "&gt;=" ... "ge" ... "&lt;=" ... "le" ... "==" ... "eq" ... "!=" ... "ne" ... "&amp;&amp;" ... "and" ... "||" ... "or" ... "*" ... "+" ... "-" ... "/" ... "div" ... "%" ... "mod" ... Any help greatly appreciated. I cannot seem to find references to using methods like this but this reference reported it working fine
type: Question
has title: Accessing bean object methods from xhtml in RichFaces
has answer: http://stackoverflow.com/a/2644839
score: 0
answer count: 1

http://stackoverflow.com/q/2756481
type: Question
tagged with: monitoring
has title: Jsystem: Thread.sleep() in testcase pauses Monitor
score: 0
has comment: http://stackoverflow.com/comment/2787959
has body: I guess I miss some basical stuff, regadring threads. However, here my problem: I have a monitor running. On the other hand I have a test. The test does execute a sql query several times, between each execution waiting some ms with Thread.sleep(xy). for (int i = 0; (i &lt; iterationsteps); i++) { rs = myQuery.execute(); //check if rs is empty if (!rs.next()) { Thread.sleep(1000); } } Now the problem is that due to this Thread.sleep(1000) also the Monitor seems to sleep (at least it does not check). I thought a monitor is a seperate thread.
answer count: 1
has answer: http://stackoverflow.com/a/2756564
type: UnansweredQuestion
tagged with: multithreading
tagged with: java

jms
tags question: http://stackoverflow.com/q/2738406
tags question: http://stackoverflow.com/q/2686495
tags question: http://stackoverflow.com/q/2623542
tags question: http://stackoverflow.com/q/2714985
tags question: http://stackoverflow.com/q/2686474
tag name: jms
tags question: http://stackoverflow.com/q/2784703
tags question: http://stackoverflow.com/q/2778283
type: Tag
tags question: http://stackoverflow.com/q/2707516
tags question: http://stackoverflow.com/q/2596855
tags question: http://stackoverflow.com/q/2604005
tags question: http://stackoverflow.com/q/2629366
tags question: http://stackoverflow.com/q/2670133
tags question: http://stackoverflow.com/q/2673784

http://stackoverflow.com/a/2622645
has body: I don't believe there's a method you can call to find this out. However, what I've commonly seen done is to keep a boolean in the activity that tracks whether or not the service is bound. You'd set it to true in your ServiceConnection.onServiceConnected() callback and set it to false in ServiceConnection.onServiceDisconnected().
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2622599
answers question: http://stackoverflow.com/q/2622599
type: Answer
upvote count: 6
score: 6

http://stackoverflow.com/q/2710300
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/45188107
has answer: http://stackoverflow.com/a/2710320
tagged with: java
has answer: http://stackoverflow.com/a/2710323
has answer: http://stackoverflow.com/a/37692509
tagged with: switch-statement
accepted answer: http://stackoverflow.com/a/2710312
type: Question
has answer: http://stackoverflow.com/a/2710314
has answer: http://stackoverflow.com/a/2710698
has answer: http://stackoverflow.com/a/2710319
downvote count: 0
has comment: http://stackoverflow.com/comment/91425744
has answer: http://stackoverflow.com/a/52238570
score: 110
has answer: http://stackoverflow.com/a/2710359
has answer: http://stackoverflow.com/a/2710311
upvote count: 110
has comment: http://stackoverflow.com/comment/138214075
linked to: http://stackoverflow.com/q/52232681
has answer: http://stackoverflow.com/a/2710341
linked to: http://stackoverflow.com/q/338206
has body: Why doesn't the compiler automatically put break statements after each code block in the switch? Is it for historical reasons? When would you want multiple code blocks to execute?
tagged with: break
has answer: http://stackoverflow.com/a/26062480
has title: Why do we need break after case statements?
possible better answer: http://stackoverflow.com/a/2710359
answer count: 15
favorite count: 0
has answer: http://stackoverflow.com/a/2710312
has answer: http://stackoverflow.com/a/43771011
has answer: http://stackoverflow.com/a/2710336
tagged with: language-design
tagged with: case

http://stackoverflow.com/comment/2612918
type: QuestionComment
comment on: http://stackoverflow.com/q/2603149
has text: This is another nice example of "SELECT isn't broken". Even though I have never ever encountered a bug in a mature and widely used standard library, I still sometimes accuse the library if I can't find the problem. And so far, I've always been proven wrong.
score: 0
type: Comment

http://stackoverflow.com/comment/2786227
score: 1
comment on: http://stackoverflow.com/a/2755032
type: AnswerComment
has text: I can only suppose that none of you both know this solution. Anyway, let it be here just for the sake of some variety in answers.
type: Comment

http://stackoverflow.com/comment/2624458
type: QuestionComment
comment on: http://stackoverflow.com/q/2613481
has text: How is `rates` defined in your code?
score: 0
type: Comment

http://stackoverflow.com/comment/2645291
comment on: http://stackoverflow.com/a/2631497
type: Comment
score: 1
type: AnswerComment
has text: no goto, but it has got labeled blocks, so you can break and continue to those labeled blocks.

http://stackoverflow.com/comment/2692902
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/2670311
has text: It isn't possible to do this at gwt compile? We're in development of an GWT Application, and then we'll have to move it every time.

http://stackoverflow.com/q/2688304
upvote count: 2
tagged with: mocking
answer count: 3
has answer: http://stackoverflow.com/a/2688348
tagged with: junit
has title: Junit and EasyMock understanding clarifications
favorite count: 0
has answer: http://stackoverflow.com/a/2695906
score: 2
downvote count: 0
type: UnansweredQuestion
tagged with: unit-testing
has answer: http://stackoverflow.com/a/2688349
has body: Still Now I am using JUnit, I came across EasyMock, I am understanding both are for the same purpose. Is my understanding correct? What are the advantages does EasyMock has over the Junit? Which one is easier to configure? Does EasyMock has any limitations? Please help me to learn
type: Question
tagged with: java
tagged with: easymock

http://stackoverflow.com/a/2756732
downvote count: 0
has body: Bytes are added using "int" arithmetic; thus the result is an int and must be cast back from int to byte, which leads to the possibility of truncation.
type: Answer
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/2756717

http://stackoverflow.com/comment/2820795
has text: Same question, but for C++: http://stackoverflow.com/questions/713701/force-directed-layout-in-c
score: 1
comment on: http://stackoverflow.com/q/2784820
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/40322114
type: AnswerComment
type: Comment
has text: ArrayBlockingQueue will be slower than LinkedBlockingQueue as it uses single lock for put() and take() whereas LinkedBlockingQueue uses 2 locks for put() and take() and synchronizes producer and consumer only when queue is empty / full.
score: 0
comment on: http://stackoverflow.com/a/2645201

http://stackoverflow.com/q/2764289
accepted answer: http://stackoverflow.com/a/2764470
answer count: 3
tagged with: http://stackoverflow.com/tag/html
downvote count: 0
has answer: http://stackoverflow.com/a/2764517
favorite count: 0
has body: I found Facelift which can basically generate html headings as images (with "nice font") on the fly. Does something similar exist for Java (couldn't find one myself)? Cheers, stephanos
possible better answer: http://stackoverflow.com/a/2764517
upvote count: 1
has title: Generate images for html heading with Java servlet
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2764470
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/71904818
type: Question

http://stackoverflow.com/a/2687124
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2687103
type: Answer
has comment: http://stackoverflow.com/comment/2707932
has comment: http://stackoverflow.com/comment/2707764
has comment: http://stackoverflow.com/comment/2707753
has comment: http://stackoverflow.com/comment/2707735
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/2707847
has body: You might be looking for the standard input and output members of the java.lang.System class: class HelloWorld { public static void main(String... argv) { System.out.println("Hello, World!"); } } For processing input, you can use Scanner on standard input: Scanner scanner = new Scanner(System.in); If you want to get really fancy, you can print some of your output to System.err, which is a PrintStream just like System.out. From the comment, "when i compile my classes i get a jar file, which does nothing when i click on it, which i think is normal because its not gui," I think your problem is an operating system problem (Windows?), not a Java problem. Windows maps the "Open" action for JAR files to run with javaw.exe, which doesn't create a console. You'll either need to modify the default file association on each machine, or create something like a batch file that overrides this default behavior. You could write two programs: the first is your actual "console" Java application, and another is just a shell that uses Runtime.exec() to create a Windows console (cmd) and executes the first program within it. There are also opensource projects (check Sourceforge) that wrap your JAR in a Windows executable.
has comment: http://stackoverflow.com/comment/2707875
answers question: http://stackoverflow.com/q/2687103
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2707724

http://stackoverflow.com/a/2752646
type: Answer
answers question: http://stackoverflow.com/q/2752607
has body: Wow, ok. Parsing is hard -- really hard -- to do right. Rolling your own java parser is going to be incredibly difficult to do right. You'll find there are a lot of edge cases you're just not prepared for. To really do it right, and handle all the edge cases, you'll need to write a real parser. A real parser is composed of a number of things: A lexical analyzer to break the input up into logical chunks A grammar to determine how to interpret the aforementioned chunks The actual "parser" which is generated from the grammar using a tool like ANTLR A symbol table to store identifiers in An abstract syntax tree to represent the code you've parsed Once you have all that, you can have a real parser. Of course you could skip the abstract syntax tree, but you need pretty much everything else. That leaves you with writing about 1/3 of a compiler. If you truly want to complete this project yourself, you should see if you can find an example for ANTLR which contains a preexisting java grammar definition. That'll get you most of the way there, and then you'll need to use ANTLR to fill in your symbol table. Alternately, you could go with the clever solutions suggested by Little Bobby Tables (awesome name, btw Bobby).
has comment: http://stackoverflow.com/comment/2783414
has comment: http://stackoverflow.com/comment/2786034
has comment: http://stackoverflow.com/comment/2786621
has comment: http://stackoverflow.com/comment/2787321
has comment: http://stackoverflow.com/comment/2783454
has comment: http://stackoverflow.com/comment/2786048
score: 0

http://stackoverflow.com/q/2741598
score: 1
has comment: http://stackoverflow.com/comment/2770587
favorite count: 0
has comment: http://stackoverflow.com/comment/2770800
has comment: http://stackoverflow.com/comment/2770803
has comment: http://stackoverflow.com/comment/2770841
answer count: 2
tagged with: jtextpane
has body: The following class implements a chatGUI. When it runs okay the screen looks like this: Fine ChatGUI http://img21.imageshack.us/img21/7177/rightchat.jpg The problem is very often when i enter text of large length ie. 50 - 100 chars the gui goes crazy. the chat history box shrinks as shown in this image http://img99.imageshack.us/img99/6962/errorgui.jpg. Any ideas regarding what is causing this? Thank you. PS: the attached class below is complete code. you can copy it and compile on your computer to see exactly what i mean. NOTE: once the GUI goes crazy then if i hit the "Clear" button the history window clears and the GUI goes back to being correctly displayed again. package Sartre.Connect4; import javax.swing.*; import java.net.*; import java.awt.*; import java.awt.event.*; import javax.swing.text.StyledDocument; import javax.swing.text.Style; import javax.swing.text.StyleConstants; import javax.swing.text.BadLocationException; import java.io.BufferedOutputStream; import javax.swing.text.html.HTMLEditorKit; import java.io.FileOutputStream; import java.io.IOException; import java.io.FileNotFoundException; import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.JFileChooser; /** * Chat form class * @author iAmjad */ public class ChatGUI extends JDialog implements ActionListener { /** * Used to hold chat history data */ private JTextPane textPaneHistory = new JTextPane(); /** * provides scrolling to chat history pane */ private JScrollPane scrollPaneHistory = new JScrollPane(textPaneHistory); /** * used to input local message to chat history */ private JTextPane textPaneHome = new JTextPane(); /** * Provides scrolling to local chat pane */ private JScrollPane scrollPaneHomeText = new JScrollPane(textPaneHome); /** * JLabel acting as a statusbar */ private JLabel statusBar = new JLabel("Ready"); /** * Button to clear chat history pane */ private JButton JBClear = new JButton("Clear"); /** * Button to save chat history pane */ private JButton JBSave =…
upvote count: 1
has comment: http://stackoverflow.com/comment/2771111
has comment: http://stackoverflow.com/comment/2770876
has comment: http://stackoverflow.com/comment/2770576
has comment: http://stackoverflow.com/comment/2770573
has comment: http://stackoverflow.com/comment/2770830
has comment: http://stackoverflow.com/comment/2770644
has comment: http://stackoverflow.com/comment/2770638
has comment: http://stackoverflow.com/comment/2770811
has comment: http://stackoverflow.com/comment/2770821
tagged with: java
has comment: http://stackoverflow.com/comment/2770561
has answer: http://stackoverflow.com/a/2742018
has comment: http://stackoverflow.com/comment/2770831
tagged with: jscrollpane
has title: Java JTextPane JScrollPane Display Issue
has answer: http://stackoverflow.com/a/2741668
has comment: http://stackoverflow.com/comment/2770889
downvote count: 0
has comment: http://stackoverflow.com/comment/2770751
has comment: http://stackoverflow.com/comment/2770786
possible better answer: http://stackoverflow.com/a/2741668
type: Question
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2770757
accepted answer: http://stackoverflow.com/a/2742018

http://stackoverflow.com/q/2701272
tagged with: connection
downvote count: 0
type: UnansweredQuestion
has title: Java multiple connections downloading file
has answer: http://stackoverflow.com/a/2701343
tagged with: file
has comment: http://stackoverflow.com/comment/2724205
score: 1
tagged with: java
type: Question
answer count: 2
upvote count: 1
has answer: http://stackoverflow.com/a/2701744
favorite count: 0
has comment: http://stackoverflow.com/comment/7480054
tagged with: download
has comment: http://stackoverflow.com/comment/2724213
has body: I was wanting to add multiple connections in the code below to be able to download files faster. Could someone help me? Thanks in advance. public void run() { RandomAccessFile file = null; InputStream stream = null; try { // Open connection to URL. HttpURLConnection connection = (HttpURLConnection) url.openConnection(); // Specify what portion of file to download. connection.setRequestProperty("Range", "bytes=" + downloaded + "-"); // Connect to server. connection.connect(); // Make sure response code is in the 200 range. if (connection.getResponseCode() / 100 != 2) { error(); } // Check for valid content length. int contentLength = connection.getContentLength(); if (contentLength &lt; 1) { error(); } /* Set the size for this download if it hasn't been already set. */ if (size == -1) { size = contentLength; stateChanged(); } // Open file and seek to the end of it. file = new RandomAccessFile("C:\\"+getFileName(url), "rw"); file.seek(downloaded); stream = connection.getInputStream(); while (status == DOWNLOADING) { /* Size buffer according to how much of the file is left to download. */ byte buffer[]; if (size - downloaded &gt; MAX_BUFFER_SIZE) { buffer = new byte[MAX_BUFFER_SIZE]; } else { buffer = new byte[size - downloaded]; } // Read from server into buffer. int read = stream.read(buffer); if (read == -1) { break; } // Write buffer to file. file.write(buffer, 0, read); downloaded += read; stateChanged(); } /* Change status to complete if this point was reached because downloading has finished. */ if (status == DOWNLOADING) { status = COMPLETE; stateChanged(); } } catch (Exception e) { error(); } finally { // Close file. if (file != null) { try { file.close(); } catch (Exception e) { } } // Close connection to server. if (stream != null) { try { stream.close(); } catch (Exception e) { } } } }

http://stackoverflow.com/a/13244586
score: 13
upvote count: 13
has body: getServletContext().getRealPath("") - This way will not work if content is being made available from a .war archive. getServletContext() will be null. In this case we can use another way to get real path. This is example of getting a path to a properties file C:/Program Files/Tomcat 6/webapps/myapp/WEB-INF/classes/somefile.properties: // URL returned "/C:/Program%20Files/Tomcat%206.0/webapps/myapp/WEB-INF/classes/" URL r = this.getClass().getResource("/"); // path decoded "/C:/Program Files/Tomcat 6.0/webapps/myapp/WEB-INF/classes/" String decoded = URLDecoder.decode(r.getFile(), "UTF-8"); if (decoded.startsWith("/")) { // path "C:/Program Files/Tomcat 6.0/webapps/myapp/WEB-INF/classes/" decoded = decoded.replaceFirst("/", ""); } File f = new File(decoded, "somefile.properties");
downvote count: 0
answers question: http://stackoverflow.com/q/2786426
type: Answer

http://stackoverflow.com/comment/2631437
score: 0
type: Comment
type: QuestionComment
has text: @Juliano I'd not heard of SCTP before. It sounds really cool! Looks like it's not natively supported in Java but planned for version 7. For learning purposes I think I'll continue with my TCP packetization, but perhaps in Java 7 I'll look into replacing my network system with SCTP.
comment on: http://stackoverflow.com/q/2619082

http://stackoverflow.com/a/2632918
has comment: http://stackoverflow.com/comment/2647003
has comment: http://stackoverflow.com/comment/2646479
answers question: http://stackoverflow.com/q/2632882
has comment: http://stackoverflow.com/comment/2646459
accepted answer of: http://stackoverflow.com/q/2632882
has comment: http://stackoverflow.com/comment/2647030
score: 50
has comment: http://stackoverflow.com/comment/2646558
has comment: http://stackoverflow.com/comment/2646477
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2647479
has comment: http://stackoverflow.com/comment/2646527
has comment: http://stackoverflow.com/comment/2646523
has body: If you provide a class like this: public class Foo { } or this: public class Foo() { public Foo() { } } the compiler will generate code for this: public class Foo() { public Foo() { super(); } } So, strictly speaking, the call to "super()" is always there. In practice you should only call "super(...)" where there are parameters you want to pass to the parent constructor. It isn't wrong to call "super()" (with no parameters) but people will laugh at you :-)
type: Answer
upvote count: 50
downvote count: 0

http://stackoverflow.com/a/2776598
upvote count: 14
answers question: http://stackoverflow.com/q/2772828
has comment: http://stackoverflow.com/comment/8066006
downvote count: 0
type: Answer
has body: The first link you posted is the right place to learn about the various possibilities and to start with. But for examples, the best thing to do would be to look at the sources of existing plugins. Having that said: For unit testing, my preference goes to the maven-plugin-testing-harness. You can learn (a bit) more about it in the Maven Plugin Harness Wiki but, as I said, especially in plugins using it, for example the maven-compiler-plugin. Check the CompilerMojoTestCase. For integration testing (it's IMO very important for plugins to do integration testing), I'd recommend the shitty-maven-plugin (Super Helpful Integration Testing ThingY), especially if you are interested by writing tests in Groovy, or the maven-invoker-plugin. They are similar but have both features that the other doesn't. The website of the SHITTY plugin mentions several plugins using it. Check it out.
score: 14

http://stackoverflow.com/comment/2762507
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2712581
has text: Regarding your shameless plug, where might I find some documentation/information/etc. on it that I might be able to give it a whirl?
type: AnswerComment

http://stackoverflow.com/a/45133302
upvote count: 1
has body: Using John W answer I created an implementation that correctly begin the timeout when the task starts its execution. I even write a unit test for it :) However, it does not suit my needs since some IO operations do not interrupt when Future.cancel() is called (ie when Thread.interrupt() is called). Some examples of IO operation that may not be interrupted when Thread.interrupt() is called are Socket.connect and Socket.read (and I suspect most of IO operation implemented in java.io). All IO operations in java.nio should be interruptible when Thread.interrupt() is called. For example, that is the case for SocketChannel.open and SocketChannel.read. Anyway if anyone is interested, I created a gist for a thread pool executor that allows tasks to timeout (if they are using interruptible operations...): https://gist.github.com/amanteaux/64c54a913c1ae34ad7b86db109cbc0bf
answers question: http://stackoverflow.com/q/2758612
score: 1
has comment: http://stackoverflow.com/comment/108657404
has comment: http://stackoverflow.com/comment/108611819
downvote count: 0
has comment: http://stackoverflow.com/comment/98821674
has comment: http://stackoverflow.com/comment/98786051
type: Answer
has comment: http://stackoverflow.com/comment/108561901
has comment: http://stackoverflow.com/comment/108611069

http://stackoverflow.com/a/2674675
has comment: http://stackoverflow.com/comment/2693400
type: Answer
answers question: http://stackoverflow.com/q/2674621
has comment: http://stackoverflow.com/comment/2693605
downvote count: 0
score: 1
has body: I would suggest introducing a class for the concept of the parts of Class1 that you want to consider significant in this context. Then use a HashSet or HashMap.
upvote count: 1

http://stackoverflow.com/a/2654107
has comment: http://stackoverflow.com/comment/15168410
downvote count: 0
has comment: http://stackoverflow.com/comment/6819488
has comment: http://stackoverflow.com/comment/6820851
answers question: http://stackoverflow.com/q/2653567
score: 94
has comment: http://stackoverflow.com/comment/15177547
has comment: http://stackoverflow.com/comment/6819601
upvote count: 94
has body: To add to mikej's answer: A Joda-Time duration is a "physical" time interval; eg: 12000 milliseconds &lt;-- this is a duration A Joda-Time interval is actually a pair of instants (start instant - end instant). An instant is, again, a "physical" concept, a point in the timeline. Eg (just a possible notation): (2010/3/3 19:00:00.000 UTC ; 2010/3/3 20:00:00.000 UTC) &lt;-- this is an interval An interval, then, can be converted to a duration, but not the reverse. Consider these two intervals: I1=(2010/3/3 19:00:00.000 UTC ; 2010/3/3 20:00:00.000 UTC) I2=(2010/3/3 21:00:00.000 UTC ; 2010/3/3 22:00:00.000 UTC) As intervals, I1 and I2 are different, because the end-points are different; but if I convert them to durations, I get the same thing: 3600000 milliseconds. (Math analogy: the intervals [10,12] and [95,97] are different intervals, but they have the same length: "interval length" maps to duration). Finally, a period is a lapse of "civil time", expressed as a number of months, days, hours, etc. It does not -by itself- represent a "physical" interval, hence it can't be directly converted to a duration (months have variable lengths...). This answers question 3: you can only divide by two a physical time (a duration).
type: Answer
has comment: http://stackoverflow.com/comment/13134906
has comment: http://stackoverflow.com/comment/15173249

http://stackoverflow.com/comment/2799120
type: AnswerComment
type: Comment
has text: When using an `InputStream`, you're *reading*, not *writing*, so running out of disk space due to a zip file being written couldn't be the cause of an `IOException` under the circumstances of this discussion.
comment on: http://stackoverflow.com/a/2766558
score: 0

http://stackoverflow.com/a/2778273
downvote count: 0
has comment: http://stackoverflow.com/comment/2813419
has body: You might must pull getInputStream() out of the inner loop, instead of invoking it repeatedly for each block.
has comment: http://stackoverflow.com/comment/2817395
type: Answer
accepted answer of: http://stackoverflow.com/q/2778176
answers question: http://stackoverflow.com/q/2778176
has comment: http://stackoverflow.com/comment/2813417
score: 4
upvote count: 4
type: AcceptedAnswer

http://stackoverflow.com/comment/2627906
type: Comment
comment on: http://stackoverflow.com/a/2613920
score: 0
type: AnswerComment
has text: 1. Obviously, it requires a refresh of the client. The reload time itself depend on the size of the update - From a single servlet to a whole application. 2. We are talking about servlets - The client does not observe classes, fields, methods, etc. Any Java class can be replaced. 3,4 - That depends on Tomcat, I'm not sure.

http://stackoverflow.com/comment/25418543
has text: @Anatoliy Took a while to get back to you - I like your comment. I modified the addAll method to use super.addAll like you suggested. I added an if statement for being able to choose which ever method is faster - addAll or multiple add calls. The value 4 is just a guess, though - no tests performed.
comment on: http://stackoverflow.com/a/12638571
type: Comment
score: 1
type: AnswerComment

http://stackoverflow.com/a/2660116
has body: It's a while loop that gets executed at least once. Edit: The while and do-while Statements
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/2660110
downvote count: 0

http://stackoverflow.com/comment/2728088
has text: No. If you specify Cipher.getInstance("RSA") you get "RSA/ECB/PKCS1Padding".
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2699032

http://stackoverflow.com/q/2611837
has body: I have a console application which screen scrapes some data, and now I need to do image comparisons. If the images are different, I want to show the images to the user. What's the best way to display two images during the execution of a console application? I'm assuming I would use some sort of inter-process communication to send information back and forth, but I'm not sure how exactly I would go about doing that in a good fashion. Also, I'd rather NOT store the images to files if possible. There's no reason to persist the data, and if the console application terminates unexpectedly, it's better if I don't have any dirt left on the file system. Does anyone have any thoughts on how best to accomplish this?
favorite count: 0
has answer: http://stackoverflow.com/a/2611956
possible better answer: http://stackoverflow.com/a/2611956
type: AnsweredQuestion
score: 2
downvote count: 0
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/2622563
tagged with: console-application
has answer: http://stackoverflow.com/a/2611870
accepted answer: http://stackoverflow.com/a/2611870
has title: Displaying images in a console application?
upvote count: 2
answer count: 2

http://stackoverflow.com/comment/2646370
score: 1
has text: Which would probably be `null`. Also class loaders often load classes and resources from multiple locations.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2632395

http://stackoverflow.com/q/2681883
has comment: http://stackoverflow.com/comment/2701604
score: 22
favorite count: 0
has answer: http://stackoverflow.com/a/2681928
answer count: 10
accepted answer: http://stackoverflow.com/a/2681993
has answer: http://stackoverflow.com/a/2681927
has answer: http://stackoverflow.com/a/2682114
has comment: http://stackoverflow.com/comment/2701545
linked to: http://stackoverflow.com/q/36707
possible better answer: http://stackoverflow.com/a/2681927
has answer: http://stackoverflow.com/a/3534260
tagged with: coding-style
type: AnsweredQuestion
has title: Unnecessary 'else' statement
has answer: http://stackoverflow.com/a/2682035
duplicate of: http://stackoverflow.com/q/36707
tagged with: java
has answer: http://stackoverflow.com/a/2681908
has body: As you know, in Eclipse you can turn on "Unnecessary 'else' statement" check that will trigger on if-then-else with premature return. And, from my experience, there are two most possible situations when use such statement: 1) Pre-check: if (!validate(arg1)) { return false; } doLotOfStuff(); 2) Post-check: doLotOfStuff(); if (condition) { return foo; } else { return bar; } In the second case, if the trigger is on, Eclipse will suggest you to change the code to: doLotOfStuff(); if (condition) { return foo; } return bar; However, I think that the return with else statement is more readable as it is like direct mapping of business logic. So I am curios if this "Unnecessary 'else' statement" code convention is widespread or code with else statement is more preferable?
tagged with: eclipse
has answer: http://stackoverflow.com/a/2682179
type: Question
upvote count: 22
has answer: http://stackoverflow.com/a/2681993
downvote count: 0
has answer: http://stackoverflow.com/a/2681973
has answer: http://stackoverflow.com/a/2681905

http://stackoverflow.com/comment/2822166
type: Comment
comment on: http://stackoverflow.com/a/2786276
type: AnswerComment
has text: @Afro: If there's concurrent access to the `Vector`, then yeah you may want to keep it a `Vector` then. Synchronization can be costly, and it's not always needed, which is why I suggested `ArrayList`. It's like `StringBuilder` vs `StringBuffer` issue.
score: 0

http://stackoverflow.com/comment/2623650
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2612744
has text: Are you sure the tree was properly constructed?

http://stackoverflow.com/q/2626482
upvote count: 1
type: Question
tagged with: inheritance
has title: Java inheritance question
has answer: http://stackoverflow.com/a/2626519
tagged with: abstract-class
has answer: http://stackoverflow.com/a/2626500
answer count: 3
has answer: http://stackoverflow.com/a/2626498
has comment: http://stackoverflow.com/comment/2639507
downvote count: 0
favorite count: 0
possible better answer: http://stackoverflow.com/a/2626500
has comment: http://stackoverflow.com/comment/2639518
tagged with: interface
has body: I have an abstract class Airplane, and two classes PassengerAirplane and CargoAirplane, which extend class Airplane. I also have an interface Measurable, and two classes that implement it - People and Containers. So, Airplane can do many things on its own, and there is a method which allows measurable things to be added to the airplane (called addAMeasurableThing). The only difference between PassengerAirplane/CargoAirplane and just an Airplane is that addAMeasurableThing should only accept People / Containers, and not any kind Measurable things. How do I implement this? I tried doing: Airplane class: public abstract Airplane addAMeasurableThing (Measurable m, int position); PassengerAirplane class: public Airplane addAMeasurableThing (Measurable m, int position) { if (m instanceof People)... CargoAirplane class: public Airplane addAMeasurableThing (Measurable m, int position) { if (m instanceof Containers)... But when I was debugging it, I've noticed that addAMeasurableThing in the CargoAirplane class never gets called, because both methods have the same signature. So how can the appropriate PassengerAirplane/CargoAirplane's addAMeasurableThing be called, depending on the type of Measurable thing that is being passed on? Thanks!
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2626498
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/2639526

http://stackoverflow.com/q/2691003
type: UnansweredQuestion
has body: @Named @ConversationScoped @Interceptors(MyInterceptor.class) public class BeanWeb implements Serializable { public String methodThrowException throws Exception() { throws new Exception(); } } public class MyInterceptor { @AroundInvoke public Object intercept(InvocationContext ic) throws Exception { try { return ic.proceed(); } catch (Exception e) { return null; } } } For @Stateless beans interceptor works, but for the BeanWeb interceptor does not work. And we have never entered into "intercept" method. Why is this happening? How could intercept method calls in BeanWeb? P.S.: All this spin under Glassfish 3.x.
tagged with: jsf
tagged with: java
has answer: http://stackoverflow.com/a/2691198
type: Question
tagged with: jakarta-ee
score: 0
answer count: 1
has title: @Intertceptors does not work for web bean for JSF page

http://stackoverflow.com/comment/2661694
has text: How do you compare H2 database with HSQLDB or JavaDB. I am more interested in concurrency since I don't want the database to be locked for UPDATEs when I am doing INSERTs. I believe SQLite locks the database when you perform any write to the database.
comment on: http://stackoverflow.com/a/2625598
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/87905379
type: AnswerComment
score: 1
comment on: http://stackoverflow.com/a/19739576
type: Comment
has text: Can someone explain the use/application of <? super MyClass>. Because you can put MyClass and its subclass objects into it, but if you want to take out stuff from that collection. They can be taken out only as Objects.

http://stackoverflow.com/a/2691081
has body: I've never heard of anyone using WSDL for generating REST clients. WADL yes, but not WSDL. Anyway, generating clients for REST services does not make sense. If you think you want to do that then you are missing the benefits of REST and trying to follow the REST constraints is going to make you do extra work for nothing.
has comment: http://stackoverflow.com/comment/8972033
has comment: http://stackoverflow.com/comment/53329476
has comment: http://stackoverflow.com/comment/8969340
has comment: http://stackoverflow.com/comment/8961006
answers question: http://stackoverflow.com/q/2689122
downvote count: 3
has comment: http://stackoverflow.com/comment/2720234
has comment: http://stackoverflow.com/comment/11192897
upvote count: 5
has comment: http://stackoverflow.com/comment/2713063
has comment: http://stackoverflow.com/comment/2712851
type: Answer
has comment: http://stackoverflow.com/comment/8963472
score: 2
has comment: http://stackoverflow.com/comment/53329294

http://stackoverflow.com/a/27165123
score: 0
type: Answer
has body: {App1(Java code)------>App1byteCode}........{(JVM+MacOS) help work with App1,App2,App3} {App2(Java Code)----->App2byteCode}........{(JVM+LinuxOS) help work with App1,App2,App3} {App3(Java Code)----->App3byteCode}........{(JVM+WindowsOS) help work with App1,App2,App3} How this is happening ? Ans: JVM have capability to read ByteCode and Response In Accordance with the underlying OS As the JVM is in Sync with OS. So we find, we need JVM with Sync with Platform. But the main thing is that the programmer dont have to know specific knowledge of the Platform and program his application keeping one specific platform in mind. This Flexibility of write Program in Java --- compile to ByteCode and run on any Machine (Yes need to have Platform DEPENDENT JVM to execute it) makes Java Platform Independent.
answers question: http://stackoverflow.com/q/2748910

http://stackoverflow.com/a/2768759
has body: I would suggest using C#, since there is a very strong library called Pcap.Net that wraps WinPcap with .NET code. This should make it easy for you to receive, send and interpret packets different packets of different protocols.
answers question: http://stackoverflow.com/q/2756243
score: 0
type: Answer

http://stackoverflow.com/q/2766190
answer count: 5
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2766219
tagged with: spring
has answer: http://stackoverflow.com/a/2766271
score: 2
upvote count: 3
tagged with: java
has answer: http://stackoverflow.com/a/2768063
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/2768015
has answer: http://stackoverflow.com/a/5968234
has body: Could anyone point me towards some good, detailed, sample Spring applications? Ideally those with good test coverage!
has title: Spring Sample Application
favorite count: 0

gnu-screen
tags question: http://stackoverflow.com/q/2676450
type: Tag
tag name: gnu-screen

http://stackoverflow.com/q/2657394
answer count: 6
score: 2
has title: Google app engine: Poor Performance with JDO + Datastore
has answer: http://stackoverflow.com/a/2662691
favorite count: 0
upvote count: 2
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2657470
has answer: http://stackoverflow.com/a/2809727
has answer: http://stackoverflow.com/a/2659491
tagged with: performance
tagged with: java
tagged with: jdo
has answer: http://stackoverflow.com/a/3786416
has answer: http://stackoverflow.com/a/2934649
has body: I have a simple data model that includes USERS: store basic information (key, name, phone # etc) RELATIONS: describe, e.g. a friendship between two users (supplying a relationship_type + two user keys) COMMENTS: posted by users (key, comment text, user_id) I'm getting very poor performance, for instance, if I try to print the first names of all of a user's friends. Say the user has 500 friends: I can fetch the list of friend user_ids very easily in a single query. But then, to pull out first names, I have to do 500 back-and-forth trips to the Datastore, each of which seems to take on the order of 30 ms. If this were SQL, I'd just do a JOIN and get the answer out fast. I understand there are rudimentary facilities for performing two-way joins across un-owned relations in a relaxed implementation of JDO (as described at http://gae-java-persistence.blogspot.com) but they sound experimental and non-standard (e.g. my code won't work in any other JDO implementation). Worse yet, what if I want to pull out all the comments posted by a user's friends. Then I need to get from User --> Relation --> Comments, i.e. a three-way join, which isn't even supported experimentally. The overhead of 500 back-and-forths to get a friend list + another 500 trips to see if there are any comments from a user's friends is already enough to push runtime >30 seconds. How do people deal with these problems in real-world datastore-backed JDO applications? (Or do they?) Has anyone managed to extract satisfactory performance from JDO/Datastore in this kind of (very common) situation? -Bosh
type: Question
tagged with: google-cloud-datastore
downvote count: 0

http://stackoverflow.com/a/2688662
downvote count: 0
has comment: http://stackoverflow.com/comment/2709712
type: Answer
has comment: http://stackoverflow.com/comment/2710427
upvote count: 7
accepted answer of: http://stackoverflow.com/q/2688493
has body: Usually barcode scanners can be configured to send some characters before and after the string. So if you append eg "F12" before the barcode string, you can capture that and move the focus to the right field. Check the barcode scanner manual how to do that.
answers question: http://stackoverflow.com/q/2688493
score: 7
type: AcceptedAnswer

http://stackoverflow.com/a/24270713
has comment: http://stackoverflow.com/comment/74014087
has comment: http://stackoverflow.com/comment/37613278
answers question: http://stackoverflow.com/q/2781086
score: 8
has comment: http://stackoverflow.com/comment/136885084
type: Answer
has body: Your intuition is correct, you MAY loose precision when converting int to float. However it not as simple as presented in most other answers. In Java a FLOAT uses a 23 bit mantissa, so integers greater than 2^23 will have their least significant bits truncated. (from a post on this page) Not true. Example: here is an integer that is greater than 2^23 that converts to a float with no loss: int i = 33_554_430 * 64; // is greater than 2^23 (and also greater than 2^24); i = 2_147_483_520 float f = i; System.out.println("result: " + (i - (int) f)); // Prints: result: 0 System.out.println("with i:" + i + ", f:" + f);//Prints: with i:2_147_483_520, f:2.14748352E9 Therefore, it is not true that integers greater than 2^23 will have their least significant bits truncated. The best explanation I found is here: A float in Java is 32-bit and is represented by: sign * mantissa * 2^exponent sign * (0 to 33_554_431) * 2^(-125 to +127) Source: http://www.ibm.com/developerworks/java/library/j-math2/index.html Why is this an issue? It leaves the impression that you can determine whether there is a loss of precision from int to float just by looking at how large the int is. I have especially seen Java exam questions where one is asked whether a large int would convert to a float with no loss. Also, sometimes people tend to think that there will be loss of precision from int to float: when an int is larger than: 1_234_567_890 not true (see counter-example above) when an int is larger than: 2 exponent 23 (equals: 8_388_608) not true when an int is larger than: 2 exponent 24 (equals: 16_777_216) not true Conclusion Conversions from sufficiently large ints to floats MAY lose precision. It is not possible to determine whether there will be loss just by looking at how large the int is (i.e. without trying to go deeper into the actual float representation).
downvote count: 1
upvote count: 9

http://stackoverflow.com/a/2653225
type: Answer
answers question: http://stackoverflow.com/q/2653118
downvote count: 1
upvote count: 0
score: -1
has body: How many threads are you creating? Just 1 server instance in 1 thread? Or is 1 instance used in 2 threads? 1 instance/1 thread - your loop is processing serially, processing accepting 1 thread at a time. This isn't because of the semaphore, but rather because its just one thread. The other connections are being queued waiting for acceptance. 1 instance/2 threads - your code (the semaphore) is limiting your server up to processing accepting 2 connections simultaneously, but TCP/IP allows for connections to be queued to be accepted (I think the general default queue length is 5). The 3rd simultaneous request (a request that comes in before either of the 2 previous requests finish processing) would wait for a certain amount of time ( I don't recall how long clients wait by default). So would the 4th, 5th, etc. Either way: So your code would have unlimited connections, because the code is just limiting how many are accepted simultaneously. Once accepted, the connections remain until the server or the client closes the connection. Updated - in response to OP comments giving more information. process maintains a persistent connection with an infinite loop – Robert 12 mins ago

http://stackoverflow.com/a/2621028
has body: You may consider wrapping your server entry point as a servlet and doing a POST from a client.
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2620687
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/49120627

http://stackoverflow.com/a/2642293
has comment: http://stackoverflow.com/comment/19995206
has comment: http://stackoverflow.com/comment/19995218
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2642281
type: Answer
has comment: http://stackoverflow.com/comment/2657950
accepted answer of: http://stackoverflow.com/q/2642281
score: 41
upvote count: 41
has body: No it's not possible. The best you can do is make two enums implement and interface and then use that interface instead of the enum. So: interface Digit { int getValue(); } enum Decimal implements Digit { ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE; private final int value; Decimal() { value = ordinal(); } @Override public int getValue() { return value; } } enum Hex implements Digit { A, B, C, D, E, F; private final int value; Hex() { value = 10 + ordinal(); } @Override public int getValue() { return value; } }

http://stackoverflow.com/a/21664676
score: 1
upvote count: 1
has body: import java.util.StringTokenizer; public class Occourence { public static void main(String[] args) { String key=null,str ="my name noorus my name noorus"; int i=0,tot=0; StringTokenizer st=new StringTokenizer(str," "); while(st.hasMoreTokens()) { tot=tot+1; key = st.nextToken(); while((i=(str.indexOf(key,i)+1))&gt;0) { System.out.println("position of "+key+" "+"is "+(i-1)); } } System.out.println("total words present in string "+tot); } }
downvote count: 0
answers question: http://stackoverflow.com/q/2615749
has comment: http://stackoverflow.com/comment/40443975
has comment: http://stackoverflow.com/comment/32747018
type: Answer

http://stackoverflow.com/a/2722762
type: Answer
has comment: http://stackoverflow.com/comment/2749248
answers question: http://stackoverflow.com/q/2722742
score: 0
has body: You'd take each integer, divide by 10 and separate the fraction from the remainder. multiply the fraction by 10 to make it an integer again and put it into your new array. Repeat until you run out of digits. Repeate until you run out of integers in your input array.

http://stackoverflow.com/q/2767075
tagged with: maven-2
score: 2
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2767931
tagged with: java
tagged with: hibernate
type: Question
upvote count: 2
has title: Wicket, Spring and Hibernate - Testing with Unitils - Error: Table not found in statement [select relname from pg_class]
has answer: http://stackoverflow.com/a/2767931
answer count: 1
downvote count: 0
has body: I've been following a tutorial and a sample application, namely 5 Days of Wicket - Writing the tests: http://www.mysticcoders.com/blog/2009/03/10/5-days-of-wicket-writing-the-tests/ I've set up my own little project with a simple shoutbox that saves messages to a database. I then wanted to set up a couple of tests that would make sure that if a message is stored in the database, the retrieved object would contain the exact same data. Upon running mvn test all my tests fail. The exception has been pasted in the first code box underneath. I've noticed that even though my unitils.properties says to use the 'hdqldb'-dialect, this message is still output in the console window when starting the tests: INFO - Dialect - Using dialect: org.hibernate.dialect.PostgreSQLDialect. I've added the entire dump from the console as well at the bottom of this post (which goes on for miles and miles :-)). Upon running mvn test all my tests fail, and the exception is: Caused by: java.sql.SQLException: Table not found in statement [select relname from pg_class] at org.hsqldb.jdbc.Util.sqlException(Unknown Source) at org.hsqldb.jdbc.jdbcStatement.fetchResult(Unknown Source) at org.hsqldb.jdbc.jdbcStatement.executeQuery(Unknown Source) at org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:188) at org.hibernate.tool.hbm2ddl.DatabaseMetadata.initSequences(DatabaseMetadata.java:151) at org.hibernate.tool.hbm2ddl.DatabaseMetadata.(DatabaseMetadata.java:69) at org.hibernate.tool.hbm2ddl.DatabaseMetadata.(DatabaseMetadata.java:62) at org.springframework.orm.hibernate3.LocalSessionFactoryBean$3.doInHibernate(LocalSessionFactoryBean.java:958) at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419) ... 49 more I've set up my unitils.properties file like so: database.driverClassName=org.hsqldb.jdbcDriver database.url=jdbc:hsqldb:mem:PUBLIC database.userName=sa database.password= database.dialect=hsqldb database.schemaNames=PUBLIC My…
favorite count: 0
tagged with: wicket
tagged with: junit

http://stackoverflow.com/a/24186488
upvote count: 3
has comment: http://stackoverflow.com/comment/91466863
has comment: http://stackoverflow.com/comment/41225722
has body: Verifying ele is visible. public static boolean isElementVisible(final By by) throws InterruptedException { boolean value = false; if (driver.findElements(by).size() &gt; 0) { value = true; } return value; }
downvote count: 2
type: Answer
answers question: http://stackoverflow.com/q/2646195
score: 1

http://stackoverflow.com/comment/72032534
score: 0
type: AnswerComment
type: Comment
has text: I have maven build with eclipse. How do you do hot code with that environment. Looking for a solution. Thanks Dhiren
comment on: http://stackoverflow.com/a/4224288

http://stackoverflow.com/comment/10373920
score: 0
type: AnswerComment
type: Comment
has text: If you need more than 3 parameters, you can use the query.executeWithMap API and pass a hash map of key/values for your parameters. For example map.put("param_name_1", param_1_value);
comment on: http://stackoverflow.com/a/2744615

http://stackoverflow.com/comment/2725922
comment on: http://stackoverflow.com/a/2702670
has text: @Chris: Yeap, clone could be used also, when you don't know anything about the object until runtime ( which is rate in Java, there you know at least it's some type of Fooable ) but when you have: `Object o = ???; Object copy = o.clone()` could be useful.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/2952881
score: 0
type: Answer
has body: Thanks for your all nice suggestion. But this below code is really very useful as we dont have any search method with List that can give number of occurance. void insert(Item newEl) { if (counters.contains(newEl)) counters.put(newEl, counters.get(newEl)+1); else counters.put(newEl, 1); items.add(newEl); } Thanks to Jack. Good posting. Thanks, Binod Suman http://binodsuman.blogspot.com
answers question: http://stackoverflow.com/q/2647232

http://stackoverflow.com/q/2672272
tagged with: algorithm
upvote count: 6
possible better answer: http://stackoverflow.com/a/2672304
has body: This is an interview question, and should concern about efficiency. How to calculate occurrences of specified word in a large text file? I can only think of indexOf() method in most programming languages, but I don't think that the correct answer.
has answer: http://stackoverflow.com/a/2672304
has title: Calculate occurrences of specified word in a large text file
favorite count: 0
has answer: http://stackoverflow.com/a/2672307
has answer: http://stackoverflow.com/a/2672644
answer count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2672842
accepted answer: http://stackoverflow.com/a/2672842
downvote count: 0
tagged with: java
score: 6
type: Question

http://stackoverflow.com/q/2696812
tagged with: compound-assignment
type: Question
tagged with: implicit-conversion
tagged with: java
answer count: 1
has comment: http://stackoverflow.com/comment/89315684
has answer: http://stackoverflow.com/a/2696819
has title: Varying behavior for possible loss of precision
score: 32
type: AnsweredQuestion
downvote count: 0
upvote count: 32
has body: In Java, when you do int b = 0; b = b + 1.0; You get a possible loss of precision error. But why is it that if you do int b = 0; b += 1.0; There isn't any error?
accepted answer: http://stackoverflow.com/a/2696819
favorite count: 0

http://stackoverflow.com/comment/2650089
score: 0
type: Comment
has text: One more thing its working on this website for regex but in java I get syntax error, `String regex = "(?<=lastStop=["']?)[^"']*";` , how to correct that?
comment on: http://stackoverflow.com/a/2636069
type: AnswerComment

http://stackoverflow.com/a/4218624
answers question: http://stackoverflow.com/q/2704099
has body: The simplest means of displaying messages on your JSP is to have a scoped (maybe session, maybe request) object that contains the messages that you want to display. For example you could do the following: ... java stuff ... List messages = new ArrayList(); messages.add("some message"); messages.add("some other message"); request.addAttribute("NotableMessages", messages); ... java stuff ... ... jsp and JSTL stuff ... &lt;c:if test="not empty NotableMessages"&gt; &lt;ul&gt; &lt;c:forEach items="${NotableMessages}" var="item"&gt; &lt;li&gt;${item}&lt;/li&gt; &lt;/c:forEach&gt; &lt;/ul&gt; &lt;/c:if&gt; ... jsp stuff ...
score: 0
type: Answer

http://stackoverflow.com/comment/2674296
score: 0
type: Comment
type: QuestionComment
has text: @Ben: bear with me, im trying to figure this all out. So i am assuming you are talking about the SetNext and SetPrev functions? The end user should not have access to them, they should only have access to, say, the add and remove methods, which will then call them. That being said, would it still make more sense to pass by address in this case? My original though for pass by function, was that by using const, we wouldn't be able to change the data there, only use it (in this case get the address). However, my mind is turning every which way trying to understand all of this, so help is welcome!
comment on: http://stackoverflow.com/q/2657298

http://stackoverflow.com/comment/2642600
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2612859
has text: @ddimitrov sorry, you don't need an interface to use the constants, but its still declaring the name of the method as a string passive of rumtime error if the method name is mistyped
type: AnswerComment

http://stackoverflow.com/q/2606049
accepted answer: http://stackoverflow.com/a/2619574
tagged with: asp.net
favorite count: 0
tagged with: xss
possible better answer: http://stackoverflow.com/a/2606261
has answer: http://stackoverflow.com/a/2606261
score: 2
downvote count: 0
has body: I'm developer moving from C# to Java. Heard about new ASP net feature. &lt;%: %>. It renders object with html encoding. Only these impolementing IHtmlString interface are not encoded (to prevent double encoding). See more in http://weblogs.asp.net/scottgu/archive/2010/04/06/new-lt-gt-syntax-for-html-encoding-output-in-asp-net-4-and-asp-net-mvc-2.aspx Is such cute tool in Java side? I mean a way to output a string to webpage and (not)encode it based on it's type.
type: AnsweredQuestion
has title: Is there Java counterpart for Aspnet 4's <%: %> XSS prevention?
tagged with: asp.net-mvc
tagged with: java
type: Question
upvote count: 2
answer count: 2
has answer: http://stackoverflow.com/a/2619574

http://stackoverflow.com/a/2723868
score: 0
has body: First of all, your regex reads like this: GET.*?(\.flv) | (\.mp4) | (\.avi).*? (spaces added for clarity). Try it like this: GET.*?(\.flv|\.mp4|\.avi).*?
type: Answer
answers question: http://stackoverflow.com/q/2723765

http://stackoverflow.com/comment/2682830
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2664833
has text: if you just need to read a single line, a scanner is overkill...Using a BufferedReader should be less resource-consuming.

http://stackoverflow.com/q/2598791
upvote count: 0
answer count: 1
has body: I'm using jRuby and a Java library (using itself an applescript to play with MS Word) to convert Word documents to PDF files. Sometimes I get a dialog about margins issues, or MS Word is freezing because the file is too big. Could anyone recommend a script or library that I could run on OSX to manage these issues (closing the dialog / restarting Word if not responding)? The problem is that I don't really know about applescript and the Java library is not opensource, so it can be an observer or something running another programming language, I don't really mind.
tagged with: jruby
tagged with: macos
tagged with: ms-word
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2825134
downvote count: 1
tagged with: applescript
has title: How to deal when MS Word 2004 (OSX) is freezing or displaying dialogs?
tagged with: java
score: -1
type: Question

http://stackoverflow.com/q/2674554
tagged with: types
has title: How do you know a variable type in java?
downvote count: 0
answer count: 7
has answer: http://stackoverflow.com/a/2674579
tagged with: variables
possible better answer: http://stackoverflow.com/a/26507980
favorite count: 0
linked to: http://stackoverflow.com/q/12361492
has comment: http://stackoverflow.com/comment/2693588
has answer: http://stackoverflow.com/a/2674558
accepted answer: http://stackoverflow.com/a/2674558
has answer: http://stackoverflow.com/a/21568625
has answer: http://stackoverflow.com/a/45019533
upvote count: 207
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2674757
has body: Let's say I declare a variable: String a = "test"; And I want to know what type it is, i.e., the output should be java.lang.String How do I do this?
has answer: http://stackoverflow.com/a/26507980
type: Question
has comment: http://stackoverflow.com/comment/2693573
has answer: http://stackoverflow.com/a/39682303
duplicate of: http://stackoverflow.com/q/3993982
tagged with: java
has comment: http://stackoverflow.com/comment/28791959
linked to: http://stackoverflow.com/q/3993982
score: 207
has comment: http://stackoverflow.com/comment/2693320
has comment: http://stackoverflow.com/comment/28793104
has comment: http://stackoverflow.com/comment/2693362

http://stackoverflow.com/q/2689675
type: AnsweredQuestion
has title: How to get the Group Id of symbian using J2ME
score: 1
tagged with: java
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/2689734
has body: I got the group names by using ContactList clist=(ContactList)pim.openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE); String[] s=clist.getCategories(); and now i want the groupid like i am getting the contact id using Contact.uid
answer count: 1
downvote count: 0
tagged with: java-me
favorite count: 0
accepted answer: http://stackoverflow.com/a/2689734

http://stackoverflow.com/comment/61914605
type: Comment
score: 2
comment on: http://stackoverflow.com/a/2728547
type: AnswerComment
has text: yeah, what I meant is that RPC originated in the C/Unix world (at least the most common RPC implementation, ONCRPC) and as such it is modeled after that computation model; of course nothing prevents to implement it on top of any other programming language

http://stackoverflow.com/q/2664578
linked to: http://stackoverflow.com/q/964392
upvote count: 1
has answer: http://stackoverflow.com/a/2710308
answer count: 1
tagged with: envjs
favorite count: 0
has title: Using javax.script or Rhino to run javascript in Java with browser context (e.g. envjs)?
type: UnansweredQuestion
tagged with: javax.script
has body: I am trying to run Protovis javascript from a Java program using javax.script: ScriptEngineManager factory = new ScriptEngineManager(); ScriptEngine engine = factory.getEngineByName("JavaScript"); engine.eval(new java.io.FileReader("protovis-d3.1.js")); In order to run this, the JavaScript engine needs to have all the context of a web browser. The best option for this seems to be envjs. Unfortunately it seems that the version of Rhino included in the JVM isn't up to date and doesn't include everything that's necessary for envjs. Has anyone had any success working with a browser context from javax.script, or am I missing something? This is related to this question: "Can I create a ‘window’ object for javascript running in the Java6 Rhino Script Engine".
downvote count: 0
score: 1
tagged with: java
type: Question
tagged with: protovis
tagged with: javascript

http://stackoverflow.com/comment/16934382
score: 0
type: AnswerComment
has text: might be a very naive question but doesn't it beat the point to have a concurrent collection if it's implemented async?
comment on: http://stackoverflow.com/a/2759145
type: Comment

http://stackoverflow.com/comment/2804111
comment on: http://stackoverflow.com/a/2770338
score: 0
type: AnswerComment
has text: @zerocrates: similar but different! Using `?` still offers type safety. I covered it in my answer.
type: Comment

http://stackoverflow.com/comment/2812547
comment on: http://stackoverflow.com/a/2775987
score: 0
type: AnswerComment
type: Comment
has text: Even Spring 3.0 with just spring core, and using annotation-config?

jdo
tags question: http://stackoverflow.com/q/2688473
tags question: http://stackoverflow.com/q/2657394
tag name: jdo
tags question: http://stackoverflow.com/q/2679759
tags question: http://stackoverflow.com/q/2641239
tags question: http://stackoverflow.com/q/2759805
type: Tag
tags question: http://stackoverflow.com/q/2605923
tags question: http://stackoverflow.com/q/2632360
tags question: http://stackoverflow.com/q/2676194

http://stackoverflow.com/q/2609301
answer count: 4
type: AnsweredQuestion
tagged with: apache-poi
downvote count: 0
has answer: http://stackoverflow.com/a/2609474
accepted answer: http://stackoverflow.com/a/2609474
has comment: http://stackoverflow.com/comment/2619794
tagged with: excel
type: Question
possible better answer: http://stackoverflow.com/a/5812592
tagged with: java
has body: I have an excel spreadsheet that is password-protected. I need to open this spreadsheet and read the data from it. I've been attempting to use the POI API to no avail. A Java solution would be preferred but any ideas would be helpful. Edit: Yes, I have the password. The file is password protected in excel; a password must be entered to view the spreadsheet. Edit2: I am unable to open it with POI with the password, I am looking for an alternate solution.
score: 5
linked to: http://stackoverflow.com/q/1204382
has answer: http://stackoverflow.com/a/5812592
has answer: http://stackoverflow.com/a/10738978
has comment: http://stackoverflow.com/comment/2619751
favorite count: 0
upvote count: 5
has comment: http://stackoverflow.com/comment/2619854
has answer: http://stackoverflow.com/a/2609535
has title: Password Protected Excel File

http://stackoverflow.com/comment/95381449
score: 0
type: AnswerComment
has text: This answer throws an exception on "d135". It doesn't handle a single character as the name followed by a number. I think you need `while (--i >= 0)` and to change your last `if` to `if (i > 0 && len - i > 1)`.
type: Comment
comment on: http://stackoverflow.com/a/2620941

http://stackoverflow.com/comment/2650069
comment on: http://stackoverflow.com/a/2635490
type: AnswerComment
has text: Is it possible to create non-eclipse OSGi bundles using Tycho ?
type: Comment
score: 2

http://stackoverflow.com/a/2645142
answers question: http://stackoverflow.com/q/2644688
has comment: http://stackoverflow.com/comment/2660267
upvote count: 6
type: Answer
has body: I would generally recommend not using a LinkedBlockingQueue in a performance sensitive area of code, use an ArrayBlockingQueue. It will giving a much nicer garbage collection profile and is more cache friendly than the LinkedBlockingQueue. Try the ArrayBlockingQueue and measure the performance. The only advantage of the LinkedBlockingQueue is that it can be unbounded, however this is rarely what you actually want. If you have a case where a consumer fails and queues start backing up, having bounded queues allows the system to degrade gracefully rather risk OutOfMemoryErrors that may occur if queues are unbounded.
downvote count: 0
score: 6

http://stackoverflow.com/a/13860182
answers question: http://stackoverflow.com/q/2660961
type: Answer
has comment: http://stackoverflow.com/comment/19205038
score: 0
has comment: http://stackoverflow.com/comment/19083739
has body: I haven't read all the previous replies, but I also have the same issue. I'm running Eclipse 4.1 on Ubuntu 12.10, 64 Bit, and a SSD. I realized that this deletion issue always comes up when my computer crashes with an opened Eclipse. I managed to solve the issue by deleting particular index files. For example, my workspace log file (located at /.metadata/.log) was full with EOFException, saying that some metadata could not be read, such as !ENTRY org.eclipse.ui.ide 4 4 2012-12-13 13:25:35.988 !MESSAGE Problems occurred refreshing the selected resources. !SUBENTRY 1 org.eclipse.core.resources 4 567 2012-12-13 13:25:35.988 !MESSAGE Could not read metadata for '/home/xyzworkspace/.metadata/.plugins/org.eclipse.core.resources/.projects/server-test/.indexes/7/9c/properties.index'. !STACK 0 java.io.EOFException at java.io.DataInputStream.readByte(DataInputStream.java:250) at org.eclipse.core.internal.localstore.Bucket.load(Bucket.java:298) at org.eclipse.core.internal.properties.PropertyBucket.load(PropertyBucket.java:258) at org.eclipse.core.internal.localstore.Bucket.load(Bucket.java:274) at org.eclipse.core.internal.localstore.BucketTree.internalAccept(BucketTree.java:98) at org.eclipse.core.internal.localstore.BucketTree.internalAccept(BucketTree.java:109) at org.eclipse.core.internal.localstore.BucketTree.internalAccept(BucketTree.java:109) at org.eclipse.core.internal.localstore.BucketTree.accept(BucketTree.java:76) at org.eclipse.core.internal.properties.PropertyManager2.deleteProperties(PropertyManager2.java:102) at org.eclipse.core.internal.properties.PropertyManager2.deleteResource(PropertyManager2.java:111) at org.eclipse.core.internal.resources.Resource.deleteResource(Resource.java:918) ... here goes the rest of the stack trace... After deleting this particular index file and restarting Eclipse, everything worked as before. Any feedback whether the suggestion worked is appreciated.

http://stackoverflow.com/comment/17337895
score: 0
has text: That seems terribly old: the web page is dated 2001. Is it still alive?
type: Comment
comment on: http://stackoverflow.com/a/2777391
type: AnswerComment

http://stackoverflow.com/a/2783435
has body: If you can get the data into an Iterable&lt;Iterable&lt;T&gt;&gt;, then you can get from that to a flattened Iterable&lt;T&gt; using Guava's Iterables.concat method. If what you have is really an Iterable&lt;S&gt;, with some way to get from an S to an Iterable&lt;T&gt;, well, then you have to first use Iterables.transform to view that as the Iterable&lt;Iterable&lt;T&gt;&gt; needed by concat. All this will look a lot nicer if and when Java has something resembling closures, but at least today it's possible. http://guava-libraries.googlecode.com
answers question: http://stackoverflow.com/q/2782893
downvote count: 0
type: Answer
score: 7
upvote count: 7

http://stackoverflow.com/comment/3079681
comment on: http://stackoverflow.com/q/2705091
has text: That's why I said: "I've tried various ways - using the native int, casting to an Integer, but nothing works." The issue is that the map.get cannot return an int from a ListPreference array, which is what I wanted to do.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2764794
has body: I have a webpage in which i want the css file to be the same name as a session variable I have set. For example; If the session variable was "blue", i want the page to load the CSS file blue.css. I tried something below which didnt work, and I'm now stuck. My knowledge of struts is very limited. &lt;LINK rel="stylesheet" type="text/css" href="&lt;html:rewrite page='/css/&lt;c:out value="${brand}"/&gt;.css'/&gt;"&gt; This is the full code listing at the top of my jsp page &lt;%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %&gt; &lt;%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %&gt; &lt;%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %&gt; &lt;%@ taglib uri="http://jakarta.apache.org/struts/tags-html-el" prefix="html-el"%&gt; &lt;html:html lang="true"&gt; &lt;head&gt; &lt;LINK rel="stylesheet" type="text/css" href="&lt;html:rewrite page='/css/${brand}.css'/&gt;"&gt; &lt;html:base/&gt; I do not know how to find the version of JSP and JSTL I am using. This was a project picked up from someone else and I have never used them before
upvote count: 1
has answer: http://stackoverflow.com/a/2764838
tagged with: struts-1
type: Question
has answer: http://stackoverflow.com/a/3801269
tagged with: struts
has answer: http://stackoverflow.com/a/2764830
downvote count: 0
has answer: http://stackoverflow.com/a/2765319
score: 1
favorite count: 0
answer count: 5
type: UnansweredQuestion
tagged with: css
has title: How to have dynamic css files depending on struts session variable
has answer: http://stackoverflow.com/a/2765843
tagged with: java

http://stackoverflow.com/comment/128108036
comment on: http://stackoverflow.com/a/2780172
has text: The problem is that if you add more elements to the enum later you will need to remember to manually update this array. Goal is to avoid having this duplication and just automatically find the right value based on the input.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/40350609
comment on: http://stackoverflow.com/a/2608406
type: AnswerComment
type: Comment
score: 0
has text: before you have to assign `mPreferences = getSharedPreferences("prefs", 0);`

http://stackoverflow.com/comment/57714328
has text: How does this not have more upvotes? Clearest answer!
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/15547976
type: Comment

http://stackoverflow.com/q/2706630
has body: I have two spring config files and I'm specifying them in my web.xml as in below. web.xml snippet .. contextConfigLocation WEB-INF/classes/domain-context.xml WEB-INF/classes/client-ws.xml org.springframework.web.context.ContextLoaderListener .. From my domain object I have to invoke a Web Service Client and in order to get a reference to the Web Service client I do this: ApplicationContext context = new ClassPathXmlApplicationContext("client-ws.xml"); //b'cos I don't want to use WebApplicationContextUtils ProductServiceClient client = (ProductServiceClient) context.getBean("productClient"); .. client.find(prodID); //calls a Web Service .. However, I have concerns that looking up the client-ws.xml file and getting a reference to the ProductServiceClient bean is not efficient. I thought of getting it using WebApplicationContextUtils. However, I don't want my domain objects to have a dependency on the ServletContext (a web/control layer object) because WebApplicationContextUtils depends on ServletContext. What is the best way to get a reference to a spring bean in the backend layers? Thanks!
upvote count: 3
tagged with: java
has answer: http://stackoverflow.com/a/2709676
type: Question
score: 3
has title: What is the best way to get a reference to a spring bean in the backend layers?
has answer: http://stackoverflow.com/a/2706639
answer count: 3
downvote count: 0
accepted answer: http://stackoverflow.com/a/2709676
favorite count: 0
tagged with: spring
possible better answer: http://stackoverflow.com/a/2706644
has answer: http://stackoverflow.com/a/2706644
type: AnsweredQuestion

http://stackoverflow.com/a/2708638
has body: I wouldn't write the first one. It's not necessary to use the latest syntax in every setting. Your instinct is a good one: if it feels and looks clumsy, it probably is. Go with #2 and sleep at night.
answers question: http://stackoverflow.com/q/2708621
downvote count: 0
has comment: http://stackoverflow.com/comment/2732743
type: Answer
score: 1
upvote count: 1

http://stackoverflow.com/comment/2699070
type: AnswerComment
type: Comment
score: 0
comment on: http://stackoverflow.com/a/2679388
has text: Yes, actually the session is created internally in the test. Or what do you mean by manually creating the Session? I edited my question to reflect that.

http://stackoverflow.com/comment/2747809
type: AnswerComment
has text: @Stephen C: JCIP page 142, there's your "explanation". Btw I didn't pretend to have any explanation and ended up my comment with a question mark '?' in case you didn't notice :)
type: Comment
score: 0
comment on: http://stackoverflow.com/a/2720787

http://stackoverflow.com/comment/93513261
has text: @Jack: This occurred to me as well. In general, I would prefer if I did not have to specify an owner for an association. Owner for me means **aggregation** (which is one option) but I might want to model a simple association between two entities that exist on their own.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/21068644

http://stackoverflow.com/q/2665544
has answer: http://stackoverflow.com/a/2665580
accepted answer: http://stackoverflow.com/a/2665580
score: 1
tagged with: java
upvote count: 1
has answer: http://stackoverflow.com/a/4402577
type: Question
tagged with: mongodb
has answer: http://stackoverflow.com/a/3475837
answer count: 3
downvote count: 0
has body: I have launch mongodb server: [demas@arch.local.net][~]% mongod --dbpatmongod --dbpath /home/demas/temp/ Mon Apr 19 09:44:18 Mongo DB : starting : pid = 4538 port = 27017 dbpath = /home/demas/temp/ master = 0 slave = 0 32-bit ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data ** see http://blog.mongodb.org/post/137788967/32-bit-limitations for more Mon Apr 19 09:44:18 db version v1.4.0, pdfile version 4.5 Mon Apr 19 09:44:18 git version: nogitversion Mon Apr 19 09:44:18 sys info: Linux arch.local.net 2.6.33-ARCH #1 SMP PREEMPT Mon Apr 5 05:57:38 UTC 2010 i686 BOOST_LIB_VERSION=1_41 Mon Apr 19 09:44:18 waiting for connections on port 27017 Mon Apr 19 09:44:18 web admin interface listening on port 28017 I have created documents by console client: [demas@arch.local.net][~]% mongo MongoDB shell version: 1.4.0 url: test connecting to: test type "help" for help &gt; db.some.find(); { "_id" : ObjectId("4bcbef3c3be43e9b7e04ef3d"), "name" : "mongo" } { "_id" : ObjectId("4bcbef423be43e9b7e04ef3e"), "x" : 3 } Now I am trying to work with MongoDb from Java: import com.mongodb.*; import java.net.UnknownHostException; public class test1 { public static void main(String[] args) { System.out.println("Start"); try { Mongo m = new Mongo("localhost", 27017); DB db = m.getDB("test"); DBCollection coll = db.getCollection("some"); coll.insert(makeDocument(10, "James", "male")); System.out.println("Finish"); } catch (UnknownHostException ex) { ex.printStackTrace(); } catch (MongoException ex) { ex.printStackTrace(); } } public static BasicDBObject makeDocument(int id, String name, String gender) { BasicDBObject doc = new BasicDBObject(); doc.put("id", id); doc.put("name", name); doc.put("gender", gender); return doc; } } But execution stops on line coll.insert(): [demas@arch.local.net][~/dev/study/java/mongodb]% javac test1.java [demas@arch.local.net][~/dev/study/java/mongodb]% java test1 Start There are not messages from mogodb server regarding accepted conn…
favorite count: 0
tagged with: mongo-java
possible better answer: http://stackoverflow.com/a/3475837
has title: Working with mongodb from Java
type: AnsweredQuestion

http://stackoverflow.com/a/2616205
score: 0
type: Answer
answers question: http://stackoverflow.com/q/2616050
has body: What I would recommend is instead of using all these exceptions is to make separate methods that read specific data types. (Ex.) import java.util.Scanner; public class HelloWorld { public static void main(String[] args){ int n = getInteger("Enter integer: "); System.out.println(n); } public static boolean isInteger(String s){ if(s.isEmpty())return false; for (int i = 0; i &lt;s.length();++i){ char c = s.charAt(i); if(!Character.isDigit(c) &amp;&amp; c !='-') return false; } return true; } public static int getInteger(String prompt){ Scanner input = new Scanner(System.in); String in = ""; System.out.println(prompt); in = input.nextLine(); while(!isInteger(in)){ System.out.println(prompt); in = input.nextLine(); } return Integer.parseInt(in); } }

http://stackoverflow.com/q/2683182
downvote count: 0
has body: How and where do you define your own Exception hierarchy in Java? My main question concerns package location where your Exception classes must be defined. Do we create a special package for our exceptions and put all classes inside it?
has answer: http://stackoverflow.com/a/2683465
score: 36
tagged with: exception
has answer: http://stackoverflow.com/a/2683261
favorite count: 0
has comment: http://stackoverflow.com/comment/110323645
accepted answer: http://stackoverflow.com/a/2683261
has answer: http://stackoverflow.com/a/2683217
answer count: 5
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/62379347
tagged with: java
has title: How and where do you define your own Exception hierarchy in Java?
type: Question
tagged with: try-catch
has answer: http://stackoverflow.com/a/2683244
upvote count: 36
possible better answer: http://stackoverflow.com/a/2683465

http://stackoverflow.com/a/8142813
upvote count: 6
type: Answer
downvote count: 4
answers question: http://stackoverflow.com/q/2642777
score: 2
has body: Here is a much simple version using 4.1.2 httpclient code. This can then be modified to any trust algorithm you see fit. public static HttpClient getTestHttpClient() { try { SSLSocketFactory sf = new SSLSocketFactory(new TrustStrategy(){ @Override public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException { return true; } }); SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("https", 443, sf)); ClientConnectionManager ccm = new ThreadSafeClientConnManager(registry); return new DefaultHttpClient(ccm); } catch (Exception e) { return new DefaultHttpClient(); } }

http://stackoverflow.com/a/2727721
has comment: http://stackoverflow.com/comment/2759282
score: 3
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2727515
answers question: http://stackoverflow.com/q/2727515
type: AcceptedAnswer
upvote count: 3
has body: This says that one Lucene class is inconsistent with another Lucene class -- one is accessing a member of the other that it can't. This strongly suggests you have two different and incompatible versions of Lucene in your classpath somehow.
has comment: http://stackoverflow.com/comment/2756022
has comment: http://stackoverflow.com/comment/2760379
type: Answer
has comment: http://stackoverflow.com/comment/2761494

http://stackoverflow.com/comment/2704811
comment on: http://stackoverflow.com/a/2684698
score: 0
type: AnswerComment
has text: @aperkins: +1 for the shiny tool :)
type: Comment

http://stackoverflow.com/a/2700832
answers question: http://stackoverflow.com/q/2700775
upvote count: 2
has comment: http://stackoverflow.com/comment/2723601
type: Answer
downvote count: 1
has body: Language design is a matter of taste. Having said that, this kind of list/object initialization has become very popular. For example, C# has almost the same thing. The syntax is quite flexible and, as even your examples show, lets you initialize something like a dictionary inline. I rather like the syntax the designers chose here.
score: 1

http://stackoverflow.com/comment/2719627
has text: I've just found suitable example to learn regex of course I'll not parse my emails with it, I'm just trying to learn regex by trying some examples
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2697290
type: AnswerComment

http://stackoverflow.com/a/2724545
answers question: http://stackoverflow.com/q/2701565
has body: I ended up putting them back to the package, and it works fine now.
score: 0
type: Answer

http://stackoverflow.com/comment/16622217
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2729070
has text: ThomasEding I'm seriously contemplating deleting this post as people think I favor this crap. I only wrote reasons why people do it and I no longer work at the company that did. From the user's perspective I was only being consistent with shit code that already existed and I could see why they did it.. because they did not know how to use eclipse and eclipse didn't always support @Nate syntax color highlighting.
type: AnswerComment

http://stackoverflow.com/q/2655964
has title: Where to put external archives to configure running in Eclipse?
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2656003
tagged with: java
tagged with: eclipse
type: Question
has answer: http://stackoverflow.com/a/2656006
answer count: 2
tagged with: runtime
tagged with: jar
has body: As a Java/Eclipse noob coming from a Visual Studio .NET background, I'm trying to understand how to set up my run/debug environment in the Eclipse IDE so I can start stepping through code. I have built my application with separate src and bin hierarchies for each library project, and each project has its own jar. For example, in a Windows environment, I have something like: c:\myapp\myapp_main\src\com\mycorp\myapp\main ...and a parallel "bin" tree like this: c:\myapp\myapp_main\bin\com\mycorp\myapp\main Other supporting projects are, similarly: c:\myapp\myapp_util\src\com\mycorp\myapp\util (and a parallel "bin" tree), etc. So, I end up with, e.g., myapp_util.jar in the ...\myapp_util\bin... path and then add that as an external archive to my myapp_main project. I also use utilities like gluegen-rt.jar, which I add ad external dependencies to the projects requiring them. I have been able to run outside of the Eclipse environment, by copying all my project jars, gluegen-rt DLL, etc., into a "lib" subfolder of some directory and executing something like: java -Djava.library.path=lib -DfullScreen=false -cp lib/gluegen-rt.jar;lib/myapp_main.jar;lib/myapp_util.jar; com.mycorp.myapp.Main In the IDE, however, When I first pressed F11 to debug I got a message about something like /com/sun/../glugen... not being found by the class loader. So, to debug, or even just run, in Ecplipse, I tried setting up my VM arguments in the Galileo Debug -> (Run/Debug) Configurations to be the command line above, beginning at "-Djava.libary.path...". I've put a lib subdirectory - just like the above with all jars and the native gluegen DLL - in various places, such as beneath the folder that my main jar is built in and as a subfolder of my Ecplipse starting workspace folder, but now the debugger can't find the main class: java.lang.NoClassDefFoundError: com.mycorp.myapp.Main Although the Classpath says that it is using the "default classpath", whatever that is. Bottom line, how do I assemble …
score: 0

http://stackoverflow.com/q/2676719
has answer: http://stackoverflow.com/a/67467448
tagged with: graphics
answer count: 8
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/16127022
tagged with: java
has comment: http://stackoverflow.com/comment/2695752
possible better answer: http://stackoverflow.com/a/7805311
accepted answer: http://stackoverflow.com/a/2676810
type: Question
has answer: http://stackoverflow.com/a/7805311
has answer: http://stackoverflow.com/a/27481611
score: 64
has answer: http://stackoverflow.com/a/57909855
has comment: http://stackoverflow.com/comment/2695668
downvote count: 0
favorite count: 0
upvote count: 64
tagged with: android
has title: Calculating the angle between a line and the x-axis
has answer: http://stackoverflow.com/a/72187883
has answer: http://stackoverflow.com/a/2676810
has answer: http://stackoverflow.com/a/58300645
has comment: http://stackoverflow.com/comment/2695744
has body: I'm currently developing a simple 2D game for Android. I have a stationary object that's situated in the center of the screen and I'm trying to get that object to rotate and point to the area on the screen that the user touches. I have the constant coordinates that represent the center of the screen and I can get the coordinates of the point that the user taps on. I'm using the formula outlined in this forum: How to get angle between two points? It says as follows "If you want the the angle between the line defined by these two points and the horizontal axis: double angle = atan2(y2 - y1, x2 - x1) * 180 / PI;". I implemented this, but I think the fact the I'm working in screen coordinates is causing a miscalculation, since the Y-coordinate is reversed. I'm not sure if this is the right way to go about it, any other thoughts or suggestions are appreciated.

http://stackoverflow.com/a/2750094
has body: The link below is to an article that determines if a cell is visible. You could use that - if the cell is visible, then the row is visible. (But of course, possibly not the entire row, if horizontal scrolling is also present.) However, I think this will fail when the cell is wider than the viewport. To handle this case, you change the test to check if the top/bottom of the cell bounds is within the vertical extent of the viewport, but ignore the left/right part of the cell. It is simplest to set the left and width of the rectangle to 0. I've also changed the method to take just the row index (no need for column index) and it returns true if the table is not in a viewport, which seems to align better with your use-case. public boolean isRowVisible(JTable table, int rowIndex) { if (!(table.getParent() instanceof JViewport)) { return true; } JViewport viewport = (JViewport)table.getParent(); // This rectangle is relative to the table where the // northwest corner of cell (0,0) is always (0,0) Rectangle rect = table.getCellRect(rowIndex, 1, true); // The location of the viewport relative to the table Point pt = viewport.getViewPosition(); // Translate the cell location so that it is relative // to the view, assuming the northwest corner of the // view is (0,0) rect.setLocation(rect.x-pt.x, rect.y-pt.y); rect.setLeft(0); rect.setWidth(1); // Check if view completely contains the row return new Rectangle(viewport.getExtentSize()).contains(rect); } Determining if a cell is visible in JTable
type: Answer
answers question: http://stackoverflow.com/q/2749977
upvote count: 3
has comment: http://stackoverflow.com/comment/2780551
score: 3
downvote count: 0

http://stackoverflow.com/a/2739204
has body: In the getView() method, can't you just setOnClickListener() on the button? Something like this: static final class MyAdapter extends BaseAdapter { /** override other methods here */ @Override public View getView(final int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { // inflate the view for row from xml file // keep a reference to each widget on the row. // here I only care about the button holder = new ViewHolder(); holder.mButton = (Button)convertView.findViewById(R.id.button); convertView.setTag(holder); } else { holder = (ViewHolder)convertView.getTag(); } // redefine the action for the button corresponding to the row holder.mButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // do something depending on position performSomeAction(position); // mark data as changed MyAdapter.this.notifyDatasetChanged(); } } } static final class ViewHolder { // references to widgets Button mButton; } } If you're unsure about extending BaseAdapter, check out example List14 in ApiDemos. This techniques provides you with a flexible way to modify just about any aspect of your adapter, though it's quite some work.
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/2768014
answers question: http://stackoverflow.com/q/2739086

http://stackoverflow.com/a/39142385
score: 3
upvote count: 3
has body: TestNG does not use Spring to instantiate your test. That's why someField=null
downvote count: 0
answers question: http://stackoverflow.com/q/2624724
type: Answer

http://stackoverflow.com/a/58854848
downvote count: 0
answers question: http://stackoverflow.com/q/2637864
type: Answer
score: 3
has body: All the answers, so far at least, concentrate on explaining the difference between the design pattern and Spring singleton and do not address your actual question: Should a Singleton design pattern be used or a Spring singleton bean? what is better? Before I answer let me just state that you can do both. You can implement the bean as a Singleton design pattern and use Spring to inject it into the client classes as a Spring singleton bean. Now, the answer to the question is simple: Do not use the Singleton design pattern! Use Spring's singleton bean implemented as a class with public constructor. Why? Because the Singleton design pattern is considered an anti-pattern. Mostly because it complicates testing. (And if you don't use Spring to inject it then all classes that use the singleton are now tightly bound to it), and you can't replace or extend it. One can google "Singleton anti-pattern" to get more info on this, e.g. Singleton anti-pattern Using Spring singleton is the way to go (with a the singleton bean implemented NOT as a Singleton design pattern, but rather with a public constructor) so that the Spring singleton bean can easily be tested and classes that use it are not tightly coupled to it, but rather, Spring injects the singleton (as an interface) into all the beans that need it, and the singleton bean can be replaced any time with another implementation without affecting the client classes that use it.
upvote count: 3

http://stackoverflow.com/comment/2884760
comment on: http://stackoverflow.com/a/2780167
type: AnswerComment
has text: their actual requirements are reasonably clear (as clear as any ever are). But don't worry, that's always my #1 priority - nail down the requirements absolutely and make sure that the client understands that any change will cost time and/or money. The things is that they are tendering to do the job for a 3rd party, and they are the ones who "prefer" Java, but don't really want to discuss it.
score: 0
type: Comment

http://stackoverflow.com/comment/2631408
has text: D'oh! I think you might be right, this maybe be a better approach. Definitely something to consider. It also gains the benefit of not needing to parse the stream byte-by-byte like ndim is suggesting, which seems overkill for this.
comment on: http://stackoverflow.com/a/2619218
type: AnswerComment
type: Comment
score: 0

http://stackoverflow.com/a/2643049
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/2642992
accepted answer of: http://stackoverflow.com/q/2642992
downvote count: 0
has body: Well, I'm not about to look at all that code to try and figure out what you are doing. I'm not sure if it will work but you can try using the Screen Image class which tries to handle non-opaque backgrounds.
has comment: http://stackoverflow.com/comment/2658668
type: AcceptedAnswer
type: Answer

http://stackoverflow.com/comment/2701246
type: QuestionComment
has text: "I new to java so bare with me ..." - I bet you say that to all the guys :-)
score: 5
comment on: http://stackoverflow.com/q/2681550
type: Comment

http://stackoverflow.com/q/2705600
tagged with: ftp
has comment: http://stackoverflow.com/comment/2729176
has title: FTP upload via sockets
answer count: 5
type: UnansweredQuestion
tagged with: sockets
has body: how can I upload a file with sockets to a ftp server? I am reading something with "STOR" in RFC...It is the same how i transfer a file between two computers?A sample code would be helpfuly...thanks
has answer: http://stackoverflow.com/a/2705662
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/2705620
has answer: http://stackoverflow.com/a/2705651
score: 0
has answer: http://stackoverflow.com/a/2705615
has answer: http://stackoverflow.com/a/2705658

javacard
tag name: javacard
tags question: http://stackoverflow.com/q/2771365
type: Tag

http://stackoverflow.com/comment/2617729
has text: I had already learned regex by the time I stumbled across Rubular (http://rubular.com), but it seems like a great place for a beginner to experiment.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2607177
score: 0

http://stackoverflow.com/q/2692643
accepted answer: http://stackoverflow.com/a/2692668
tagged with: package
downvote count: 1
has comment: http://stackoverflow.com/comment/2715288
has answer: http://stackoverflow.com/a/2692846
has comment: http://stackoverflow.com/comment/2714128
type: AnsweredQuestion
score: 3
has title: Allow Incorrect Package Name in Eclipse
tagged with: java
tagged with: eclipse
type: Question
upvote count: 4
has body: I have some classes in my current project which have the wrong package declaration (they are in the wrong folder for their declared package.) Unfortunately, fixing the problem by moving the class is not an option. Is there a way I can get eclipse to ignore the error?
has comment: http://stackoverflow.com/comment/2714108
possible better answer: http://stackoverflow.com/a/2692687
has answer: http://stackoverflow.com/a/2692668
has answer: http://stackoverflow.com/a/2692687
has comment: http://stackoverflow.com/comment/2714594
answer count: 3
favorite count: 0

http://stackoverflow.com/a/2712507
answers question: http://stackoverflow.com/q/2712445
type: AcceptedAnswer
downvote count: 0
type: Answer
score: 2
upvote count: 2
has body: You could do one of the following: Define nextState as a mutable field within your State class, and wire up the states afterwards using a mutator; e.g. setNextState. The setNextState method could be implemented to only allow it to be called once; subsequent calls would cause an IllegalStateException to be thrown. Change the State interface to simply return whether a pre-condition is met or not (i.e. return a boolean) and use an external "coordinator" class to transition along the list if the pre-condition is met. In other words, you know that the next state is at index i+1 so there's no real need for each state to have explicit knowledge of its successor. Given the simplicity of your state machine I would favour the second approach.
accepted answer of: http://stackoverflow.com/q/2712445

http://stackoverflow.com/q/2727780
has comment: http://stackoverflow.com/comment/2755053
type: Question
has body: I've got problems starting my WAR application on a local JBoss. After two other EARs are deployed and the TomcatDeployer begins deploying the WAR, I'm getting the following error message: 2010-04-28 10:01:56,605 ERROR [org.jboss.ejb.plugins.LogInterceptor] [] [main] EJBException in method: public abstract [return type] methode throws javax.ejb.CreateException,java.rmi.RemoteException, causedBy: javax.ejb.EJBException: org.springframework.beans.factory.access.BootstrapException: Unable to initialize group definition. Group resource name [classpath*:context.xml], factory key [contextService]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'service' defined in URL [jar:file:/C:/jboss-4.2.3.GA/server/default/deploy/frontend.war/WEB-INF/lib/modules.jar!/aontext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.context.support.ClassPathXmlApplicationContext]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [package/context.xml]; nested exception is java.io.FileNotFoundException: class path resource [package/context.xml] cannot be opened because it does not exist But package/context.xml actually is placed inside a JAR in one of my EAR files which should be deployed before the WAR. And at least I get a message that the deployment of the EAR has been successful. I also looked into the JAR with my file archiver and the context.xml is indeed there at the right place. Is there a way for me to get sure that the JAR, not the EAR as a whole, is really deployed to the JBoss? I'm already starting to lose my head about this issue. Thank you. Bernhard
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2756169
tagged with: java
tagged with: jboss
possible better answer: http://stackoverflow.com/a/2727845
answer count: 2
has title: FileNotFoundException, although the XML file should be deployed
has answer: http://stackoverflow.com/a/2735206
accepted answer: http://stackoverflow.com/a/2735206
score: 0
has answer: http://stackoverflow.com/a/2727845
tagged with: spring

http://stackoverflow.com/q/2783204
tagged with: image-manipulation
score: 13
has comment: http://stackoverflow.com/comment/2818378
answer count: 4
upvote count: 13
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/25635162
accepted answer: http://stackoverflow.com/a/2783341
has comment: http://stackoverflow.com/comment/25635161
tagged with: java
has comment: http://stackoverflow.com/comment/25635160
has title: Flood fill using a stack
tagged with: flood-fill
type: Question
has answer: http://stackoverflow.com/a/24965523
possible better answer: http://stackoverflow.com/a/40421933
has answer: http://stackoverflow.com/a/40421933
has answer: http://stackoverflow.com/a/2783358
has body: I am using the recursive Flood fill algorithm in Java to fill some areas of a image. With very small images it works fine, but when de image becomes larger the JVM gives me a Stack Over Flow Error. That's the reason why I have to reimplement the method using a Flood Fill with my own stack. (I read that's the best way to do it in these kind of cases) Can anyone explain me how to code it? (if you don't have the code at hand, with the pseudo-code of the algorithm will be fine) I've read a lot in the Internet but I haven't understood it very well. EDIT: I added my recursive code public void floodFill(int x, int y, Color targetColor,Color replacementColor) { if (img.getRGB(x, y) != targetColor.getRGB()) return; img.setRGB(x, y, replacementColor.getRGB()); floodFill(x - 1, y, targetColor, replacementColor); floodFill(x + 1, y, targetColor, replacementColor); floodFill(x, y - 1, targetColor, replacementColor); floodFill(x, y + 1, targetColor, replacementColor); return; } Thanks!
has answer: http://stackoverflow.com/a/2783341
downvote count: 0
favorite count: 0

http://stackoverflow.com/a/57788264
answers question: http://stackoverflow.com/q/2676687
has body: if i get your question right , you wanna invoke someFunction() , execute the short smallOperation() , run a thread to the SecondOperation and make sure that when returned from this function , the SecondOperation is completed . if the flow i suggested is correct , u only need to add the following line : public void someFunction(String data) { smallOperation() SecondOperation a = new SecondOperation(); Thread th = new Thread(a); th.Start(); th.join(); //add this line to make your MainThread await for this to finish . } class SecondOperation implements Runnable { public void run(){ // doSomething long running } } take a look at this article , it states that "When we invoke the join() method on a thread, the calling thread goes into a waiting state. It remains in a waiting state until the referenced thread terminates" . which i think what you trying to accomplish if its not the case and you wanna be notified when the SecondOperation terminates , i suggest you use asyncTask
score: 0
type: Answer

http://stackoverflow.com/q/2750346
tagged with: java.util.logging
tagged with: pmd
has title: Logger vs. System.out.println
has answer: http://stackoverflow.com/a/2750389
score: 58
has answer: http://stackoverflow.com/a/2750374
has answer: http://stackoverflow.com/a/2750367
type: AnsweredQuestion
downvote count: 0
favorite count: 0
linked to: http://stackoverflow.com/q/2746578
accepted answer: http://stackoverflow.com/a/2750367
type: Question
has comment: http://stackoverflow.com/comment/2780519
upvote count: 58
answer count: 6
has answer: http://stackoverflow.com/a/20653334
has answer: http://stackoverflow.com/a/2750562
has answer: http://stackoverflow.com/a/2750385
tagged with: java
tagged with: eclipse
has body: I'm using the PMD plugin for eclipse and it gives me an error when using System.out.println() with the explanation: System.(out|err).print is used, consider using a logger. My question is - What is a Logger? How is it used to print to the screen? Why is it better?
possible better answer: http://stackoverflow.com/a/2750562

deployment
tags question: http://stackoverflow.com/q/2768528
tag name: deployment
tags question: http://stackoverflow.com/q/2712884
tags question: http://stackoverflow.com/q/2641338
tags question: http://stackoverflow.com/q/2720895
tags question: http://stackoverflow.com/q/2712768
tags question: http://stackoverflow.com/q/2670661
tags question: http://stackoverflow.com/q/2618281
tags question: http://stackoverflow.com/q/2768518
tags question: http://stackoverflow.com/q/2708573
type: Tag
tags question: http://stackoverflow.com/q/2781057
tags question: http://stackoverflow.com/q/2642696

rms
tag name: rms
type: Tag
tags question: http://stackoverflow.com/q/2632788
tags question: http://stackoverflow.com/q/2631450

http://stackoverflow.com/q/2699008
has answer: http://stackoverflow.com/a/2699080
has answer: http://stackoverflow.com/a/3208844
downvote count: 10
has answer: http://stackoverflow.com/a/5942303
type: Question
has comment: http://stackoverflow.com/comment/2721474
has answer: http://stackoverflow.com/a/14183431
has answer: http://stackoverflow.com/a/2702725
has body: Does anybody know if via the google api in java I can create google accounts programmatically.
has answer: http://stackoverflow.com/a/13690003
answer count: 11
favorite count: 0
has comment: http://stackoverflow.com/comment/37609748
upvote count: 38
has answer: http://stackoverflow.com/a/2699083
has comment: http://stackoverflow.com/comment/2721400
possible better answer: http://stackoverflow.com/a/2699134
has comment: http://stackoverflow.com/comment/2722520
accepted answer: http://stackoverflow.com/a/5942303
has answer: http://stackoverflow.com/a/2699134
score: 28
tagged with: google-api
has title: Can I create a Google account programmatically?
has answer: http://stackoverflow.com/a/55797701
has answer: http://stackoverflow.com/a/60096690
has comment: http://stackoverflow.com/comment/113888339
has comment: http://stackoverflow.com/comment/2723324
has comment: http://stackoverflow.com/comment/28878848
has comment: http://stackoverflow.com/comment/2721439
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2721560
has answer: http://stackoverflow.com/a/60257162
tagged with: java
has comment: http://stackoverflow.com/comment/2723059

http://stackoverflow.com/comment/2775453
has text: It won't let me accept my own answer until tomorrow, oh well. Now we know.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2746155

http://stackoverflow.com/a/34442999
upvote count: 1
answers question: http://stackoverflow.com/q/2775345
has body: Hi I used to have same problem or similar. In my case I defined the Form and initialized his properties. but when I submit the form I had same error, the message said that one of mi fields are null. That was because in my struts-config.xml I used to have scope="request" indeed of scope="session". That way every time I submit I lose my data.
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/67568089
score: 1

http://stackoverflow.com/comment/72559261
comment on: http://stackoverflow.com/a/38040074
has text: It's the `<logger>...` element. Specify the class or package as the name and the appender as the file appender.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2692593
type: Comment
has text: problem with this approach is that im using Spring Batch and a StoredProcedureItemReader, for which I just give a String parameter which is the procedure name, and a List of SqlParameter objects that create the CallableStatement (see: http://static.springsource.org/spring-batch/reference/html/readersAndWriters.html#StoredProcedureItemReader ), so unless something special exists in the sring core jdbc functionality, I'll be limited to using the CallableStatement reference directly to set the parameters
comment on: http://stackoverflow.com/a/2673799
score: 0
type: AnswerComment

http://stackoverflow.com/comment/2760665
comment on: http://stackoverflow.com/a/2732856
score: 0
type: Comment
has text: @Query is my annotation. In a later iteration, I was simply using NamedQuery annotations and then creating the named query based on the method name. It doesn't need to be a Seam component, I just want to give a query parameters without having to write the implementation which will be redundant work. Walter
type: AnswerComment

http://stackoverflow.com/comment/39840646
type: Comment
has text: @crushman not 100% sure, I think that would be ok. Needs to be first line in on create. But I usually put in an application class.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/16883281

http://stackoverflow.com/a/44243488
type: Answer
has body: Pass one activity to another: startActivity(new Intent(getBaseContext(),GetActivity.class).putExtra("passingkey","passingvalue")); Get values: String myvalue= getIntent().getExtras("passingkey");
score: 0
answers question: http://stackoverflow.com/q/2736389

http://stackoverflow.com/a/2636472
accepted answer of: http://stackoverflow.com/q/2636399
answers question: http://stackoverflow.com/q/2636399
type: Answer
score: 0
has body: Since you are looking for new AJAX methods for the web, you can leverage your Java programming skills with Google Web Toolkit (GWT), it makes the integration between the client and the server sides quite seamless. You can use Java on both the client and the server side. (The GWT Compiler generates JavaScript from Java for the client side) I recommend you have a look at the GWT Remote Procedure Call (RPC) tutorial to see how easy it is to communicate between the client and the server in an asynchronous way. It might be a good fit for your project since you are not prone to some of its cons like SEO, as I do not think that an accounting system would care about SEO. Keywords: Java, Interactive, AJAX Calls.
type: AcceptedAnswer

http://stackoverflow.com/q/2649573
has answer: http://stackoverflow.com/a/2649618
has comment: http://stackoverflow.com/comment/2667162
has comment: http://stackoverflow.com/comment/2665618
accepted answer: http://stackoverflow.com/a/2649602
has comment: http://stackoverflow.com/comment/2665600
type: AnsweredQuestion
tagged with: java
type: Question
upvote count: 4
has answer: http://stackoverflow.com/a/2649594
downvote count: 4
has title: in java can one have an array of variables?
tagged with: arrays
has answer: http://stackoverflow.com/a/2649590
has body: in java can you have an array of variables? if so what is the syntax? here's an example if your confused: varint[] ArrayOfVariablesThatAreInts = new varint[#] or var[] ArrayofVariables = new var[#] is something like this legal?
tagged with: variables
answer count: 6
has answer: http://stackoverflow.com/a/2649602
score: 0
has comment: http://stackoverflow.com/comment/2665604
possible better answer: http://stackoverflow.com/a/2650127
favorite count: 0
has answer: http://stackoverflow.com/a/2650127
has answer: http://stackoverflow.com/a/2649582

http://stackoverflow.com/comment/2651361
score: 2
type: QuestionComment
has text: See also http://stackoverflow.com/questions/904492/
comment on: http://stackoverflow.com/q/2635272
type: Comment

http://stackoverflow.com/comment/34621645
has text: possible duplicate of [Java Timestamp - How can I create a Timestamp with the date 23/09/2007?](http://stackoverflow.com/questions/974973/java-timestamp-how-can-i-create-a-timestamp-with-the-date-23-09-2007)
comment on: http://stackoverflow.com/q/2742380
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2646037
tagged with: datetime
tagged with: timezone
tagged with: utc
has body: For example, when I extract from a database a Date() variable, it contains a date with "+04:00" shift. According to my locale's settings. So, UTC time is "ourTime" MINUS 4 hours. Then, a user tells where he/she is from. Now, we need to save his/her shift. LET'S SAY it is -01:00. And finally, this user tells us where's he/she is heading, let's say this place has a time shift of +05:00. How do we save this town's or place's time shifts in the DB so that according to where he/she's from we could calculate the time difference with our current locale? Also, date save light things, how do we work with them?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2646103
tagged with: java
has title: Java TimeZones: how to get UTC time values based on Console settings?
type: Question
answer count: 1
accepted answer: http://stackoverflow.com/a/2646103
score: 0

http://stackoverflow.com/comment/2640307
has text: JavaScript is client-side. PHP and Java (JSP) are server-side.
type: Comment
comment on: http://stackoverflow.com/q/2627237
score: 1
type: QuestionComment

http://stackoverflow.com/a/2679306
answers question: http://stackoverflow.com/q/2679066
type: Answer
score: 0
has body: &lt;javac&gt; tasks &lt;sourcepath&gt; child corresponds to -sourcepath flag of javac command. This flag specifies directories, JAR files or ZIP files containing source files to compile. The javac command can also be used by specifying a list of files on the command line. To pass such a list to javac command, you should use the &lt;src&gt; child element (or srcdir attribute) of &lt;javac&gt; task. If your source files are in directories on the filesystem, the two do not make any difference in practice.
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2679066

http://stackoverflow.com/q/2653040
has answer: http://stackoverflow.com/a/2653097
upvote count: 1
has comment: http://stackoverflow.com/comment/2669270
has title: How do I implement a remove by index method for a singly linked list in Java?
favorite count: 0
answer count: 5
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/2669248
tagged with: linked-list
has answer: http://stackoverflow.com/a/2653113
downvote count: 0
has body: I'm a student in a programming class, and I need some help with this code I've written. So far I've written an entire linked list class (seen below), yet for some reason the "removeByIndex" method won't work. I can't seem to figure out why, the logic seems sound to me. Is there some problem I don't know about? public class List&lt;T&gt; { //private sub-class Link private class Link { private T value; private Link next; //constructors of Link: public Link (T val) { this.value = val; this.next = null; } public Link (T val, Link next) { this.value = val; this.next = next; } @SuppressWarnings("unused") public T getValue() { return value; } } private static final Exception NoSuchElementException = null; private static final Exception IndexOutOfBoundsException = null; private Link chain = null; //constructors of List: public List() { this.chain = null; } //methods of List: /** * Preconditions: none * Postconditions: returns true if list is empty */ public boolean isEmpty() { return this.chain == null; } /** * Preconditions: none * Postconditions: A new Link is added via add-aux * @param element */ public void add(T element) { this.add_aux(element, this.chain); } /** * Preconditions: none * Postconditions: A new Link is added to the current chain * @param element * @param chain */ private void add_aux(T element, Link chain) { if (chain == null) { //if chain is null set chain to a new Link with a value of //element this.chain = new Link(element); } else if (chain.next != null) { //if chain.next is not null, go to next item in chain and //try //to add element add_aux(element, chain.next); } else { //if chain.next is null, set chain.next equal to a new Link //with value of element. chain.next = new Link(element); } } /** * Preconditions: none * Postconditions: returns the link at the defined index via nthlink_aux * @param index * @return */ private Link nthLink (int index) { return nthLink_aux(index, this.chain); } /** * Preconditions: none * Postconditions: returns the link …
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/2653109
has answer: http://stackoverflow.com/a/2653114
has answer: http://stackoverflow.com/a/2653094
type: Question
has comment: http://stackoverflow.com/comment/2669226

http://stackoverflow.com/comment/2611438
type: Comment
has text: Okay, so LabelMaker interferes with alpha blending, the texture (created from a PNG with a transparent background) now has a solid black background, rather than a transparent background. If I comment out all the LabelMaker-related code, it works fine.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2601459

http://stackoverflow.com/comment/2644523
type: Comment
has text: Yes, I saw that yesterday. In that issue they have disabled the redirect filter, whereas I have it by default on.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2630847

http://stackoverflow.com/a/2707310
has body: If you just need to print it out, this is a shorter version: System.out.printf("%08d\n", number);
upvote count: 2
type: Answer
answers question: http://stackoverflow.com/q/2705096
score: 2
downvote count: 0

http://stackoverflow.com/comment/2691903
comment on: http://stackoverflow.com/q/2668141
has text: Yes that's it. But now on, working with Strings is completely messy and I try to improve it.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/2713224
has body: I think it's very likely the borders are part of the buttons' GUI. You could try calling .setBorder(null) on all the buttons and see what happens!
score: 3
answers question: http://stackoverflow.com/q/2713190
downvote count: 0
has comment: http://stackoverflow.com/comment/7915458
type: Answer
upvote count: 3

http://stackoverflow.com/q/2768903
has title: What is a reasonable OSGi development workflow?
type: Question
has answer: http://stackoverflow.com/a/2769058
accepted answer: http://stackoverflow.com/a/2769058
tagged with: compilation
tagged with: osgi
has body: I'm using OSGi for my latest project at work, and it's pretty beautiful as far as modularity and functionality. But I'm not happy with the development workflow. Eventually, I plan to have 30-50 separate bundles, arranged in a dependency graph - supposedly, this is what OSGi is designed for. But I can't figure out a clean way to manage dependencies at compile time. Example: You have bundles A and B. B depends on packages defined in A. Each bundle is developed as a separate Java project. In order to compile B, A has to be on the javac classpath. Do you: Reference the file system location of project A in B's build script? Build A and throw the jar into B's lib directory? Rely on Eclipse's "referenced projects" feature and always use Eclipse's classpath to build (ugh) Use a common "lib" directory for all projects and dump the bundle jars there after compilation? Set up a bundle repository, parse the manifest from the build script and pull down the required bundles from the repository? No. 5 sounds the cleanest, but also like a lot of overhead.
upvote count: 7
has answer: http://stackoverflow.com/a/2769229
answer count: 4
favorite count: 0
has answer: http://stackoverflow.com/a/2770860
possible better answer: http://stackoverflow.com/a/2769122
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2769122
downvote count: 0
tagged with: ant
score: 7
tagged with: java

http://stackoverflow.com/a/2689947
has comment: http://stackoverflow.com/comment/2711787
has comment: http://stackoverflow.com/comment/2711632
downvote count: 1
has comment: http://stackoverflow.com/comment/90041762
type: AcceptedAnswer
has body: You cannot require classes to implement particular static methods through an interface. It just makes no sense in Java terms. Interfaces force the presence of particular non-static methods in the classes that implement the interface; that's what they do. The easiest way is definitely to have some sort of factory class that produces instances of the others. Yes, this does mean that you have to remember to keep that factory up to date when you add new instances, but since the first thing you do when you make a new implementation is test it (you do test it, yes?) you'll pick up on that problem very quickly!
has comment: http://stackoverflow.com/comment/2711042
has comment: http://stackoverflow.com/comment/139830262
score: 22
accepted answer of: http://stackoverflow.com/q/2689312
has comment: http://stackoverflow.com/comment/134579834
type: Answer
has comment: http://stackoverflow.com/comment/2711902
answers question: http://stackoverflow.com/q/2689312
upvote count: 23

http://stackoverflow.com/comment/39949895
type: Comment
comment on: http://stackoverflow.com/a/2749740
score: 1
has text: Oh what are all the engineers doing, We should cringe whenever we had to do **manual** manipulation *for* the computer in this time and age.
type: AnswerComment

http://stackoverflow.com/q/2764054
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2764134
tagged with: java
tagged with: hibernate
tagged with: orm
upvote count: 10
has body: We have just finish to profile our application. ( she's begin to be slow ). the problem seems to be "in hibernate". It's a legacy mapping. Who work's, and do it's job. The relational shema behind is ok too. But some request are slow as hell. So, we would appreciate any input on common and usual mistake made with hibernate who end up with slow response. Exemple : Eager in place of Lazy can change dramaticly the response time.... Edit : As usual, read the manual is often a good idea. A whole chapter cover this subject here : http://docs.jboss.org/hibernate/core/3.3/reference/en/html/performance.html
type: Question
tagged with: performance
has answer: http://stackoverflow.com/a/2764474
has title: Usual hibernate performance pitfall
score: 10
possible better answer: http://stackoverflow.com/a/5061988
has answer: http://stackoverflow.com/a/5061988
downvote count: 0
answer count: 7
has answer: http://stackoverflow.com/a/18830546
favorite count: 0
accepted answer: http://stackoverflow.com/a/2764474
has answer: http://stackoverflow.com/a/25377604
has answer: http://stackoverflow.com/a/31844400
has answer: http://stackoverflow.com/a/2766765

http://stackoverflow.com/comment/77630666
has text: best answer for me
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/44074706

http://stackoverflow.com/q/2716433
downvote count: 0
tagged with: orm
type: Question
has answer: http://stackoverflow.com/a/2716485
has title: How do I specify the foreign key on a many-to-one relationship when is not a property on the object itself?
score: 1
tagged with: java
tagged with: hibernate
accepted answer: http://stackoverflow.com/a/2717773
answer count: 3
upvote count: 1
possible better answer: http://stackoverflow.com/a/2716505
has answer: http://stackoverflow.com/a/2717773
has answer: http://stackoverflow.com/a/2716505
favorite count: 0
has body: I'm trying to map a many-to-one relationship from MarketMenuBranch to Market. My classes look like: public class Market implements Serializable { private int id; private String name; private List&lt;MarketMenuBranch&gt; marketMenuBranches; // accessors / mutators etc... public class MarketMenuBranch implements Serializable { private MarketMenuBranchId id; private String name; // accessors / mutators etc... public class MarketMenuBranchId implements Serializable { private int marketId; private int sequence; // accessors / mutators etc... But I don't know what I can put for the property name (where I have ???? below). I really want to put id.marketId but that seems to be wrong. &lt;class name="MarketMenuBranch" table="MARKET_MENU_BRANCH"&gt; &lt;composite-id name="id" class="MarketMenuBranchId"&gt; &lt;key-property name="marketId"/&gt; &lt;key-property name="sequence"/&gt; &lt;/composite-id&gt; &lt;property name="name"/&gt; &lt;many-to-one name="????????"/&gt; &lt;/class&gt; How can I do this? EDIT: here is the Market mapping: &lt;class name="Market" table="MARKET"&gt; &lt;id name="id"/&gt; &lt;property name="name"/&gt; &lt;list name="marketMenuBranches" inverse="true" cascade="all-delete-orphan"&gt; &lt;key column="marketId"/&gt; &lt;list-index column="sequence"/&gt; &lt;one-to-many class="MarketMenuBranch"/&gt; &lt;/list&gt; &lt;/class&gt; and here are my tables: mysql&gt; describe MARKET; +-------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+--------------+------+-----+---------+-------+ | id | int(11) | NO | PRI | NULL | | | name | varchar(100) | YES | | NULL | | +-------+--------------+------+-----+---------+-------+ mysql&gt; describe MARKET_MENU_BRANCH; +----------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+--------------+------+-----+---------+-------+ | marketId | int(11) | NO | PRI | 0 | | | sequence | int(11) | NO | PRI | 0 | | | name |…
type: AnsweredQuestion

http://stackoverflow.com/a/2610510
has body: (See http://www.devdaily.com/java/java-exec-processbuilder-process-2 for the article from which this snippet was taken, you'll need the other classes in there to make it work.) Give this a shot- List&lt;String&gt; commands = new ArrayList&lt;String&gt;(); commands.add("/bin/sh"); commands.add("-c"); commands.add("gs -version"); try { ProcessBuilder pb = new ProcessBuilder(commands); Process process = pb.start(); inputStreamHandler = new ThreadedStreamHandler( process.getInputStream() ); errorStreamHandler = new ThreadedStreamHandler( process.getErrorStream()); inputStreamHandler.start(); errorStreamHandler.start(); process.waitFor(); inputStreamHandler.interrupt(); errorStreamHandler.interrupt(); inputStreamHandler.join(); errorStreamHandler.join(); } catch (IOException e) { Log.err(e); } catch (InterruptedException e) { Log.err(e); } StringBuilder stdout = inputStreamHandler.getOutputBuffer();
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/2610469
score: 3
upvote count: 3

http://stackoverflow.com/a/2602964
has body: How about this: string2.equalsIgnoreCase(string1.substring(0, string2.length())
upvote count: 3
answers question: http://stackoverflow.com/q/2602934
has comment: http://stackoverflow.com/comment/26127751
type: Answer
has comment: http://stackoverflow.com/comment/26095847
downvote count: 0
score: 3

http://stackoverflow.com/a/2678829
downvote count: 2
upvote count: 0
score: -2
has body: I would go with System.out.println(getA()); and setA(b + c); for the simple reason that if you wanted to generally change the way an attribute is accessed or enforce any constraints as to what you could set a variable to, you can just change the getA or setA methods. I don't like using this unless I need to explicitly distinguish between variables of the same name.
type: Answer
answers question: http://stackoverflow.com/q/2678745

http://stackoverflow.com/q/2716646
accepted answer: http://stackoverflow.com/a/2718861
has body: Greeting, I'm trying to put some Beanshell script in my Ant build.xml file. I've followed the Ant manual as well as I can but I keep getting "Unable to create javax script engine for beanshell" when I run Ant. Here is the test target I wrote mostly from examples in the Ant manual: &lt;target name="test-target"&gt; &lt;script language="beanshell" setbeans="true"&gt; &lt;classpath&gt; &lt;fileset dir="c:\TEMP" includes="*.jar" /&gt; &lt;/classpath&gt; System.out.println("Hello world"); &lt;/script&gt; &lt;/target&gt; My beanshell "bsh-2.0b4.jar" file is on the script task's classpath the way the manual recommended. Hope I have the right file. I'm working in c:\TEMP right now. I've been googling and trying for a while now. Any ideas would be greatly appreciated. Thanks.
favorite count: 0
has title: Beanshell in Ant yielding, "Unable to create javax script engine for beanshell"
has answer: http://stackoverflow.com/a/12653680
has answer: http://stackoverflow.com/a/2718861
answer count: 4
type: AnsweredQuestion
tagged with: beanshell
has answer: http://stackoverflow.com/a/3092114
possible better answer: http://stackoverflow.com/a/12653680
tagged with: java
upvote count: 10
type: Question
has answer: http://stackoverflow.com/a/12664347
tagged with: ant
downvote count: 0
score: 10

http://stackoverflow.com/a/9553776
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2746334
type: Answer
answers question: http://stackoverflow.com/q/2746334
score: 2
has comment: http://stackoverflow.com/comment/12109415
downvote count: 0
has body: I'm also running Arch Linux and noticed my games going slow sometimes, especially when using alpha transparencies with my images. It turns out that even Windows, not only Linux sometimes turns off hardware acceleration by default. I looked for a solution to the problem and found this: http://web.archive.org/web/20120926022918/http://www.systemparadox.co.uk/node/29 Enabling OpenGL considerably sped up my framerates, and I assume if you ran your tests again, you'd get faster draws.
upvote count: 2

http://stackoverflow.com/comment/14027022
has text: Why don't you just use ` `? Your apprach is unnecessarily overcomplicated.
type: Comment
score: 1
comment on: http://stackoverflow.com/a/10782196
type: AnswerComment

http://stackoverflow.com/comment/2768429
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2739743
type: Comment
has text: Yes, you can write "return i==null;" But that is not what you submitted us for our consideration.

http://stackoverflow.com/a/13230535
has body: Old thread, but I stumbled upon it so here's an updated answer. The answer is in your stacktrace. while it may relate to the use of Domino this is a general issue that would occur for a pretty simple applet used on a normal JVM invoked from the standard Java browser plugins, and apparently your Java Agent is using an applet sandbox. Applets are not allowed (except by modifying directly the Java Security Policy on the client machine) to perform some critical calls. Even if using signed applets. In your case, System.exit(-1) is triggering the exception. The reason for this is that applets have a fairly complex lifecycle, and you are not supposed to mess around with it. It's for your own good, as you want the browser to be able to interact with the applet for you and to be able to tear-down (or re-use) the JVM process launched to run the applet. By invocating System.exit() or others, you'd mess up with this lifecycle and with your browser's chances of controlling the applet's destruction. You may want to re-consider why you need this entirely, as you probably don't need to invoke a System.exit() call there.
answers question: http://stackoverflow.com/q/2635881
downvote count: 0
type: Answer
score: 2
upvote count: 2

http://stackoverflow.com/q/2711186
type: Question
has comment: http://stackoverflow.com/comment/2735927
tagged with: naming-conventions
possible better answer: http://stackoverflow.com/a/2711206
has comment: http://stackoverflow.com/comment/2735982
has answer: http://stackoverflow.com/a/2711204
downvote count: 0
has title: How is this statement making sense? (Sun's naming convention for Java variables)
favorite count: 0
score: 8
has answer: http://stackoverflow.com/a/2711252
upvote count: 8
has answer: http://stackoverflow.com/a/2711206
answer count: 4
type: AnsweredQuestion
tagged with: java
has body: I've been quoting this segment from Sun's document for the past few days, and only now do I stop and think about what it's saying, and I can't make any sense of it. Please keep in mind that English is not my first language. Naming conventions Variables: Except for variables, all instance, class, and class constants are in mixed case with a lowercase first letter. How is this making sense? Isn't this saying that class names are in mixed case with a lower-case first letter? Like I should name it class myClass? And class constants are also in mixed case with a lower-case first letter? Like instead of Integer.MAX_VALUE, it should've been named integer.maxValue? And is it really saying anything about how variables themselves should be named? Am I not parsing this properly or is this actually a blatant error?
has comment: http://stackoverflow.com/comment/2735930
has answer: http://stackoverflow.com/a/2711273
accepted answer: http://stackoverflow.com/a/2711273
has comment: http://stackoverflow.com/comment/2735939

http://stackoverflow.com/a/2776773
type: AcceptedAnswer
downvote count: 1
accepted answer of: http://stackoverflow.com/q/2775550
answers question: http://stackoverflow.com/q/2775550
has body: Take a look at: https://timingframework.dev.java.net/ and the samples that come in http://filthyrichclients.org/ They provide some very good information on how animation work and using the Timer framework. You'll have a good understanding of how it works. I did a sample animation here with Swing after reading those: count down demo app http://img580.imageshack.us/img580/742/capturadepantalla201004wd.png Java application featuring blog.stackoverflow.com page ( click on image to see the demo video ) But I'm not even sure what is what you want to achieve. EDIT I read about the timing framework to understand better what is all about, but I actually didn't use it ( it is useful to create animations with no linear times - ie no every second as mine, but things like 1, 5, 3, 2 seconds ) The code I'm using in the demo above is exactly this: final Timer imageTimer = new Timer(); imageTimer.schedule( new TimerTask() { public void run() { changeImage(); } }, 0, 10000 ); //&lt;-- every 10 seconds. The animation for the "stackoverflowing" and the count down use a similar approach.
type: Answer
score: 1
has comment: http://stackoverflow.com/comment/2813380
has comment: http://stackoverflow.com/comment/2811224
upvote count: 2

http://stackoverflow.com/q/2618281
tagged with: tools.jar
tagged with: deployment
favorite count: 0
has comment: http://stackoverflow.com/comment/2630253
has title: Ant error when trying to build file, can't find tools.jar?
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/23221206
has answer: http://stackoverflow.com/a/10502290
has answer: http://stackoverflow.com/a/2618359
upvote count: 42
has comment: http://stackoverflow.com/comment/2630403
downvote count: 0
linked to: http://stackoverflow.com/q/3382583
tagged with: java
has answer: http://stackoverflow.com/a/25182212
type: Question
has comment: http://stackoverflow.com/comment/2630372
has answer: http://stackoverflow.com/a/2618327
answer count: 8
has answer: http://stackoverflow.com/a/20780375
tagged with: ant
has answer: http://stackoverflow.com/a/23935218
has comment: http://stackoverflow.com/comment/2630390
score: 42
has answer: http://stackoverflow.com/a/26585157
has body: When I run ant it says: Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar Buildfile: build.xml does not exist! Build failed What package can I use to download the file required > C:\Program Files\Java\jre6\lib\tools.jar I just downloaded this one: jre-6u19-windows-i586-s.exe but unfortunately it appears that it was not on it...

http://stackoverflow.com/q/2624177
has answer: http://stackoverflow.com/a/31481395
tagged with: spring
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2624449
has answer: http://stackoverflow.com/a/2624449
tagged with: java
has title: Spring FactoryBean - iterating over an "object creation" list
type: Question
answer count: 2
score: 0
accepted answer: http://stackoverflow.com/a/31481395
has body: Santa's got a list. He wants to make a "present" for every child on hist list (we're assuming for the moment they're all good) and load them all in his sled. Can he do it with Spring? I've written a simple FileListFactory that implements FactoryBean and returns a list of strings that represents the lines in a given file. Set that aside for now - if we solve the problem for a &lt;list>, then I assume I can plug in a ref to this factory's output in its place. What I want is a list of "foo" objects. The foo objects are non-singleton instances of some bean (likely with an abstract bean definition). Each foo object created gets one of the list items as a property. To up the ante one level further, the property in question is of a "bar" object. I have already created a property editor to make "bar" objects from strings. So the thing that iterates over the list of strings should use the property editor infrastructure when setting the per-instance property. It seems like there ought to be some sort of list factory iterator bean or something for this. The problem appears to be that all of the searches I'm doing to look for example solutions to this fail because terms like "list" are far too generic.

http://stackoverflow.com/q/2672700
has body: I have two relations A and B, both with all integer attributes (A {a1,a2,a3,...} B{b1,b2,b3,..}. How would I hash-join these two in java? The user will pick the two joining attributes. Do I make two hashtables and then proceed to join them?
type: AnsweredQuestion
score: 3
has comment: http://stackoverflow.com/comment/2691617
upvote count: 3
tagged with: java
has answer: http://stackoverflow.com/a/34740398
type: Question
has title: Hash join in java
possible better answer: http://stackoverflow.com/a/34740398
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/2672902
favorite count: 0
accepted answer: http://stackoverflow.com/a/2672902

http://stackoverflow.com/a/2620784
upvote count: 2
has comment: http://stackoverflow.com/comment/2633227
answers question: http://stackoverflow.com/q/2620758
type: Answer
has body: Have tyou tried looking in the logs ? From Google App Engine doc, it seems that System.out is redirected to logs.
score: 2
downvote count: 0

http://stackoverflow.com/a/2664456
has body: To run with a 64-bit JDK, you need to use tomcat.exe and tomcatw.exe that are compiled 64-bit. To run with a 32-bit JDK, you need the .exes that are compiled 32-bit. It is likely that the install package you got for Tomcat contained 64-bit executables. Go to the download page (http://tomcat.apache.org/download-60.cgi), download the 32-bit version and you should be fine. This question has more info on running Tomcat with 64-bit. How to run Tomcat 6 on WinXP 64 bit?
score: 3
downvote count: 0
answers question: http://stackoverflow.com/q/2664424
has comment: http://stackoverflow.com/comment/2682451
type: Answer
upvote count: 3
has comment: http://stackoverflow.com/comment/2682778

http://stackoverflow.com/a/2610684
accepted answer of: http://stackoverflow.com/q/2610679
answers question: http://stackoverflow.com/q/2610679
type: AcceptedAnswer
upvote count: 34
type: Answer
has comment: http://stackoverflow.com/comment/2621212
score: 34
downvote count: 0
has body: You have a semicolon after the condition. When you use braces to specify a block for your while you don't use a semicolon.

http://stackoverflow.com/q/2631662
tagged with: apache-camel
type: Question
upvote count: 4
answer count: 2
has answer: http://stackoverflow.com/a/2632406
accepted answer: http://stackoverflow.com/a/2632406
downvote count: 0
possible better answer: http://stackoverflow.com/a/2637485
score: 4
has title: Using Apache Camel how do I unmarshal my deserialized object that comes in through a CXF Endpoint?
favorite count: 0
has body: I have a very simple camel route. It starts with a CXF Endpoint exposed as a web service. I then want to convert it to xml and call a method on a bean. Currently i'm getting a CXF specific object after the web service call. How do I take my serialized object out of the CXF MessageList and use it going forward? My Route: <camel:route> <camel:from uri="cxf:bean:helloEndpoint" /> <camel:marshal ref="xstream-utf8" /> <camel:to uri="bean:hello?method=hello"/> </camel:route> The XML Serialized Message: <?xml version='1.0' encoding='UTF-8'?> <org.apache.cxf.message.MessageContentsList serialization="custom"> <unserializable-parents /> 1 6 <com.whatever.Person> Joe Buddah 2010-04-13 12:09:00.137 CDT </com.whatever.Person> </org.apache.cxf.message.MessageContentsList> I would expect the XML to be more like this: <com.whatever.Person> Joe Buddah 2010-04-13 12:09:00.137 CDT </com.whatever.Person>
has answer: http://stackoverflow.com/a/2637485
tagged with: spring
type: AnsweredQuestion
tagged with: cxf
tagged with: java

http://stackoverflow.com/comment/2818378
score: 0
comment on: http://stackoverflow.com/q/2783204
type: QuestionComment
type: Comment
has text: If you were to show your existing code (or a high-level summary thereof), someone might be able to tell you how to write it in a way that is not recursive, if that's what you are after.

http://stackoverflow.com/comment/2724797
type: Comment
has text: @Oscar Reyes: The link in my answer contains the `revised version of this newsletter that works for Java 5 upwards` :)
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/2701850

http://stackoverflow.com/comment/2751375
comment on: http://stackoverflow.com/q/2723073
type: Comment
type: QuestionComment
has text: thats because i havent made much progress with regards to understanding the solution contributed.
score: 0

http://stackoverflow.com/q/2747630
downvote count: 0
accepted answer: http://stackoverflow.com/a/2750161
tagged with: android
has title: Project setup for creating third party libraries for Android
favorite count: 0
upvote count: 3
possible better answer: http://stackoverflow.com/a/2819643
has answer: http://stackoverflow.com/a/2819643
type: AnsweredQuestion
score: 3
has answer: http://stackoverflow.com/a/2750161
tagged with: java
type: Question
answer count: 2
has body: I am creating a library for Android that others can include in their own project. So far I have been working on it as a normal Java project with JDK 1.6 setup as system library. This works just fine in Eclipse when I add the android.jar. The issue comes when I try to my build script. I am running Gradle and doing a normal compile and test build cycle. My thoughts were that it does not matter if I compile it with a normal JDK, since this is not a standalone application. The benefits by creating a normal Java project is that Gradle does support this much better. My project also does not contain any UI at all. However, the problem is that of course android.jar and the JDK contains lots of the same classes and I think that this is what messes up my build script. Everything crashes when running the tests (the tests are in the same project under src/test/java). My question is, how should I create this project that is meant to be included in Android projects as a third party library? Should I create it as an Android project in Eclipse even though I am only creating a library that does not use any of the UI features? Also, should the tests be in a separate project? Thanks for all responses!

http://stackoverflow.com/a/2921952
has comment: http://stackoverflow.com/comment/105086498
answers question: http://stackoverflow.com/q/2633790
has comment: http://stackoverflow.com/comment/105094716
score: 3
accepted answer of: http://stackoverflow.com/q/2633790
has body: Connection Refused. This sounds like a firewall/program not running issue. try a telnet &lt;machine&gt; 2809. You should get a "Connected to " and not a refusal, if everything is running/enabled correctly. I'm running on a UNIX client so the paths use UNIX style. jacORB installed properly ? e.g. get the nameservice entry from the orb.properties file (in ${JAVA_HOME}/jre/lib/ I use "ORBInitRef.NameService=corbaloc::localhost:2809/NameServer" as "NameServer" is used on the production name server and not the other string of "Standard...." The other changes in the properties files are setting the paths to UNIX style (i.e. e:\NS_Ref -> /tmp/NS_Ref) jacorb.naming.ior_filename=/tmp/NS_Ref 1a. Setting the http:// in the properties file didn't seem to do anything in regards to resolving on the client side. 1b. NOTE: start ns with: ns -DOAPort=2809 Log will show: 2010-05-27 10:00:47.777 FINE Created socket listener on 0.0.0.0/0.0.0.0:2809 2010-05-27 10:00:47.777 FINE Using port 2809 Running: $ lsof | grep 2809 java 27529 jbsymolo 15u IPv6 693300 TCP *:2809 (LISTEN) $ lsof -Pnl +M -i6 COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME Naming_Se 9678 1000 7u IPv6 45779 TCP *:51148 (LISTEN) java 27959 1000 15u IPv6 696092 TCP *:2809 (LISTEN) Not Running: (shows nothing) ns when started will log where it reads the properties from and it shouldn't throw any errors. If it does your properties files have issues. VM arguments. The -D is used to set system properties. Any Java code can then access any property so defined via System.getProperty(). Even though I've also seen the "non-D" used, I've been using the D. -DORBInitRef.NameService=corbaloc::localhost:2809/NameService -Dorg.omg.CORBA.ORBClass=org.jacorb.orb.ORB -Dorg.omg.CORBA.ORBSingletonClass=org.jacorb.orb.ORBSingleton When running the client in Eclipse, I see the following in the Console: May 27, 2010 10:01:06 AM org.jacorb.config.JacORBConfiguration init INFO: base configuration loaded from file /usr/lib/java/jdk1.6.0_18/jre/li…
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/105094704
type: Answer
upvote count: 3
has comment: http://stackoverflow.com/comment/105094689

http://stackoverflow.com/a/2713745
answers question: http://stackoverflow.com/q/2713584
type: Answer
accepted answer of: http://stackoverflow.com/q/2713584
upvote count: 5
downvote count: 0
score: 5
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2738919
has body: That's because you probably have Book 1..n Chapter, with cascade set to (at least) PERSIST. Which means that whenever a book is saved, all of its chapters are saved as well. So you are actually trying to save the chapters twice. You don't need the 2nd save (in the 2nd example) The first example works that way because the chapter has become associated with the session (perhaps you haven't overridden the hashCode() and equals() methods), and the save() doesn't do anything at all. But these are all guesses. You'd have to show your mappings.

pipeline
type: Tag
tags question: http://stackoverflow.com/q/2645975
tag name: pipeline

http://stackoverflow.com/comment/2649783
comment on: http://stackoverflow.com/a/2618511
type: Comment
has text: @Isawpalmetto And this is indeed the case with Derby - see http://db.apache.org/derby/docs/10.0/manuals/develop/develop75.html
score: 0
type: AnswerComment

http://stackoverflow.com/comment/2793168
type: QuestionComment
has text: Which Terracotta product are you talking about?
comment on: http://stackoverflow.com/q/2761177
score: 0
type: Comment

http://stackoverflow.com/comment/2788350
type: Comment
has text: @Yatandra: as I wrote: since the behaviour is not clearly stated in the API doc, I would not depend on it. Put the code that should be executed upon interruption into a separate method and call it from both places.
comment on: http://stackoverflow.com/a/2756715
score: 1
type: AnswerComment

http://stackoverflow.com/q/2630529
type: Question
has answer: http://stackoverflow.com/a/71225576
tagged with: c++
has answer: http://stackoverflow.com/a/2630830
upvote count: 14
tagged with: java
answer count: 3
tagged with: java-native-interface
accepted answer: http://stackoverflow.com/a/2630830
score: 14
possible better answer: http://stackoverflow.com/a/2639550
type: AnsweredQuestion
has title: JNI how to access Java Object (Integer)
downvote count: 0
has answer: http://stackoverflow.com/a/2639550
favorite count: 0
has body: I have a JNI method to access java method which returns an Integer object. I do not want to return the primitive int type because this code will be modified to handle Generic objects. The following is what I have. I am not able to get the value of the Integer that I pass. The output at C++ side is something like value = 0x4016f3d0 How can I get the actual value of Integer object that I pass at C++ end? Please help. Thanks, -H GenericPeer.cpp JNIEXPORT void JNICALL Java_GenericPeer_print (JNIEnv *jenv, jclass jcls, jobject data){ jclass peerCls = jenv-&gt;GetObjectClass(data); jmethodID mGetValue = jenv-&gt;GetMethodID(peerCls, "getValue","()Ljava/lang/Integer;"); if(mGetValue == NULL){ return (-1); } jobject value = jenv-&gt;CallObjectMethod(data, mGetValue); cout&lt;&lt;"value = "&lt;&lt;value&lt;&lt;endl; } GenericPeer.java public class GenericPeer { public static native void print(Data d); static { System.load("/home/usr/workspace/GenericJni/src/libGenericJni.so"); } } Data.java public class Data { private Integer value; pubilc Data(Integer v){ this.value = v; } public Integer getValue() { return value; } public void setValue(Integer value) { this.value = value; } } Test.java (Main class) public class Test { public static void main(String[] args){ Integer i = new Integer(1); Data d = new Data(i); GenericPeer.print(d); } }

http://stackoverflow.com/a/2784095
has body: Here is a hack-ish way I have seen the method name retrieved: String methodName = new Exception() .getStackTrace()[0] .getMethodName(); Someone with stronger Java-fu might be able to give a cleaner approach and also provide a way to retrieve the body of the method.
type: Answer
downvote count: 1
score: -1
upvote count: 0
answers question: http://stackoverflow.com/q/2784066
has comment: http://stackoverflow.com/comment/2819373

http://stackoverflow.com/a/2710900
has comment: http://stackoverflow.com/comment/2735752
downvote count: 0
has comment: http://stackoverflow.com/comment/55851174
type: Answer
upvote count: 7
has body: You have to specify the type: HOME_LOAN_TYPES type = HOME_LOAN_TYPES.FIFTEEN_YEAR; By the way, don't use this naming convention for enums. Use the same camel case you do for classes so: public enum HomeLoanType { FIFTEEN YEAR, THIRTY_YEAR } If you don't want to specify the type you can do a static import: import static package.name.HomeLoanType.*; ... HomeLoanType type = FIFTEEN_YEAR; Lastly, one of the best things about Java enums is they can have state and behaviour. For example: public enum HomeLoanType { FIFTEEN YEAR(15), THIRTY_YEAR(30); private final int years; HomeLoanType(int years) { this.year = years; } public int getYears() { returns years; } }
answers question: http://stackoverflow.com/q/2710897
score: 7

http://stackoverflow.com/comment/2741743
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2702315
has text: Some instances are highly automated (see point 3 in the edits above) and others are basically variations on your example of replacing System.out. I guess I'm a little surprised that no one has made a library or DSL for working with the AST/tokenized code in a high-level way.
score: 0

http://stackoverflow.com/comment/2620845
has text: Does the .net runtime ship with OS X? I have it on my machine but I think I installed it a while back.
comment on: http://stackoverflow.com/a/2610349
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/2743593
has body: Use of private constructor to prevent instantiation of class? There are several ways you can think of users preventing from the Instantiations for the purpose of creating the Constants As you have mentioned a class with the private Constructors and has all the string constants, is one way, even there is an overhead, that can be negligible Else you can create a Class with Final Modifier and Define your string constants You can use the Abstract Class with the String Constants You can define the string constants in the properties files and can access from that, this will definitely reduce the memory and increase the flexibility of your code.
type: Answer
upvote count: 14
accepted answer of: http://stackoverflow.com/q/2743434
answers question: http://stackoverflow.com/q/2743434
downvote count: 0
score: 14
type: AcceptedAnswer

http://stackoverflow.com/q/2694782
favorite count: 0
possible better answer: http://stackoverflow.com/a/19093715
type: Question
type: AnsweredQuestion
score: 3
accepted answer: http://stackoverflow.com/a/2694829
has answer: http://stackoverflow.com/a/19093715
has title: Remove a JFrame from taskbar in Java
tagged with: java
has answer: http://stackoverflow.com/a/2694829
answer count: 2
tagged with: taskbar
downvote count: 0
upvote count: 3
has body: I did a quick topic look, but did not find something similar. My query is: how can I prevent a child window appearing on the Windows taskbar when it is shown?

http://stackoverflow.com/a/2707830
has comment: http://stackoverflow.com/comment/2731816
accepted answer of: http://stackoverflow.com/q/2707745
answers question: http://stackoverflow.com/q/2707745
has body: I have only found that you can do that with separate launches in Eclipse (so you need to launch first your server, and then your client). Unfortunately each Console is then a pane in the Console view, and not its own Console so you have to manually switch, but that is the best I've found so far.
score: 0
type: AcceptedAnswer
type: Answer

http://stackoverflow.com/comment/2637302
type: Comment
has text: do you want to iterate over path[i].prop where i is in [1..n]?
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/2624545

http://stackoverflow.com/q/2702513
downvote count: 0
answer count: 1
favorite count: 0
tagged with: jprogressbar
type: AnsweredQuestion
score: 3
has title: Java Swingworker: Not as encapsulated class
upvote count: 3
tagged with: java
has answer: http://stackoverflow.com/a/2702675
type: Question
tagged with: swingworker
tagged with: jtextarea
has body: I'm having problems passing information, updating progress and indicating "done" with a SwingWorker class that is not an encapsulated class. I have a simple class that processes files and directories on a hard drive. The user clicks on the Start button and that launches an instance of the SwingWorker. I would like to print the names of the files that are processed on the JTextArea in the Event Driven Thread from the SwingWorker as update a progress bar. All the examples on the web are for an nested class, and the nested class accesses variables in the outer class (such as the done method). I would also like to signal the Event Driven Thread that the SwingWorker is finished so the EDT can perform actions such as enabling the Start button (and clearing fields). Here are my questions: 1. How does the SwingWorker class put text into the JTextArea of the Event Driven Thread and update a progress bar? How does the EDT determine when the {external} SwingWorker thread is finished? {I don't want the SwingWorker as a nested class because there is a lot of code (and processing) done.}
accepted answer: http://stackoverflow.com/a/2702675

http://stackoverflow.com/comment/2715467
comment on: http://stackoverflow.com/a/2687585
score: 0
type: AnswerComment
has text: @Ravi, ok... then I don't see anything particularly wrong with your implementation. Is there a specific reason that you *need* to create multiple new threads to receive packets? I would pull that out into a separate thread altogether, but I don't know what's your motivation for doing it that way.
type: Comment

http://stackoverflow.com/comment/15648214
type: AnswerComment
comment on: http://stackoverflow.com/a/2663855
has text: @ThorbjørnRavnAndersen, Why not? This is democracy right? I can down-vote I think answer is not correct - even the question was not about how to organize the file upload, but about technical details. :-) I have no dependencies. I think it's not natural to store files in database that's why filesystem exists. Especially I would avoid using frameworks where it's more elegant to store the uploaded file on disk.
type: Comment
score: 1

http://stackoverflow.com/q/2714385
type: Question
downvote count: 0
possible better answer: http://stackoverflow.com/a/2714410
favorite count: 0
has answer: http://stackoverflow.com/a/2714410
has answer: http://stackoverflow.com/a/2714491
tagged with: file-io
has body: I have a text file. I would like to retrieve the content from one line to another line. For example, the file may be 200K lines. I want to read the content from line 78 to line 2735. Since the file may be very large, I do not want to read the whole content into the memory.
answer count: 4
tagged with: text-files
has title: Read text file in Java
upvote count: 3
accepted answer: http://stackoverflow.com/a/2714491
type: AnsweredQuestion
score: 3
has answer: http://stackoverflow.com/a/2714666
tagged with: java
has answer: http://stackoverflow.com/a/2714408

http://stackoverflow.com/comment/2613412
score: 0
has text: pls don't tell me that the only solution is to create a root 'foo' object and pass it to the cctor before persisting to the datastore for all cards and products...
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/2603745

http://stackoverflow.com/comment/75549856
comment on: http://stackoverflow.com/a/12571330
type: AnswerComment
score: 0
has text: I used this with Will's answer for a straight forward and easy to maintain option.
type: Comment

http://stackoverflow.com/q/2646739
type: Question
score: 3
tagged with: performance
has title: what can cause large discrepancy between minor GC time and total pause time?
answer count: 3
has answer: http://stackoverflow.com/a/15353012
has answer: http://stackoverflow.com/a/2647450
downvote count: 0
has body: We have a latency-sensitive application, and are experiencing some GC-related pauses we don't fully understand. We occasionally have a minor GC that results in application pause times that are much longer than the reported GC time itself. Here is an example log snippet: 485377.257: [GC 485378.857: [ParNew: 105845K->621K(118016K), 0.0028070 secs] 136492K->31374K(1035520K), 0.0028720 secs] [Times: user=0.01 sys=0.00, real=1.61 secs] Total time for which application threads were stopped: 1.6032830 seconds The total pause time here is orders of magnitude longer than the reported GC time. These are isolated and occasional events: the immediately preceding and succeeding minor GC events do not show this large discrepancy. The process is running on a dedicated machine, with lots of free memory, 8 cores, running Red Hat Enterprise Linux ES Release 4 Update 8 with kernel 2.6.9-89.0.1EL-smp. We have observed this with (32 bit) JVM versions 1.6.0_13 and 1.6.0_18. We are running with these flags: -server -ea -Xms512m -Xmx512m -XX:+UseConcMarkSweepGC -XX:NewSize=128m -XX:MaxNewSize=128m -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCApplicationStoppedTime -XX:-TraceClassUnloading Can anybody offer some explanation as to what might be going on here, and/or some avenues for further investigation?
tagged with: jvm
favorite count: 0
has answer: http://stackoverflow.com/a/2651558
type: UnansweredQuestion
tagged with: garbage-collection
upvote count: 3
tagged with: java

http://stackoverflow.com/comment/2783220
has text: See my edit :) I _just_ suggested making it an extension method.
score: 0
comment on: http://stackoverflow.com/a/2752536
type: AnswerComment
type: Comment

http://stackoverflow.com/a/2780348
score: 0
type: Answer
has body: (...) SYSDATE is inserted only once and not updated for subsequent updates. First of all, let me make something clear: Generated means that the field is generated by the database and that Hibernate needs to read it after insert/update to update the entity. Using default SYSDATE in the column definition works fine for an INSERT but for an UPDATE, you'll need a trigger. Also, lastUpdDTTM is not part of sql generated by hibernate. Well, you told Hibernate that the field is ALWAYS generated by the database so I'm not surpised that Hibernate doesn't include it in the generated SQL (actually, I believe that this somehow conflicts with udpatable = true, I would expect Hibernate to complain about it). Anyway, as I said, it's not Hibernate that will update this field, it's the database and you need a trigger, Hibernate will just refresh the entity after an update to get the new value. A different approach would be to use callback annotations, for example for the last update date: @PreUpdate protected void updateDates() { lastUpdDTTM = new Date(); } For better consistency, you could even use the same approach for the creation date with @PrePersit: @PrePersist @PreUpdate protected void updateDates() { Date now = new Date(); if (createdDTTM == null) { createdDTTM = new Date(now.getTime()); } lastUpdDTTM = now; }
has comment: http://stackoverflow.com/comment/2815197
has comment: http://stackoverflow.com/comment/2815353
answers question: http://stackoverflow.com/q/2780230
has comment: http://stackoverflow.com/comment/2815674
has comment: http://stackoverflow.com/comment/2815438

http://stackoverflow.com/q/2633514
upvote count: 3
tagged with: java
tagged with: hibernate
tagged with: orm
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/2633658
downvote count: 0
has answer: http://stackoverflow.com/a/2633695
favorite count: 0
type: UnansweredQuestion
score: 3
has title: Java-Hibernate-Newbie: How do I acces the values from this list?
has body: I have this class mapped @Entity @Table(name = "USERS") public class User { private long id; private String userName; } and I make a query: Query query = session.createQuery("select id, userName, count(userName) from User order by count(userName) desc"); return query.list(); How can I access the values returned by the query? I mean, how should I treat the query.list()? As a User or what?

android
tags question: http://stackoverflow.com/q/2741063
tags question: http://stackoverflow.com/q/2734318
tags question: http://stackoverflow.com/q/2670011
tags question: http://stackoverflow.com/q/2739186
tags question: http://stackoverflow.com/q/2686823
tags question: http://stackoverflow.com/q/2636629
tags question: http://stackoverflow.com/q/2767407
tags question: http://stackoverflow.com/q/2605555
tags question: http://stackoverflow.com/q/2698002
tags question: http://stackoverflow.com/q/2670719
tags question: http://stackoverflow.com/q/2735323
tags question: http://stackoverflow.com/q/2747630
tags question: http://stackoverflow.com/q/2676044
tags question: http://stackoverflow.com/q/2599536
tags question: http://stackoverflow.com/q/2754847
tags question: http://stackoverflow.com/q/2727568
tags question: http://stackoverflow.com/q/2617962
tags question: http://stackoverflow.com/q/2709602
tags question: http://stackoverflow.com/q/2744285
tags question: http://stackoverflow.com/q/2775859
tags question: http://stackoverflow.com/q/2651907
tags question: http://stackoverflow.com/q/2777042
tags question: http://stackoverflow.com/q/2741755
tags question: http://stackoverflow.com/q/2612576
tags question: http://stackoverflow.com/q/2685254
tags question: http://stackoverflow.com/q/2636906
tags question: http://stackoverflow.com/q/2643949
tags question: http://stackoverflow.com/q/2767442
tags question: http://stackoverflow.com/q/2749236
tags question: http://stackoverflow.com/q/2739086
tags question: http://stackoverflow.com/q/2743167
tags question: http://stackoverflow.com/q/2718565
tags question: http://stackoverflow.com/q/2758255
tags question: http://stackoverflow.com/q/2707309
tags question: http://stackoverflow.com/q/2733255
tags question: http://stackoverflow.com/q/2598390
tags question: http://stackoverflow.com/q/2739329
tags question: http://stackoverflow.com/q/2640919
tags question: http://stackoverflow.com/q/2702218
tags question: http://stackoverflow.com/q/2704956
tags question: http://stackoverflow.com/q/2631483
tags question: http://stackoverflow.com/q/2622599
tags question: http://stackoverflow.com/q/2700038
tags question: http://stackoverflow.com/q/2676719
tags question: http://stackoverflow.com/q/2608452
tags question: http://stackoverflow.com/q/2765636
tags question: http://stackoverflow.com/q/2774446
tags question: http://stackoverflow.com/q/2610384
tags question: http://stackoverflow.com/q/2687773
tags question: http://stackoverflow.com/q/2722949
tags question: http://stackoverflow.com/q/2724871
tags question: http://stackoverflow.com/q/2756122
tags question: http://stackoverflow.com/q/2743872
tags question: http://stackoverflow.com/q/2693752
tags question: http://stackoverflow.com/q/2715694
tags question: http://stackoverflow.com/q/2743741
tags question: http://stackoverflow.com/q/2755358
tags question: http://stackoverflow.com/q/2780119
tags question: http://stackoverflow.com/q/2614719
tags question: http://stackoverflow.com/q/2709488
tags question: http://stackoverflow.com/q/2778098
tags question: http://stackoverflow.com/q/2631686
tags question: http://stackoverflow.com/q/2737456
tags question: http://stackoverflow.com/q/2694731
tags question: http://stackoverflow.com/q/2612291
tags question: http://stackoverflow.com/q/2785614
tags question: http://stackoverflow.com/q/2686126
tags question: http://stackoverflow.com/q/2601368
tags question: http://stackoverflow.com/q/2597889
tags question: http://stackoverflow.com/q/2629691
tags question: http://stackoverflow.com/q/2634422
tags question: http://stackoverflow.com/q/2622694
tags question: http://stackoverflow.com/q/2623392
tags question: http://stackoverflow.com/q/2618573
tags question: http://stackoverflow.com/q/2607613
tags question: http://stackoverflow.com/q/2654258
tags question: http://stackoverflow.com/q/2781604
tags question: http://stackoverflow.com/q/2709253
tags question: http://stackoverflow.com/q/2762914
tags question: http://stackoverflow.com/q/2603176

http://stackoverflow.com/a/69083516
answers question: http://stackoverflow.com/q/2627889
has comment: http://stackoverflow.com/comment/125338754
score: 0
type: Answer
has body: The two instances of int[] are different and not equal. A nice approach would be to convert the int array to String using Arrays.toString(arr): HashMap<String, String> h = new HashMap<>(); int[] a = new int[]{1, 2}; h.put(Arrays.toString(a), "sun"); h.get(Arrays.toString(new int[]{1, 2})); // returns sun

http://stackoverflow.com/q/2701651
type: Question
possible better answer: http://stackoverflow.com/a/2702263
has answer: http://stackoverflow.com/a/2702263
has title: jfreechart time series chart with events
upvote count: 2
has answer: http://stackoverflow.com/a/2702314
tagged with: java
answer count: 2
has body: I am using jfreechart (specially ChartFactory.createTimeSeriesChart()). Is there a way to signal events like Google Finance charts, see the A, B, C etc on the right and in the chart.
tagged with: swing
tagged with: jfreechart
tagged with: graph
tagged with: charts
accepted answer: http://stackoverflow.com/a/2702314
score: 2
type: AnsweredQuestion
downvote count: 0
favorite count: 0

http://stackoverflow.com/comment/2752100
type: Comment
has text: Never heard of it, but it sounds this would do the trick. I would test it with various JRE/JDK installations on different windows operating system to monitor its performance.
score: 1
comment on: http://stackoverflow.com/a/2708030
type: AnswerComment

http://stackoverflow.com/comment/46986585
has text: Thank you @Adam Ch Your answer is worth much more than a thanks !! your solution is priceless
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/8782009

parsing
tags question: http://stackoverflow.com/q/2735238
tags question: http://stackoverflow.com/q/2763091
tags question: http://stackoverflow.com/q/2703511
tags question: http://stackoverflow.com/q/2749778
tags question: http://stackoverflow.com/q/2731893
tag name: parsing
tags question: http://stackoverflow.com/q/2671031
tags question: http://stackoverflow.com/q/2735458
tags question: http://stackoverflow.com/q/2716178
tags question: http://stackoverflow.com/q/2739840
tags question: http://stackoverflow.com/q/2736830
tags question: http://stackoverflow.com/q/2736185
tags question: http://stackoverflow.com/q/2767442
tags question: http://stackoverflow.com/q/2706909
tags question: http://stackoverflow.com/q/2637961
tags question: http://stackoverflow.com/q/2731742
tags question: http://stackoverflow.com/q/2702315
tags question: http://stackoverflow.com/q/2753523
tags question: http://stackoverflow.com/q/2752141
type: Tag
tags question: http://stackoverflow.com/q/2746816
tags question: http://stackoverflow.com/q/2609998
tags question: http://stackoverflow.com/q/2688100
tags question: http://stackoverflow.com/q/2661126
tags question: http://stackoverflow.com/q/2650259
tags question: http://stackoverflow.com/q/2609948
tags question: http://stackoverflow.com/q/2738455
tags question: http://stackoverflow.com/q/2691815
tags question: http://stackoverflow.com/q/2752607
tags question: http://stackoverflow.com/q/2603638
tags question: http://stackoverflow.com/q/2713216
tags question: http://stackoverflow.com/q/2669269
tags question: http://stackoverflow.com/q/2734659
tags question: http://stackoverflow.com/q/2716063
tags question: http://stackoverflow.com/q/2735657
tags question: http://stackoverflow.com/q/2773733
tags question: http://stackoverflow.com/q/2603149
tags question: http://stackoverflow.com/q/2733621

http://stackoverflow.com/a/2632777
has comment: http://stackoverflow.com/comment/2646566
has body: Use a regex to check if it matches camelCase. Related answers: What Perl regex can match CamelCase words?
answers question: http://stackoverflow.com/q/2632757
downvote count: 0
type: Answer
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/2646651
has comment: http://stackoverflow.com/comment/2646414
has comment: http://stackoverflow.com/comment/2646360
has comment: http://stackoverflow.com/comment/2646596

http://stackoverflow.com/comment/2768452
type: Comment
has text: I like that idea, I may end up using it actually. Thankyou :)
type: AnswerComment
comment on: http://stackoverflow.com/a/2734331
score: 0

class
tags question: http://stackoverflow.com/q/2652295
tags question: http://stackoverflow.com/q/2603064
tags question: http://stackoverflow.com/q/2731303
tags question: http://stackoverflow.com/q/2604675
tags question: http://stackoverflow.com/q/2786416
tags question: http://stackoverflow.com/q/2632249
tags question: http://stackoverflow.com/q/2752717
tags question: http://stackoverflow.com/q/2784696
tags question: http://stackoverflow.com/q/2747014
tags question: http://stackoverflow.com/q/2690118
type: Tag
tag name: class
tags question: http://stackoverflow.com/q/2624462
tags question: http://stackoverflow.com/q/2752224
tags question: http://stackoverflow.com/q/2685404
tags question: http://stackoverflow.com/q/2608037
tags question: http://stackoverflow.com/q/2664990
tags question: http://stackoverflow.com/q/2761172
tags question: http://stackoverflow.com/q/2769710

http://stackoverflow.com/comment/137215320
type: AnswerComment
comment on: http://stackoverflow.com/a/2761026
has text: Important: This initializes a fixed size `List`, but not a variable size `ArrayList`!
score: 0
type: Comment

http://stackoverflow.com/comment/2820927
comment on: http://stackoverflow.com/a/2785483
type: AnswerComment
score: 0
type: Comment
has text: ok I know the syntax from using them in php, but how to apply them in java ?

http://stackoverflow.com/a/2716008
answers question: http://stackoverflow.com/q/2715983
has comment: http://stackoverflow.com/comment/2741513
score: 0
has comment: http://stackoverflow.com/comment/2741523
has body: http://java.sun.com/j2se/1.4.2/docs/api/java/util/ArrayList.html Note that this implementation is not synchronized. If multiple threads access an ArrayList instance concurrently, and at least one of the threads modifies the list structurally, it must be synchronized externally. Since there is no synchronization internally, what you theorize is not plausible. So, things get out of sync, with unpleasant and unpredictable results.
type: Answer

http://stackoverflow.com/comment/2764993
type: QuestionComment
comment on: http://stackoverflow.com/q/2736698
has text: @halfwarp: ... why not just use a database??? Why would you store this list of lists in Java?
score: 0
type: Comment

http://stackoverflow.com/a/2610697
has body: Use Element instead of DocumentFragment: NodeList folderNodes = document.getElementsByTagName("Folder"); Element node = (Element)folderNodes.item(0); NodeList subNodes = node.getElementsByTagName("OtherNodes"); // and so on... The Element interface supports getElementsByTagName, whereas DocumentFragment is minimal and really doesn't do much.
answers question: http://stackoverflow.com/q/2610674
accepted answer of: http://stackoverflow.com/q/2610674
type: AcceptedAnswer
downvote count: 0
score: 3
type: Answer
upvote count: 3

http://stackoverflow.com/comment/2697374
has text: ...but don't bother. There are very few valid reasons to use `String.getBytes()`, and when you do use it you should always specify an encoding rather than rely on the default. The same goes for the `new String(byte[])` constructors.
score: 3
type: AnswerComment
comment on: http://stackoverflow.com/a/2677505
type: Comment

http://stackoverflow.com/comment/24628359
type: Comment
comment on: http://stackoverflow.com/a/2618187
type: AnswerComment
score: 0
has text: It's not about "time traveling" -- it's about debugging what happened on someone else's machine when they submit a bug -- your QA can attach an .ITrace file to the bug they submit, and you can step through the code and see exactly what happened.

http://stackoverflow.com/q/2695767
has answer: http://stackoverflow.com/a/2695832
accepted answer: http://stackoverflow.com/a/2695832
tagged with: swing
has answer: http://stackoverflow.com/a/62315630
type: AnsweredQuestion
has body: I have a JList nested inside of a JScrollPane. When I add items to the JList, I want the JScrollPane to automatically scroll to the bottom of the JList so the last item is visible. To do this, I have the following code: getWordListScroller().getVerticalScrollBar().getModel().setValue(getWordListScroller().getVerticalScrollBar().getModel().getMaximum()); When I try using this code, however, the JScrollPane only scrolls to the second to last item, leaving the last item out of view. This is not in any way desirable. I've tried adding values to getMaximum(), but the issue persists. How can I get the JScrollPane to scroll to the very bottom?
tagged with: java
type: Question
score: 5
has answer: http://stackoverflow.com/a/3042545
answer count: 3
has title: Unable to programatically scroll to last item in JList
downvote count: 0
favorite count: 0
upvote count: 5
possible better answer: http://stackoverflow.com/a/3042545

http://stackoverflow.com/comment/91471109
comment on: http://stackoverflow.com/a/29895662
score: 0
type: AnswerComment
type: Comment
has text: Sorry I should have been more specific. I meant is there a way to server side render an Angular app within Java without a nodejs server?

http://stackoverflow.com/a/2672302
has comment: http://stackoverflow.com/comment/2691316
score: 3
downvote count: 0
has comment: http://stackoverflow.com/comment/2691101
upvote count: 3
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2672291
answers question: http://stackoverflow.com/q/2672291
has body: You've created the array, but you still need to go through and create the ArrayList objects. As it's written, adjList[i] returns null because nothing has been assigned to it yet.
type: Answer

http://stackoverflow.com/a/2709176
has body: If you want to compare strings, use equals(): if ("hello".equals(test))...
answers question: http://stackoverflow.com/q/2709161
upvote count: 5
has comment: http://stackoverflow.com/comment/2733402
downvote count: 0
has comment: http://stackoverflow.com/comment/2733790
type: Answer
score: 5

http://stackoverflow.com/a/2741898
upvote count: 61
answers question: http://stackoverflow.com/q/2738886
type: Answer
score: 61
has body: Here's a quote from Effective Java 2nd Edition, Item 9: "Always override hashCode when you override equals": While the recipe in this item yields reasonably good hash functions, it does not yield state-of-the-art hash functions, nor do Java platform libraries provide such hash functions as of release 1.6. Writing such hash functions is a research topic, best left to mathematicians and computer scientists. [... Nonetheless,] the techniques described in this item should be adequate for most applications. Josh Bloch's recipe Store some constant nonzero value, say 17, in an int variable called result Compute an int hashcode c for each field f that defines equals: If the field is a boolean, compute (f ? 1 : 0) If the field is a byte, char, short, int, compute (int) f If the field is a long, compute (int) (f ^ (f &gt;&gt;&gt; 32)) If the field is a float, compute Float.floatToIntBits(f) If the field is a double, compute Double.doubleToLongBits(f), then hash the resulting long as in above If the field is an object reference and this class's equals method compares the field by recursively invoking equals, recursively invoke hashCode on the field. If the value of the field is null, return 0 If the field is an array, treat it as if each element is a separate field. If every element in an array field is significant, you can use one of the Arrays.hashCode methods added in release 1.5 Combine the hashcode c into result as follows: result = 31 * result + c; Now, of course that recipe is rather complicated, but luckily, you don't have to reimplement it every time, thanks to java.util.Arrays.hashCode(Object[]). @Override public int hashCode() { return Arrays.hashCode(new Object[] { myInt, //auto-boxed myDouble, //auto-boxed myString, }); } As of Java 7 there is a convenient varargs variant in java.util.Objects.hash(Object...).
downvote count: 0

http://stackoverflow.com/q/2606766
answer count: 5
type: AnsweredQuestion
score: 2
has comment: http://stackoverflow.com/comment/2617261
has body: I want to store a data structure thats a table with one column Strings and another column of Ints. List&lt;Entry&lt;String, Integer&gt;&gt; li = new LinkedList&lt;Entry&lt;String, Integer&gt;&gt;(); would do the job for a list but I would rather have the performance of and need the memory of an array. I tried Entry&lt;String, Integer&gt;[] = new Entry&lt;String, Integer&gt;[10]; but that doesn't seem to work. Is Entry the right datatype to use?
has comment: http://stackoverflow.com/comment/2617066
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/2606815
has comment: http://stackoverflow.com/comment/2616797
has comment: http://stackoverflow.com/comment/2616806
possible better answer: http://stackoverflow.com/a/2606782
has answer: http://stackoverflow.com/a/2606782
downvote count: 0
has title: Multidimensional Array with different types in java
has answer: http://stackoverflow.com/a/2607018
has comment: http://stackoverflow.com/comment/2617123
favorite count: 0
has answer: http://stackoverflow.com/a/2607006
has answer: http://stackoverflow.com/a/2607005
has comment: http://stackoverflow.com/comment/2617029
has answer: http://stackoverflow.com/a/2606815
upvote count: 2

http://stackoverflow.com/comment/2641101
type: AnswerComment
comment on: http://stackoverflow.com/a/2628060
score: 0
type: Comment
has text: I developed the project in eclipse with BlackBerry_JDE_PluginFull. I can run the cod+jad file on my phone,but failed to run the jar file

http://stackoverflow.com/comment/2643099
comment on: http://stackoverflow.com/q/2630009
has text: shouldn't that go to serverfault.com?
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/comment/2652594
comment on: http://stackoverflow.com/a/2638266
has text: +1. Thank you for this very interesting feedback. Could you detail the solution B (in order to not depend on an internet link which might broke one day)?
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/2632362
has answer: http://stackoverflow.com/a/3304472
type: AnsweredQuestion
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/2632460
has title: Where did this class come from?
type: Question
possible better answer: http://stackoverflow.com/a/2632859
has answer: http://stackoverflow.com/a/2632859
has answer: http://stackoverflow.com/a/2632395
accepted answer: http://stackoverflow.com/a/2632395
answer count: 6
score: 4
has answer: http://stackoverflow.com/a/2632909
has answer: http://stackoverflow.com/a/2632400
has body: How would you go about establishing where a class ( or maybe resource ) has been loaded from? I am trying to work out exactly where a class has been loaded from. Does anyone know if you can find out the following: Which Jar file did the class come from ? What classloader loaded the file?
tagged with: jvm
favorite count: 0
tagged with: classloader
upvote count: 4

http://stackoverflow.com/comment/2812946
type: AnswerComment
has text: playAnimation() is called by a JButton though, it depends on a certain condition. The logic is roughly the following. The user enters a word in a text field and presses the button if the guess is wrong the animation plays. This wrong guessing decrements the users lives, he tries again and if again wrong the animation plays again but this time after it finishesh a pop-up box emerges asking if the user wants a new game. With the join() method in the code this works but the animation renders only the first and the last picture. With the join() method out it renders perfect but the pop up box
score: 0
comment on: http://stackoverflow.com/a/2778297
type: Comment

http://stackoverflow.com/q/2638200
tagged with: tokenize
tagged with: java
has body: I'm trying to use Apache Lucene for tokenizing, and I am baffled at the process to obtain Tokens from a TokenStream. The worst part is that I'm looking at the comments in the JavaDocs that address my question. http://lucene.apache.org/java/3_0_1/api/core/org/apache/lucene/analysis/TokenStream.html#incrementToken%28%29 Somehow, an AttributeSource is supposed to be used, rather than Tokens. I'm totally at a loss. Can anyone explain how to get token-like information from a TokenStream?
has answer: http://stackoverflow.com/a/23156847
answer count: 4
possible better answer: http://stackoverflow.com/a/12554138
has answer: http://stackoverflow.com/a/12554138
has answer: http://stackoverflow.com/a/2638252
tagged with: lucene
upvote count: 78
tagged with: token
type: AnsweredQuestion
has title: How to get a Token from a Lucene TokenStream?
has answer: http://stackoverflow.com/a/50785820
downvote count: 0
favorite count: 0
tagged with: attributes
type: Question
accepted answer: http://stackoverflow.com/a/2638252
score: 78

http://stackoverflow.com/a/2725874
accepted answer of: http://stackoverflow.com/q/2725812
type: Answer
score: 1
upvote count: 1
has body: P.S. One solution I was thinking about is not to use and use some servlet to stream image. But I don't know how to implement that correctly and how to tie jsf component with servlet and how to save already built chart images (generating new same image for each request can cause performance problems imho) and so on.. Just give it an URL as attribute so that it ends up as &lt;img src="url"&gt; and let that URL point to the servlet. Let the servlet generate/return the image based on the information provided by request parameters or pathinfo in the URL. As to the caching, just store it somewhere in the disk file system or a DB by some unique identifier and let the servlet on every request check if it is there and handle accordingly. For this all the standard &lt;h:graphicImage&gt; would be already sufficient. Just make the URL dynamic.
has comment: http://stackoverflow.com/comment/2761365
answers question: http://stackoverflow.com/q/2725812
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/2618469
type: Answer
has body: If you need to store a Byte array you have two choices: com.google.appengine.api.datastore.ShortBlob : short byte string, &lt; 500 bytes com.google.appengine.api.datastore.Blob: long byte string (not orderable)
upvote count: 7
accepted answer of: http://stackoverflow.com/q/2615939
score: 7
answers question: http://stackoverflow.com/q/2615939
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/2624665
has title: Embeddable database better than SQLite for java
tagged with: database
answer count: 6
possible better answer: http://stackoverflow.com/a/2624826
has answer: http://stackoverflow.com/a/2625598
has answer: http://stackoverflow.com/a/2624826
tagged with: sqlite
has answer: http://stackoverflow.com/a/2624698
favorite count: 0
has answer: http://stackoverflow.com/a/2624690
score: -1
has answer: http://stackoverflow.com/a/2625499
upvote count: 2
has answer: http://stackoverflow.com/a/2624816
tagged with: web-applications
accepted answer: http://stackoverflow.com/a/2625598
type: AnsweredQuestion
tagged with: java
has body: I am creating a web application that is accessing a SQLite database in the server. I also have "clients" that updates this same database. As we know SQLite locks the entire database during INSERTs which are done by the clients and the web application is also trying to make some UPDATEs at the same time. So my problem now is about concurrency in database access. I would like to use an embeddable database like SQLite. Any suggestions.
downvote count: 3
tagged with: concurrency
type: Question

http://stackoverflow.com/comment/2818293
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2782872
has text: actually, I gave a simplified example. I have subclassed a GUI component, and the call to select() occurs inside it. How do I know when the frame is laid out?
score: 0

http://stackoverflow.com/q/2615712
has comment: http://stackoverflow.com/comment/2627278
has answer: http://stackoverflow.com/a/45245849
has answer: http://stackoverflow.com/a/41390284
upvote count: 38
has answer: http://stackoverflow.com/a/22305276
has answer: http://stackoverflow.com/a/44261614
has answer: http://stackoverflow.com/a/45809177
has answer: http://stackoverflow.com/a/32540549
has body: I'm having difficulty to understand the logic behind the method to find the second highest number in array. The method used is to find the highest in the array but less than the previous highest (which has already been found). The thing that I still can't figure it out is why || highest_score == second_highest is necessary. For example I input three numbers: 98, 56, 3. Without it, both highest and second highest would be 98. Please explain. int second highest = score[0]; if (score[i] &gt; second_highest &amp;&amp; score[i] &lt; highest_score || highest_score == second_highest) second_highest = score[i];
has answer: http://stackoverflow.com/a/35199468
has answer: http://stackoverflow.com/a/17752371
has answer: http://stackoverflow.com/a/14880748
has answer: http://stackoverflow.com/a/38222768
has answer: http://stackoverflow.com/a/24529081
has answer: http://stackoverflow.com/a/49706203
has answer: http://stackoverflow.com/a/50892942
type: UnansweredQuestion
answer count: 45
has answer: http://stackoverflow.com/a/72635790
tagged with: java
has comment: http://stackoverflow.com/comment/2627808
has answer: http://stackoverflow.com/a/31746689
has answer: http://stackoverflow.com/a/20704105
has answer: http://stackoverflow.com/a/34600988
has answer: http://stackoverflow.com/a/45125298
type: Question
has answer: http://stackoverflow.com/a/30320044
has answer: http://stackoverflow.com/a/74023207
has answer: http://stackoverflow.com/a/33028075
has answer: http://stackoverflow.com/a/71458983
has answer: http://stackoverflow.com/a/56580843
linked to: http://stackoverflow.com/q/1811846
has answer: http://stackoverflow.com/a/35752968
has answer: http://stackoverflow.com/a/27841629
has answer: http://stackoverflow.com/a/44589817
tagged with: algorithm
has answer: http://stackoverflow.com/a/2615723
has answer: http://stackoverflow.com/a/38942442
has comment: http://stackoverflow.com/comment/2627281
has answer: http://stackoverflow.com/a/31051667
has answer: http://stackoverflow.com/a/33785327
has answer: http://stackoverflow.com/a/36113595
has answer: http://stackoverflow.com/a/14866902
has answer: http://stackoverflow.com/a/63780993
has answer: http://stackoverflow.com/a/2615743
has answer: http://stackoverflow.com/a/32458210
has answer: http://stackoverflow.com/a/68432098
has answer: http://stackoverflow.com/a/12573103
has answer: http://stackoverflow.com/a/74384923
has answer: http://stackoverflow.com/a/33524775
has answer: http://stackoverflow.com/a/28293002
tagged with: arrays
has answer: http://stackoverflow.com/a/35354148
downvote count: 0
has answer: http://stackoverflow.com/a/22824359
linked to: http://stackoverflow.com/q/11644858
has answer: http://stackoverflow.com/a/47573143
linked to: http://stackoverflow.com/q/1412751
has answer: http://stackoverflow.com/a/20989553
favorite count: 0
has answer: http://stackoverflow.com/a/2615761
has title: Finding the second highest number in array in Java
score: 38

http://stackoverflow.com/q/2713869
tagged with: java
possible better answer: http://stackoverflow.com/a/2713920
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/2713920
has comment: http://stackoverflow.com/comment/2738846
has comment: http://stackoverflow.com/comment/2739620
has comment: http://stackoverflow.com/comment/2738853
has answer: http://stackoverflow.com/a/2713897
has answer: http://stackoverflow.com/a/2713882
upvote count: 4
has comment: http://stackoverflow.com/comment/2738914
has comment: http://stackoverflow.com/comment/2738852
answer count: 7
has comment: http://stackoverflow.com/comment/2739890
has comment: http://stackoverflow.com/comment/2740805
favorite count: 0
has comment: http://stackoverflow.com/comment/2739077
has title: How does this Java code work?
has answer: http://stackoverflow.com/a/2713892
has comment: http://stackoverflow.com/comment/2738835
has comment: http://stackoverflow.com/comment/2739774
accepted answer: http://stackoverflow.com/a/2713882
has answer: http://stackoverflow.com/a/2713904
has answer: http://stackoverflow.com/a/2713917
has body: public static void main(String[] args) { int [][]shatner = new int[1][1]; int []rat = new int[4]; shatner[0] = rat; System.out.println(shatner[0][3]); } surprised, The output is 0, why Java doesn't check this kind of indexOutOfBound error?
has answer: http://stackoverflow.com/a/2713889
type: AnsweredQuestion
score: 3

http://stackoverflow.com/q/2750208
has comment: http://stackoverflow.com/comment/2781774
has comment: http://stackoverflow.com/comment/2781373
has body: I have an entity with Integer attributes that looks like this in proto code: class MyEntity: String name @Choices({1, "BSD", 2, "Apache", 3, "GPL"} Integer frequency @ChoicesSegment({1000, 2000, 3000}, {"BSD", "Apache", "GPL"}) Integer type String getFrequency() return getChoice("frequency", frequency) String getType() return getChoice("type", type) maybe this solution is more feasible: class MyEntity: String name final static private Something? frequencyChoices = {1000, 2000, 3000}, {"BSD", "Apache", "GPL"} Integer frequency final static private String[] typeChoices = new String[] {"BSD", "Apache", "GPL"} Integer type @Choices(MyEntity.frequencyChoices) String getFrequency() return frequency) @IntervalChoices(MyEntity.typeChoices) String getType() return type *get** accessors return strings according to this table. value(type) HumanReadableString(type) 1 BSD 2 Apache 3 GPL min frequency max frequency HumanReadableString(frequency) 0 1000 rare 1000 2000 frequent 2001 3000 sexy It should be possible to get all possible values that an attribute can take, example: getChoices(MyEntity, "type") returns ("rare", "frequent", "sexy") It should be possible to get the bound value from the string: getValue(MyEntity, "frequency", "sexy") returns (2000,3000) edit: purpose of all of this This methods should simplify the generation of forms and requests (of course this should not be view implementation bound) edit: added how I would like to tell Java that some attributes are spécial so that it can generate get* accessors acordingly. edit: added how to submit in the code the choices edit: the only thing that I store in the db is integers, when I want to print them they should be converted somehow to their human readable string.
type: AnsweredQuestion
tagged with: data-modeling
tagged with: java
tagged with: hibernate
tagged with: orm
has answer: http://stackoverflow.com/a/2864207
has answer: http://stackoverflow.com/a/14354870
type: Question
has answer: http://stackoverflow.com/a/2768139
possible better answer: http://stackoverflow.com/a/2864207
has comment: http://stackoverflow.com/comment/2781138
has title: How to handle choice field with JPA 2, Hibernate 3.5
score: 0
answer count: 3
accepted answer: http://stackoverflow.com/a/2768139
tagged with: jpa-2.0

http://stackoverflow.com/comment/2796089
type: Comment
comment on: http://stackoverflow.com/a/2763452
has text: So I guess, I will have to add a new controller which will forward requests to another one, as you suggested. Thanks! :)
type: AnswerComment
score: 0

http://stackoverflow.com/a/2772403
downvote count: 0
has comment: http://stackoverflow.com/comment/2806004
type: Answer
has comment: http://stackoverflow.com/comment/2805982
upvote count: 5
has body: To Martin Smith comment I'll add: Remember, Karnaugh can help you to simplify the condition of that if.
answers question: http://stackoverflow.com/q/2772303
score: 5

http://stackoverflow.com/a/45286358
has body: I am wondering when to use static methods? A common use for static methods is to access static fields. But you can have static methods, without referencing static variables. Helper methods without referring static variable can be found in some java classes like java.lang.Math public static int min(int a, int b) { return (a &lt;= b) ? a : b; } The other use case, I can think of these methods combined with synchronized method is implementation of class level locking in multi threaded environment. Say if I have a class with a few getters and setters, a method or two, and I want those methods only to be invokable on an instance object of the class. Does this mean I should use a static method? If you need to access method on an instance object of the class, your method should should be non static. Oracle documentation page provides more details. Not all combinations of instance and class variables and methods are allowed: Instance methods can access instance variables and instance methods directly. Instance methods can access class variables and class methods directly. Class methods can access class variables and class methods directly. Class methods cannot access instance variables or instance methods directly—they must use an object reference. Also, class methods cannot use the this keyword as there is no instance for this to refer to.
upvote count: 2
downvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/100434990
answers question: http://stackoverflow.com/q/2671496
type: Answer

http://stackoverflow.com/a/2928976
answers question: http://stackoverflow.com/q/2726410
upvote count: 1
type: AcceptedAnswer
type: Answer
has body: For the time being, I wrap all methods in my services. I automatically find the query they're looking for and inject the parameters (either named or indexed). This isn't as clean as I'd like it, but there is room for improvement. I write an interface as well as a implementation with no code in the body except return(null); Walter
downvote count: 0
score: 1
accepted answer of: http://stackoverflow.com/q/2726410

http://stackoverflow.com/q/2698868
type: AnsweredQuestion
has body: I am encrypting on JAVA using RSA and attempting to decrypt using .NET. I am including my JAVA code and .NET code in hopes that someone has some experience with this sort of thing. JAVA Code: byte[] modulusBytes = Base64.decode("xTSiS4+I/x9awUXcF66Ffw7tracsQfGCn6g6k/hGkLquHYMFTCYk4mOB5NwLwqczwvl8HkQfDShGcvrm47XHKUzA8iadWdA5n4toBECzRxiCWCHm1KEg59LUD3fxTG5ogGiNxDj9wSguCIzFdUxBYq5ot2J4iLgGu0qShml5vwk="); byte[] exponentBytes = Base64.decode("AQAB"); BigInteger modulus = new BigInteger(1, modulusBytes ); BigInteger exponent = new BigInteger(1, exponentBytes); RSAPublicKeySpec rsaPubKey = new RSAPublicKeySpec(modulus, exponent); KeyFactory fact = KeyFactory.getInstance("RSA"); PublicKey pubKey = fact.generatePublic(rsaPubKey); Cipher cipher = Cipher.getInstance("RSA"); cipher.init(Cipher.ENCRYPT_MODE, pubKey); byte[] plainBytes = new String("big kitty dancing").getBytes("UTF-8"); byte[] cipherData = cipher.doFinal( plainBytes ); String encryptedString = Base64.encodeBytes(cipherData); From this JAVA Code I take the results of the encryptedString which happen to be: FoP4+AAIH6hcabXnrvNG5YUk/nBv9n9HU0CAgZjkIWQIDjbOpSwoPVBFERrZ6641x2QaoJw5yv18XAay+0WrCaSw4sveRX+hmPm5qeVUPcjoR4slsVZ/hBFJtAHj9tva4hOugWDZa9s3RVJlxkNfE+u+Kt/YKLOi2EYbH05HjeM= And attempt to decrypt using the following .NET code const int PROVIDER_RSA_FULL = 1; const string CONTAINER_NAME = "Tracker"; CspParameters cspParams; cspParams = new CspParameters(PROVIDER_RSA_FULL); cspParams.KeyContainerName = CONTAINER_NAME; RSACryptoServiceProvider rsa1 = new RSACryptoServiceProvider(cspParams); rsa1.FromXmlString(" xTSiS4+I/x9awUXcF66Ffw7tracsQfGCn6g6k/hGkLquHYMFTCYk4mOB5NwLwqczwvl8HkQfDShGcvrm47XHKUzA8iadWdA5n4toBECzRxiCWCHm1KEg59LUD3fxTG5ogGiNxDj9wSguCIzFdUxBYq5ot2J4iLgGu0qShml5vwk= AQAB [binary] <D>g1WAWI4pEK9TA7CA2Yyy/2FzzNiu0uQCuE2TZYRNiomo96KQXpxwqAzZLw+VDXfJMypwDMAVZe/SqzSJnFEtZxjdxaEo3VLcZ1mnbIL0vS7D6iFeYutF9kF231165qGd3k2tgymNMMpY7oYKjS11Y6JqWDU0WE5hjS2X35iG6mE=</D> "); string data2Decrypt = "FoP4+AAIH6hcabX…
downvote count: 0
has comment: http://stackoverflow.com/comment/78762583
tagged with: java
tagged with: rsa
has comment: http://stackoverflow.com/comment/2721254
type: Question
has answer: http://stackoverflow.com/a/2699032
accepted answer: http://stackoverflow.com/a/2699032
has title: Java RSA Encrypt - Decrypt .NET
tagged with: .net
score: 10
has comment: http://stackoverflow.com/comment/78762729
upvote count: 10
answer count: 1
favorite count: 0
tagged with: encryption-asymmetric
has comment: http://stackoverflow.com/comment/136942224

http://stackoverflow.com/a/2701988
score: 2
upvote count: 2
has body: In a unit test context, you very likely don't want to get your session factory from JNDI (you don't want to start JBoss for unit tests) and my recommendation would be to use a good old HibernateUtil helper class. Below, a very basic example: import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; public class HibernateUtil { private static final SessionFactory sessionFactory = buildSessionFactory(); private static SessionFactory buildSessionFactory() { try { // Create the SessionFactory from hibernate.cfg.xml return new Configuration().configure().buildSessionFactory(); } catch (Throwable ex) { // Make sure you log the exception, as it might be swallowed System.err.println("Initial SessionFactory creation failed." + ex); throw new ExceptionInInitializerError(ex); } } public static SessionFactory getSessionFactory() { return sessionFactory; } } Just in case, the caveat emptor sample application (the native version) has a a more advanced version that can get a global SessionFactory either from a static variable or a JNDI lookup (so you can use the same code in and outside the container). Personally, I've used the one from Cameron McKenzie during a long time. Then, get a Session from the SessionFactory and begin/commit/rollback a transaction for each method in your unit test.
downvote count: 0
answers question: http://stackoverflow.com/q/2701861
type: Answer

http://stackoverflow.com/q/2623392
tagged with: java
type: UnansweredQuestion
has body: I'm currently developing a Field-Service application that stores data in the local sqlite database on an android device. At some point, usually after completing the data collection rounds, the local sqlite db is to be synchronized to a remote sybase db on the server. Any suggestions as to how this could be achieved or engineered as a solution? Or even better, are there alternatives to synchronizing data in such an application?
has title: Synchronizing the sqlite database on Android to a Sybase database on server
tagged with: sybase
type: Question
tagged with: android
tagged with: sqlite
tagged with: http://stackoverflow.com/tag/xml
score: 0
has answer: http://stackoverflow.com/a/2623778
answer count: 1

http://stackoverflow.com/q/2744351
answer count: 5
has answer: http://stackoverflow.com/a/39976420
has answer: http://stackoverflow.com/a/2744355
accepted answer: http://stackoverflow.com/a/2744355
has title: JUnit won't stop at breakpoints in Eclipse (using JDK 1.6.0.20)
type: AnsweredQuestion
downvote count: 0
tagged with: java
possible better answer: http://stackoverflow.com/a/11930047
score: 24
tagged with: eclipse
type: Question
tagged with: debugging
has answer: http://stackoverflow.com/a/54203199
has answer: http://stackoverflow.com/a/13874891
has body: my breakpoints in Eclipse won't stop the execution of a JUnit test. It doesn't matter where I set the breakpoint in the JUnit method, it simply won't stop the code from flowing. Placing it in a class called in the JUnit test won't work either. I am using the JDK in the version of 1.6.0.20, so I guess I'm not affected by the bug in version 1.6.0.14. Do you know any hints concerning this matter?
tagged with: breakpoints
has comment: http://stackoverflow.com/comment/55920541
has answer: http://stackoverflow.com/a/11930047
tagged with: junit
upvote count: 24
favorite count: 0

http://stackoverflow.com/q/2783595
has answer: http://stackoverflow.com/a/2785030
tagged with: dynamic-proxy
has title: Dynamic, reflective SignalHandler in Java
favorite count: 0
upvote count: 1
type: AnsweredQuestion
tagged with: reflection
accepted answer: http://stackoverflow.com/a/2785030
score: 1
tagged with: java
type: Question
tagged with: signals
downvote count: 0
has body: How do I install signal handling logic iff sun.misc.Signal is available? Background First generation of my code, which assumed signal handling availability, looked something like this: class MyApp { public static void main(String[] args) { ... Signal.handle(term_sig, new SignalHandler() { public void handle(Signal sig) { ... } }); ... } } I believe I understand how to reflectively test for and use signal handlers -- Class.forName("sun.misc.Signal"), reflectively call Signal.handle, and so forth. My impulse was simply to instantiate another anonymous inner class with the dynamically obtained SignalHandler class, but I think that's just wishful syntax.
answer count: 1

http://stackoverflow.com/comment/2728623
has text: What your asking is not necessarily unit testing. It is more of coverage tests.
type: Comment
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/2703689

http://stackoverflow.com/comment/2679399
comment on: http://stackoverflow.com/a/2654368
score: 0
type: AnswerComment
type: Comment
has text: Also Bouncy Castle isn't that great either. It still has significant unpatched flaws in it implementation of RSA.

http://stackoverflow.com/a/2712906
type: Answer
upvote count: 3
has comment: http://stackoverflow.com/comment/2739991
score: 3
answers question: http://stackoverflow.com/q/2712880
has body: There's a good-old recipe, originally by Bjarne Stroustroup for C++, ported here to Java: Result tryOpenFile(File f) { while (true) { try { // try to open the file return result; // or break } catch (FileNotFoundException e) { // try to recover, wait, whatever } } }
downvote count: 0

http://stackoverflow.com/q/2690118
tagged with: methods
has answer: http://stackoverflow.com/a/2690829
tagged with: class
answer count: 2
downvote count: 0
tagged with: jar
has body: I'm searching for a way to get a list of method stubs of all classes within a jar file. I'm not sure where to start... May I use Reflection or Javassist or some other tools of which I've not heard yet!? At least it may be possible to unpack the jar, decompile the class files and scan with a line parser for methods, but I think that is the most dirtiest way ;-) Any ideas? Kind Regards
type: Question
type: AnsweredQuestion
has title: Java: Easy way to get method stub out of class files within a JAR file? Reflection?
accepted answer: http://stackoverflow.com/a/2690829
score: 7
favorite count: 0
upvote count: 7
has answer: http://stackoverflow.com/a/2690440
tagged with: reflection
tagged with: java
possible better answer: http://stackoverflow.com/a/2690440

http://stackoverflow.com/comment/11407863
comment on: http://stackoverflow.com/q/2663115
score: 0
type: Comment
type: QuestionComment
has text: possible duplicate of [How to determine if a linked list has a cycle using only two memory locations](http://stackoverflow.com/questions/494830/how-to-determine-if-a-linked-list-has-a-cycle-using-only-two-memory-locations)

http://stackoverflow.com/comment/15995670
comment on: http://stackoverflow.com/a/6926987
type: Comment
score: 3
has text: What's the point of the second replace? After the decode there will no longer be any instances of "%2B" in the string since they will have all been replaced with "+", so there will be nothing for the replace to match.
type: AnswerComment

http://stackoverflow.com/a/2780067
has body: First, let's remind the various states of an entity. From the JPA 1.0 specification (in section 3.2 Entity Instance’s Life Cycle): This section describes the EntityManager operations for managing an entity instance’s lifecycle. An entity instance may be characterized as being new, managed, detached, or removed. A new entity instance has no persistent identity, and is not yet associated with a persistence context. A managed entity instance is an instance with a persistent identity that is currently associated with a persistence context. A detached entity instance is an instance with a persistent identity that is not (or no longer) associated with a persistence context. A removed entity instance is an instance with a persistent identity, associated with a persistence context, that is scheduled for removal from the database. And a graphical illustration: So, by definition, a detached entity has already been persisted, and I actually don't think that this is your real question. Now, if you want to know if an entity is new (i.e. doesn't have any persistent identity), what about this: @Transient public boolean isNew() { return (this.id == null); }
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2815072
has comment: http://stackoverflow.com/comment/2814975
type: Answer
answers question: http://stackoverflow.com/q/2779857
accepted answer of: http://stackoverflow.com/q/2779857
score: 46
upvote count: 46
has comment: http://stackoverflow.com/comment/2815123
has comment: http://stackoverflow.com/comment/18428104
has comment: http://stackoverflow.com/comment/2815022

http://stackoverflow.com/a/2682068
has comment: http://stackoverflow.com/comment/2701731
has comment: http://stackoverflow.com/comment/2728593
type: Answer
score: 1
has body: You might try looking into Quercus. It's a server that runs PHP inside java. You can call java called directly from PHP as if it was native PHP functions. You won't have to worry about streams then.
upvote count: 1
has comment: http://stackoverflow.com/comment/2726790
answers question: http://stackoverflow.com/q/2682038
has comment: http://stackoverflow.com/comment/2712032
downvote count: 0

http://stackoverflow.com/q/2632980
favorite count: 0
tagged with: java-2d
has answer: http://stackoverflow.com/a/2633056
tagged with: http://stackoverflow.com/tag/png
possible better answer: http://stackoverflow.com/a/2633022
tagged with: javax.imageio
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2633022
has body: Is there an easy way to manipulate PNGs in Java? I know I can read into a BufferedImage and write that back out, but I need to add clear pixels around the edge of an image. Is there an easy way to do this?
score: 1
tagged with: java
upvote count: 1
has title: Manipulating PNGs in Java
type: Question
accepted answer: http://stackoverflow.com/a/2633056
answer count: 2
downvote count: 0

http://stackoverflow.com/q/2741954
has body: I have a JSP that takes an Arraylist from the session object and removes the items from it. It seemed to be working fine and then out of nowhere when I navigate to that page, the page is blank. I checked the Tomcat log files and in catalina.out I am receiving a JasperException an it is showing it as being on a line with the following for(int i; i &lt; agentItems.size(); i++) agentItems is the name of the ArrayList I am using. I have been debugging it and can't seem to figure out what the problem might be. I have read that a JasperException is sometiems thrown as a JSP's NullPointerException. Is this true or am I just completely overlooking the problem? I have the web application running on a local machine and a intermediate server for development in which both of them have had no trouble. Why could it be that only on this server it is giving me problems?
possible better answer: http://stackoverflow.com/a/18935431
score: 2
upvote count: 2
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/2741981
type: Question
answer count: 2
downvote count: 0
tagged with: jsp
has title: What are the possible causes of JasperException
tagged with: tomcat
favorite count: 0
has answer: http://stackoverflow.com/a/18935431
linked to: http://stackoverflow.com/q/1831238
accepted answer: http://stackoverflow.com/a/2741981

http://stackoverflow.com/comment/2662915
score: 1
has text: It is not always advisable to implement a functionality exposed through a public method, in the body of that public method itself. A public method may have to call other methods to execute its behaviour. These other methods are thus intended for internal use, and ought to be marked private.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2647339

http://stackoverflow.com/comment/83182262
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/11107799
has text: Were you able to figure out how to parse this? I am having the same difficulties parsing the same type of xml document.
score: 0

http://stackoverflow.com/a/2640735
downvote count: 1
type: Answer
score: 8
upvote count: 9
has comment: http://stackoverflow.com/comment/2655302
answers question: http://stackoverflow.com/q/2640727
has body: Probably because none of the code you posted actually calls printDice(). With the exception of the main() method, none of your methods in your classes are magically invoked - they need to be invoked by some other code.

http://stackoverflow.com/a/2706937
type: Answer
upvote count: 3
answers question: http://stackoverflow.com/q/2706335
score: 3
downvote count: 0
has body: As a general rule, the database wins. That will almost certainly be the case for you. If you want to be sure though, profile it. I have run into cases in other languages where the overhead of transferring a lot of data was offset by the fact that some of the processing could be done outside of the DB much faster than in it. If the boolean condition you are evaluating is extremely complex to express in relational terms, you could see a benefit in evaluating it in Java, but it is extremely unlikely.

http://stackoverflow.com/a/52325174
has comment: http://stackoverflow.com/comment/96707659
has comment: http://stackoverflow.com/comment/96592483
has comment: http://stackoverflow.com/comment/96735311
has comment: http://stackoverflow.com/comment/96743867
has comment: http://stackoverflow.com/comment/96743916
has comment: http://stackoverflow.com/comment/96820410
has comment: http://stackoverflow.com/comment/96532031
has comment: http://stackoverflow.com/comment/96743897
has comment: http://stackoverflow.com/comment/96707519
has comment: http://stackoverflow.com/comment/96687268
has comment: http://stackoverflow.com/comment/96744091
has comment: http://stackoverflow.com/comment/96744313
has comment: http://stackoverflow.com/comment/96532180
has comment: http://stackoverflow.com/comment/102536604
has comment: http://stackoverflow.com/comment/96592086
has comment: http://stackoverflow.com/comment/96801487
has comment: http://stackoverflow.com/comment/96707566
answers question: http://stackoverflow.com/q/2704417
has body: There are two basic reasons that that Java is faster than Go and C++, and can be faster than C in many cases: 1) The JIT compiler. It can inline virtual function calls through multiple levels, even with OO classes, based on the runtime profile. This is not possible in a statically compiled language (although the newer re-compilation based on recorded profile can help). This is very important to most benchmarks that involve repetitive algorithms. 2) The GC. GC based memory allocation is nearly free, as compared to malloc. And the 'free' penalty can be amortized across the entire runtime - often skipped because the program terminates before all garbage needs to be collected. There are hundreds (thousands?) of extremely talented developers making the GC/JVM efficient. Thinking you can "code better than all of them" is a folly. It is a human ego problem at its heart - humans have a hard time accepting that with proper training by talented humans, the computer is going to perform better than the humans that programmed it. Btw, C++ can be as fast as C if you don't use and of the OO features, but then you are pretty close to just programming in C to begin with. Most importantly, the "speed differences" in these tests are usually meaningless. The IO costs are orders of magnitude more than the performance differences, and so proper designs that minimize IO costs always win - even in a interpreted language. Very few systems are CPU bound. As a final note, people refer to the "computer language benchmarks game" as a "scientific measure". The tests are completely flawed, For example, if you view the Java tests for nbody. When I run the tests on the same OS/hardware, I get roughly 7.6 secs for Java, and 4.7 secs for C - which is reasonable - not the 4x slowness the tests reports. It is click-bait, fake news, designed to generate site traffic. As a final, final note... I ran the tests using Go, and it was 7.9 secs. The fact that when you click on Go, it compares it to Java, and w…
has comment: http://stackoverflow.com/comment/96777671
type: Answer
has comment: http://stackoverflow.com/comment/102536460
has comment: http://stackoverflow.com/comment/96733752
score: 2
has comment: http://stackoverflow.com/comment/96592266
has comment: http://stackoverflow.com/comment/96531996
has comment: http://stackoverflow.com/comment/96773895
upvote count: 3
has comment: http://stackoverflow.com/comment/96687366
has comment: http://stackoverflow.com/comment/96801602
has comment: http://stackoverflow.com/comment/96744157
downvote count: 1
has comment: http://stackoverflow.com/comment/96774270

http://stackoverflow.com/q/2738608
tagged with: swing
score: 2
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/2738629
downvote count: 0
tagged with: progress-bar
answer count: 3
has comment: http://stackoverflow.com/comment/2767523
has answer: http://stackoverflow.com/a/2739087
has body: I have got a form in Java (Swing) loading large amount of data from the database. I want to display a progress bar while the program gets actually loaded. How can i do it? The code is as follows: import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.sql.*; import java.applet.*; import java.util.*; import java.awt.Color; public class bookshow extends JFrame implements MouseListener, ActionListener { JPanel p1, p2, p3; JLabel l1, l2, l3, l4; ImageIcon image; JButton b[] = new JButton[84]; JButton btnocc, btnbook, btnsel; ResultSet rs; private JMenuBar menuBar = new JMenuBar(); private JMenuItem exit, home, save; private JMenu fileMenu, gotoMenu; public int cnt = 0, x = 150, y = 90, i, j, put = 0, k = 0, avail = 1, point, x1, y1, count = 0, quan; public static int prev_click = -1, xpos, ypos; public static int prev[] = new int[5]; public static int pos[][] = new int[5][2]; public String movname, movdate, movtime; public bookshow() { avail = 1; try { String sql = "Select * from Pass"; String url = "jdbc:odbc:tbs"; Connection con = DriverManager.getConnection(url); Statement s = con.createStatement(); rs = s.executeQuery(sql); while (rs.next()) { movname = rs.getString("movname"); movdate = rs.getString("movdate"); movtime = rs.getString("movtime"); quan = Integer.parseInt(rs.getString("Quantity")); } } catch (Exception ex) { System.out.println(ex); } try { String sql = "Delete from Pass"; String url = "jdbc:odbc:tbs"; Connection con = DriverManager.getConnection(url); Statement s = con.createStatement(); s.executeUpdate(sql); con.close(); } catch (Exception ex) { System.out.println(ex); } setTitle("Select Ticket"); setDefaultCloseOperation(EXIT_ON_CLOSE); p1 = new JPanel(); getContentPane().add(p1); p1.setLayout(null); p1.setBackground(Color.white); setJMenuBar(menuBar); fileMenu = new JMenu("File"); menuBar.add(fileMenu); exit = new JMenuItem("Exit"); exit.addActionListener(this); fileMenu.add(exit); exit.setAccelerator(KeyStroke.getKeyStroke('E…
favorite count: 0
has title: Progress bar in Java
upvote count: 2
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2738617

http://stackoverflow.com/q/2602473
has answer: http://stackoverflow.com/a/2606111
tagged with: http://stackoverflow.com/tag/xml
has answer: http://stackoverflow.com/a/2605231
type: UnansweredQuestion
has body: I am trying to re-arrange all the attributes of the XML file. Need to group all the attributes of each node. <?xml version="1.0" encoding="UTF-8"?> Here is the required output XML file: <?xml version="1.0" encoding="UTF-8"?> Can this be possible with XML DOM in JAVA?
tagged with: java
has title: Can all the attibutes of a node in an XML be grouped using JAVA?
tagged with: dom
type: Question
has comment: http://stackoverflow.com/comment/2616009
answer count: 2
score: 0

http://stackoverflow.com/a/2698435
answers question: http://stackoverflow.com/q/2698391
has body: lucene is Java based search engine
downvote count: 1
has comment: http://stackoverflow.com/comment/2720943
score: -1
upvote count: 0
type: Answer

http://stackoverflow.com/q/2712970
accepted answer: http://stackoverflow.com/a/2713013
tagged with: maven-2
favorite count: 0
upvote count: 203
has title: Get Maven artifact version at runtime
linked to: http://stackoverflow.com/q/11500533
has answer: http://stackoverflow.com/a/73050121
has answer: http://stackoverflow.com/a/24957990
has answer: http://stackoverflow.com/a/43383222
has answer: http://stackoverflow.com/a/58067252
type: AnsweredQuestion
score: 203
linked to: http://stackoverflow.com/q/26551439
linked to: http://stackoverflow.com/q/2161054
has answer: http://stackoverflow.com/a/62170900
tagged with: java
has answer: http://stackoverflow.com/a/70307580
has answer: http://stackoverflow.com/a/12571330
type: Question
has answer: http://stackoverflow.com/a/2713013
possible better answer: http://stackoverflow.com/a/7676650
has answer: http://stackoverflow.com/a/7676650
has answer: http://stackoverflow.com/a/38193883
downvote count: 0
has answer: http://stackoverflow.com/a/63360815
has body: I have noticed that in a Maven artifact's JAR, the project.version attribute is included in two files: META-INF/maven/${groupId}/${artifactId}/pom.properties META-INF/maven/${groupId}/${artifactId}/pom.xml Is there a recommended way to read this version at runtime?
answer count: 13
has answer: http://stackoverflow.com/a/49190623
has answer: http://stackoverflow.com/a/65236252
has comment: http://stackoverflow.com/comment/41794837
linked to: http://stackoverflow.com/q/14934299

http://stackoverflow.com/a/2685191
downvote count: 7
type: Answer
has comment: http://stackoverflow.com/comment/21221693
has comment: http://stackoverflow.com/comment/137200982
score: 1
has comment: http://stackoverflow.com/comment/137201056
upvote count: 8
has body: If you want a brutally subjective answer. I have just finished a degree in Computer Science in England, I chose a university that taught C# as opposed to Java.........reason being, so I could easily walk straight into a highly paid job as a software developer with a company that simply only wants people who know the "new" technologies. These are companies such as Investment Banks, tech startups, IT Consulting firms. So if you want to pick one to learn...... Think about the end goal.....if it's cash and modern knowledge...follow C#. ....and if it's anything else, follow C# P.S. Java is terrible - I had to say it.
answers question: http://stackoverflow.com/q/2625520
has comment: http://stackoverflow.com/comment/53932378

http://stackoverflow.com/q/2693752
has answer: http://stackoverflow.com/a/2694385
tagged with: android
tagged with: android-sdk-2.1
accepted answer: http://stackoverflow.com/a/2694385
upvote count: 1
type: Question
type: AnsweredQuestion
has title: Conversion to Dalvik format failed error for Android Grid View
score: 1
tagged with: java
tagged with: eclipse
has body: I'm on the android bandwagon and started going through google's "view" tutorials. Here is what I'm using: Eclipse Galileo Android SDK 2.1 Java SDK 6.Something I think. Everything was hunky-dory until I hit the grid view tutorial. I got errors all over the place when I started editing the "HelloGridview.java" File. I thought I'd fix it by following through with the next part of the tutorial, creating the ImageAdapter class, but it created more. I realized alot of my issues could be resolved by importing widgets which were not mentioned in the tutorial (i.e. android.widget.GridView, .ImageView, .BaseAdapter etc.) However, after all the reconciliation suggested by eclipse the files were finally showing no errors. I go to run it as an android app and bam, "Your project contains error(s)." window comes up. There are no errors showing on the files I've created. I cleared the error log and shut down eclipse and started again the error log now reads: Conversion to Dalvik format failed with error 1. I'm a little lost at this point. I think I've included the required information. If you need to know more let me know. Any help is appreciated.
answer count: 2
downvote count: 0
possible better answer: http://stackoverflow.com/a/8282577
has answer: http://stackoverflow.com/a/8282577
favorite count: 0

http://stackoverflow.com/comment/2816795
has text: I don't see why. What magic do you think your going via java.dll is doing? I would imagine java.dll will turn around and call back in via java to do this, so I doubt your path to jvm.dll (where the JVM really sits) is as clean as you think. But the point around not being able to trust remains: java.dll itself could be compromised as you don't own it. Or jvm.dll. Either could be replaced by "man in the middle" DLLs that monitor/manipulate all calls through them.
comment on: http://stackoverflow.com/a/2778770
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/a/2660125
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2660110
has body: It is a do-while loop. So it will do everything in the following block while count is less than or equal to 5. The difference between this and a normal while loop is that the condition is evaluated at the end of the loop not the start. So the loop is guarenteed to execute at least once. Sun tutorial on while and do-while. Oh, and in this case it will print: 1, 2 1, 2, 3, 4 Edit: just so you know there will also be a new line at the start, but the formatting doesn't seem to let me show that.
type: Answer
answers question: http://stackoverflow.com/q/2660110
upvote count: 6
score: 6

http://stackoverflow.com/q/2717561
tagged with: jsp-tags
has answer: http://stackoverflow.com/a/2717719
tagged with: spring-mvc
score: 0
tagged with: java
type: Question
has body: I have read here that one disadvantage that some may find with using Spring MVC over Struts is that Struts has tags that output HTML code, while Spring has tags that don't generate HTML. My question is can't you just use the Struts tag-lib in a Spring MVC project (or any other kind of framework project), by dropping the right jar into the WEB-INF/lib folder? Any clarification is appreciated, thanks.
has title: Can any framework project use Struts-taglib
tagged with: struts
answer count: 1
tagged with: jsp
type: UnansweredQuestion

http://stackoverflow.com/q/2776942
accepted answer: http://stackoverflow.com/a/2777126
answer count: 2
has title: JPA merge fails due to duplicate key
downvote count: 0
favorite count: 0
tagged with: merge
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2777032
score: 1
tagged with: java
tagged with: orm
upvote count: 1
type: Question
possible better answer: http://stackoverflow.com/a/2777032
has answer: http://stackoverflow.com/a/2777126
has body: I have a simple entity, Code, that I need to persist to a MySQL database. public class Code implements Serializable { @Id private String key; private String description; ...getters and setters... } The user supplies a file full of key, description pairs which I read, convert to Code objects and then insert in a single transaction using em.merge(code). The file will generally have duplicate entries which I deal with by first adding them to a map keyed on the key field as I read them in. A problem arises though when keys differ only by case (for example: XYZ and XyZ). My map will, of course, contain both entries but during the merge process MySQL sees the two keys as being the same and the call to merge fails with a MySQLIntegrityConstraintViolationException. I could easily fix this by uppercasing the keys as I read them in but I'd like to understand exactly what is going wrong. The conclusion I have come to is that JPA considers XYZ and XyZ to be different keys but MySQL considers them to be the same. As such when JPA checks its list of known keys (or does whatever it does to determine whether it needs to perform an insert or update) it fails to find the previous insert and issuing another which then fails. Is this corrent? Is there anyway round this other than better filtering the client data? I haven't defined .equals or .hashCode on the Code class so perhaps this is the problem.
tagged with: jpa
tagged with: persistence

http://stackoverflow.com/comment/2685531
type: Comment
has text: Yes. The problem is that the 'actions that occure after a user clicked 'login'' are controlled by tomcat, not by the application. I would like to avoid using tomcat's internal classes.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2667400

http://stackoverflow.com/comment/2812972
has text: I am using the event dispatch thread. Thank you for the reply I'll check the links :).
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2778361

http://stackoverflow.com/q/2652113
has comment: http://stackoverflow.com/comment/2668266
upvote count: 1
answer count: 1
tagged with: java
type: AnsweredQuestion
tagged with: locale
downvote count: 0
has title: Calling Grep inside Java gives incorrect results while calling grep in shell gives correct results
has answer: http://stackoverflow.com/a/2652189
favorite count: 0
tagged with: bash
type: Question
accepted answer: http://stackoverflow.com/a/2652189
tagged with: grep
score: 1
has comment: http://stackoverflow.com/comment/2668279
tagged with: exec
has body: I've got a problem where calling grep from inside java gives incorrect results, as compared to the results from calling grep on the same file in the shell. My grep command (called both in Java and in bash. I escaped the slash in Java accordingly): /bin/grep -vP --regexp='^[0-9]+\t.*' /usr/local/apache-tomcat-6.0.18/work/Catalina/localhost/saccitic/237482319867147879_1271411421 Java Code: String filepath = "/path/to/file"; String options = "P"; String grepparams = "^[0-9]+\\t.*"; String greppath = "/bin/"; String[] localeArray = new String[] { "LANG=", "LC_COLLATE=C", "LC_CTYPE=UTF-8", "LC_MESSAGES=C", "LC_MONETARY=C", "LC_NUMERIC=C", "LC_TIME=C", "LC_ALL=" }; options = "v"+options; //Assign optional params if (options.contains("P")) { grepparams = "\'"+grepparams+"\'"; //Quote the regex expression if -P flag is used } else { options = "E"+options; //equivalent to calling egrep } proc = sysRuntime.exec(greppath+"/grep -"+options+" --regexp="+grepparams+" "+filepath, localeArray); System.out.println(greppath+"/grep -"+options+" --regexp="+grepparams+" "+filepath); inStream = proc.getInputStream(); The command is supposed to match and discard strings like these: 85295371616 Hi Mr Lee, please be informed that... My input file is this: 85aaa234567 Hi Ms Chan, please be informed that... 85292vx5678 Hi Mrs Ng, please be informed that... 85295371616 Hi Mr Lee, please be informed that... 85aaa234567 Hi Ms Chan, please be informed that... 85292vx5678 Hi Mrs Ng, please be informed that... 85295371616 Hi Mr Lee, please be informed that... 85295371616 Hi Mr Lee, please be informed that... 85295371616 Hi Mr Lee, please be informed that... 85295371616 Hi Mr Lee, please be informed that... 85295371616 Hi Mr Lee, please be informed that... 8~!95371616 Hi Mr Lee, please be informed that... 85295371616 Hi Mr Lee, please be informed that... 852&amp;^*&amp;1616 Hi Mr Lee, please be informed that... 8529537Ax16 Hi Mr Lee, please be informed that... 85====ppq16 Hi Mr Lee, please be inform…

http://stackoverflow.com/q/2743167
tagged with: sqlite
type: UnansweredQuestion
tagged with: calendar
has answer: http://stackoverflow.com/a/2744020
has title: extract android 1.6 calendar fields to vcal
tagged with: java
tagged with: database
type: Question
answer count: 1
has body: I want to extract android 1.6 calendar fields and put them into a vcalendar file my problem is that i can't find some fields in the database like: DTSTAMP UID LAST-MODIFIED SEQUENCE does anyone have a clue on how to find them? thanks!
score: 0
tagged with: android

http://stackoverflow.com/a/2738598
has comment: http://stackoverflow.com/comment/131043705
answers question: http://stackoverflow.com/q/2738574
score: 48
type: Answer
accepted answer of: http://stackoverflow.com/q/2738574
upvote count: 51
has body: Someone is trying to send you a message :-) In the time you've spend fiddling with compiler versions you could have loaded the data from a text file - which is probably where it belongs. Check out: java.util.Properties Apache Commons FileUtils.readFileToString()
downvote count: 3
type: AcceptedAnswer

http://stackoverflow.com/a/2751971
has comment: http://stackoverflow.com/comment/2782833
downvote count: 0
answers question: http://stackoverflow.com/q/2751949
score: 1
upvote count: 1
type: Answer
has body: As you mention, servlet filters can provide the basis of solution. Use a filter to store the current session details (e.g. the session context Map) in a threadLocal storage. This is implemented as your application class, so is transport agnostic. Your service simply uses a static method to fetch the current context, unaware of where it came from. E.g. class ServiceSessionContext { static ThreadLocal&lt;Map&gt; local = new ThreadLocal&lt;Map&gt;(); // context set by the transport layer, e.g. servlet filter static public void setContext(Map map) { local.put(map); } // called when request is complete static public void clearContext() { local.put(null); } // context fetched by the service static public Map getContext() { return local.get(); } }

http://stackoverflow.com/a/2782221
type: AcceptedAnswer
has body: Unless you have a special reason to use a third-party library for XML parsing, I'd just use the standard Java API. See the package javax.xml.parsers. Assuming you have the XML in a file, you can parse it into an org.w3c.dom.Document (also part of Java's standard API) like this: DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(new File(filename)); Since your files are not so large, using DOM would be the easiest and most obvious choice. You can use the methods of the Document object and related objects (see the classes in the org.w3c.dom package) to get at the data, or use XPath (see the package javax.xml.xpath). JAXB, that Quotidian mentions, is also in the standard API since Java 6, but it might be a bit more work to set up than using the standard DOM API.
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2781653
type: Answer
answers question: http://stackoverflow.com/q/2781653
score: 3
upvote count: 3

http://stackoverflow.com/a/16483831
type: Answer
answers question: http://stackoverflow.com/q/2781086
score: 3
upvote count: 3
has body: Possibly the clearest explanation I've seen: http://www.ibm.com/developerworks/java/library/j-math2/index.html the ULP or unit of least precision defines the precision available between any two float values. As these values increase the available precision decreases. For example: between 1.0 and 2.0 inclusive there are 8,388,609 floats, between 1,000,000 and 1,000,001 there are 17. At 10,000,000 the ULP is 1.0, so above this value you soon have multiple integeral values mapping to each available float, hence the loss of precision.
downvote count: 0

http://stackoverflow.com/comment/79318646
comment on: http://stackoverflow.com/a/2728810
type: AnswerComment
type: Comment
score: 1
has text: Use Guava ComparisonChain. It is very handy! https://google.github.io/guava/releases/22.0/api/docs/com/google/common/collect/ComparisonChain.html

http://stackoverflow.com/a/2733765
answers question: http://stackoverflow.com/q/2733688
score: 3
upvote count: 3
has body: I think you'll be better off with an embeddable database for this. HSQLDB or H2 would work, as would SQLite. SQLite is quite popular outside the Java world (it's used by the Mozilla project, for instance). I'm not familiar with JavaDB, so I can't speak to its capabilities. SQLite is known to be pretty fast.
type: Answer
downvote count: 0

http://stackoverflow.com/a/2740894
type: Answer
has comment: http://stackoverflow.com/comment/2769938
upvote count: 4
has comment: http://stackoverflow.com/comment/2769769
answers question: http://stackoverflow.com/q/2740852
downvote count: 0
has comment: http://stackoverflow.com/comment/2770030
has comment: http://stackoverflow.com/comment/2769910
has comment: http://stackoverflow.com/comment/2769889
has body: Just scan the matrix, and remember the best score and best name so far. Something like: String[] names = {"a","b","c","d","e"}; int[][] scores = new int[5][5]; //... init scores int best = Integer.MIN_VALUE; String bestName = null; for(int nm = 0;nm&lt;5;nm++){ for(int c = 0;c&lt;5;c++){ int score = scores[nm][c]; if (score&gt;=best){ best = score; bestName = names[nm]; } } } System.out.println(bestName);
has comment: http://stackoverflow.com/comment/2769829
score: 4
has comment: http://stackoverflow.com/comment/2772399

http://stackoverflow.com/comment/2814140
type: QuestionComment
comment on: http://stackoverflow.com/q/2779035
score: 0
type: Comment
has text: @Jonas: Yeah got it, its a bit strange, I've been working so long with Swings, but have not noticed it. I think I have one or two alternates, will try to do something on this issue. Nice Question, by the way +1

http://stackoverflow.com/comment/2654048
has text: Yes, my first thought was exactly yours, but when i added the openjpa.jar in my classpath i found that the exception throws in this moment was ClassNotFoundException of javax.jdo.spi.PersistenceCapable thats is in the wlfullclient.jar. Obviously i tried with and without wlfullclient.jar and i have the same behaviour
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2639314

http://stackoverflow.com/q/2617313
answer count: 2
accepted answer: http://stackoverflow.com/a/2617446
favorite count: 0
has answer: http://stackoverflow.com/a/2620141
has answer: http://stackoverflow.com/a/2617446
tagged with: c++
type: AnsweredQuestion
score: 2
downvote count: 0
possible better answer: http://stackoverflow.com/a/2620141
tagged with: java
tagged with: android-ndk
type: Question
upvote count: 2
tagged with: java-native-interface
has body: I am using JNI to call my C++ function from Java. One of the C++ function's arguments is jobject thiz (as far as I know, all JNI native functions have this argument). The function takes quite long to complete and I want to report progress back to the jobject thiz Java object, so that I can show the progress to the user. How can I call jobject's methods from C++?
has title: How to call Java method from C++

http://stackoverflow.com/comment/2794319
type: Comment
has text: @poygenelubricants what do you mean by *raw types* not generics? Why not?
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2762137

http://stackoverflow.com/a/2707526
has body: Regarding your code with MultiMap: the only thing you're doing wrong is to create a new set for every token instead of putting all the tokens of a line into the same set. That's also why you're missing tokens. This works: s = new HashSet&lt;String&gt;(); while (st.hasMoreTokens()) { //System.out.println(st.nextToken()); s.add(st.nextToken()); }
upvote count: 2
has comment: http://stackoverflow.com/comment/2731409
type: Answer
answers question: http://stackoverflow.com/q/2704882
score: 2
downvote count: 0

http://stackoverflow.com/comment/24954389
type: AnswerComment
type: Comment
has text: Be careful when doing this on platforms before 4.0 - this will leak a lot of resources due to a bug in Android: https://code.google.com/p/android/issues/detail?id=9904
comment on: http://stackoverflow.com/a/13305509
score: 2

http://stackoverflow.com/q/2609141
favorite count: 0
tagged with: swing
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/2615779
score: 1
tagged with: java
has title: Is it possible to have a JPanel over JTable
possible better answer: http://stackoverflow.com/a/2609196
has answer: http://stackoverflow.com/a/2609196
has body: I have a JTable whose associated TableModel could be initially empty. Therefore, it currently shows a JTable with its columns and no rows. In order to fill this JTable, I want the user to drag and drop elements from another component. The problem is that I would like to hint the user that he/she should drag elements to this table, with some message like "Drag xxx here to add a row". I thought that I could achieve this by putting a panel over the JTable , but I don't think it is possible with any java layout. Does anyone know how to do this? Or should I stick to a CardLayout to switch to/from the hint and the JTable? Thanks a lot
type: Question
accepted answer: http://stackoverflow.com/a/2609275
tagged with: layout
has answer: http://stackoverflow.com/a/2609275
answer count: 3
upvote count: 1

http://stackoverflow.com/comment/2606174
comment on: http://stackoverflow.com/q/2597106
type: Comment
type: QuestionComment
has text: You want to run the code 2000 times with alternative values... are these values known, or are they the result of previous executions?
score: 0

http://stackoverflow.com/comment/137900641
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2691162
type: AnswerComment
has text: Why can't you store a number with 303 digits? That's less than the maximum of 308 digits.

generics
tags question: http://stackoverflow.com/q/2704514
tags question: http://stackoverflow.com/q/2770321
tags question: http://stackoverflow.com/q/2758582
tags question: http://stackoverflow.com/q/2602048
tags question: http://stackoverflow.com/q/2640060
tags question: http://stackoverflow.com/q/2648758
tags question: http://stackoverflow.com/q/2767212
tags question: http://stackoverflow.com/q/2669326
tags question: http://stackoverflow.com/q/2701630
tags question: http://stackoverflow.com/q/2632405
tags question: http://stackoverflow.com/q/2777561
tags question: http://stackoverflow.com/q/2745265
tags question: http://stackoverflow.com/q/2646613
type: Tag
tags question: http://stackoverflow.com/q/2599623
tags question: http://stackoverflow.com/q/2648438
tags question: http://stackoverflow.com/q/2783613
tags question: http://stackoverflow.com/q/2717356
tags question: http://stackoverflow.com/q/2648398
tags question: http://stackoverflow.com/q/2733388
tags question: http://stackoverflow.com/q/2721546
tags question: http://stackoverflow.com/q/2781672
tags question: http://stackoverflow.com/q/2770264
tags question: http://stackoverflow.com/q/2683202
tags question: http://stackoverflow.com/q/2723397
tags question: http://stackoverflow.com/q/2753002
tags question: http://stackoverflow.com/q/2711071
tags question: http://stackoverflow.com/q/2630514
tags question: http://stackoverflow.com/q/2745088
tags question: http://stackoverflow.com/q/2668117
tags question: http://stackoverflow.com/q/2754756
tags question: http://stackoverflow.com/q/2662333
tags question: http://stackoverflow.com/q/2622259
tags question: http://stackoverflow.com/q/2657131
tags question: http://stackoverflow.com/q/2776975
tags question: http://stackoverflow.com/q/2773511
tags question: http://stackoverflow.com/q/2745944
tags question: http://stackoverflow.com/q/2705091
tags question: http://stackoverflow.com/q/2730507
tags question: http://stackoverflow.com/q/2755133
tags question: http://stackoverflow.com/q/2660827
tags question: http://stackoverflow.com/q/2719776
tags question: http://stackoverflow.com/q/2685537
tag name: generics
tags question: http://stackoverflow.com/q/2676153
tags question: http://stackoverflow.com/q/2611015
tags question: http://stackoverflow.com/q/2664594
tags question: http://stackoverflow.com/q/2629786
tags question: http://stackoverflow.com/q/2619429
tags question: http://stackoverflow.com/q/2769308

http://stackoverflow.com/comment/2664015
has text: which would be the max hexString lenght supported?
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2648259
type: Comment

http://stackoverflow.com/q/2711092
tagged with: java
has answer: http://stackoverflow.com/a/2711112
type: Question
upvote count: 2
has answer: http://stackoverflow.com/a/2711123
has title: Java application design question
has body: I have a hobby project, which is basically to maintain 'todo' tasks in the way I like. One task can be described as: public class TodoItem { private String subject; private Date dueBy; private Date startBy; private Priority priority; private String category; private Status status; private String notes; } As you can imagine I would have 1000s of todo items at a given time. What is the best strategy to store a todo item? (currently on an XML file) such that all the items are loaded quickly up on app start up(the application shows kind of a dashboard of all the items at start up)? What is the best way to design its back-end so that it can be ported to Android/or a J2ME based phone? Currently this is done using Java Swing. What should I concentrate on so that it works efficiently on a device where memory is limited? The application throws open a form to enter new todo task. For now, I would like to save the newly added task to my-todos.xml once the user presses "save" button. What are the common ways to append such a change to an existing XML file?(note that I don't want to read the whole file again and then persist)
tagged with: android
has answer: http://stackoverflow.com/a/2714743
has answer: http://stackoverflow.com/a/2711213
favorite count: 0
possible better answer: http://stackoverflow.com/a/2711112
has comment: http://stackoverflow.com/comment/2735937
tagged with: swing
tagged with: backend
answer count: 4
score: 2
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2711123
downvote count: 0

http://stackoverflow.com/a/6340496
upvote count: 1
has body: This issue is described here and a couple of bugs have been opened on it. Essentially, when being retrieved from the datastore you're not getting a java.util.ArrayList back, you're getting an org.datanucleus.sco.backed.ArrayList instead. Everything seems fine until you call an RPC when, unsurprisingly, it's unable to serialize this type. The hacky fix appears to be converting the ArrayList to the right type after retrieving the object but before calling any RPCs that use it. At least until the bugs are fixed.
score: 1
answers question: http://stackoverflow.com/q/2687911
downvote count: 0
type: Answer

http://stackoverflow.com/q/2721322
has answer: http://stackoverflow.com/a/2721359
has body: I use JButtons in my application. They need to have different colors. First I used that btn.setBackground(col);. It works on my computer and on another computer my button just gray (not red, as it's supposed to be). Trying to solve this problem I decided to use images. I do it in the following way: tmp = new JButton(newIcon); Again, it works fine on my computer and on another computer I see just gray buttons. Does anybody have any ideas what can be the reason of the problem and how it can be solved? I heard it can be related to "look-and-feel of the native system". But I do not know what it means and what should I do if it is the case? Can anybody pleas, help me with that?
tagged with: java
tagged with: cross-platform
has answer: http://stackoverflow.com/a/2721412
has comment: http://stackoverflow.com/comment/2747641
type: Question
possible better answer: http://stackoverflow.com/a/2721412
has answer: http://stackoverflow.com/a/2721487
has comment: http://stackoverflow.com/comment/2749367
tagged with: icons
accepted answer: http://stackoverflow.com/a/2721359
score: 0
tagged with: colors
answer count: 3
has title: Why does my JButton look differently of different computers?
tagged with: jbutton
type: AnsweredQuestion

http://stackoverflow.com/q/2636837
has body: I have a custom class loader which extends from a URLClassLoader. I added a .class file to the urlpath using addURL(); but when i do a class.forname() using this loader i get a ClassNotFoundException. However, if i create a jar and add the jar to the urlpath, i do not get any exception. Using addURL(), can we add a .class file or a directory?? Can someone confirm this because it does not work for me?
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
accepted answer: http://stackoverflow.com/a/2636910
type: Question
upvote count: 1
has answer: http://stackoverflow.com/a/2636910
answer count: 1
has title: can a .class file be added to the urlpath of a URLClassLoader
favorite count: 0
has comment: http://stackoverflow.com/comment/2725864
tagged with: classnotfoundexception
tagged with: urlclassloader

http://stackoverflow.com/q/2686733
has answer: http://stackoverflow.com/a/2691816
type: Question
answer count: 2
score: 0
has answer: http://stackoverflow.com/a/2687499
has body: I tried to do it 2 different ways, but neither way worked. @Component public class EmailForm{ ... private QuestionDAO questionDAO; ... @Autowired public void setQuestionDAO(QuestionDAO questionDAO) { this.questionDAO = questionDAO; } ... Another way: @Component public class EmailForm implements ApplicationContextAware { ... public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.questionDAO = (QuestionDAO)applicationContext.getBean("questionDAO"); } ... Neither way results in questionDAO being injected Form bean is populated by spring: @RequestMapping(method = RequestMethod.POST) public String submit(@Valid final EmailForm emailForm, BindingResult result, final Model model) {
type: UnansweredQuestion
tagged with: annotations
tagged with: spring
tagged with: spring-mvc
tagged with: java
has comment: http://stackoverflow.com/comment/8985141
has title: Is it possible to inject a bean into a spring form bean

http://stackoverflow.com/comment/2679815
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2662342
has text: Arg, I found the problem within my own code. Thanks for the help!
type: AnswerComment

http://stackoverflow.com/a/2638252
has comment: http://stackoverflow.com/comment/35409939
has comment: http://stackoverflow.com/comment/12968516
has comment: http://stackoverflow.com/comment/12961203
has comment: http://stackoverflow.com/comment/8467495
has comment: http://stackoverflow.com/comment/35586328
score: 120
accepted answer of: http://stackoverflow.com/q/2638200
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2638200
has comment: http://stackoverflow.com/comment/27118648
downvote count: 0
has comment: http://stackoverflow.com/comment/73798469
type: Answer
has body: Yeah, it's a little convoluted (compared to the good ol' way), but this should do it: TokenStream tokenStream = analyzer.tokenStream(fieldName, reader); OffsetAttribute offsetAttribute = tokenStream.getAttribute(OffsetAttribute.class); TermAttribute termAttribute = tokenStream.getAttribute(TermAttribute.class); while (tokenStream.incrementToken()) { int startOffset = offsetAttribute.startOffset(); int endOffset = offsetAttribute.endOffset(); String term = termAttribute.term(); } Edit: The new way According to Donotello, TermAttribute has been deprecated in favor of CharTermAttribute. According to jpountz (and Lucene's documentation), addAttribute is more desirable than getAttribute. TokenStream tokenStream = analyzer.tokenStream(fieldName, reader); OffsetAttribute offsetAttribute = tokenStream.addAttribute(OffsetAttribute.class); CharTermAttribute charTermAttribute = tokenStream.addAttribute(CharTermAttribute.class); tokenStream.reset(); while (tokenStream.incrementToken()) { int startOffset = offsetAttribute.startOffset(); int endOffset = offsetAttribute.endOffset(); String term = charTermAttribute.toString(); }
has comment: http://stackoverflow.com/comment/34968040
upvote count: 120

http://stackoverflow.com/q/2609060
possible better answer: http://stackoverflow.com/a/2609172
type: Question
has answer: http://stackoverflow.com/a/2609172
has answer: http://stackoverflow.com/a/13527394
score: 5
accepted answer: http://stackoverflow.com/a/13528298
upvote count: 5
has body: I'm working on a MigLayout form with 3 columns and 4 rows, like this: "wrap 3", "[15%] 15px [45%] 15px [40%]", "20 [] 15 [] 15 [grow,fill] 15 []" Now my goal is to have it look like this: .------------------------------------. | 15% | 45% | 40% | |------------------------------------| | | | | |------------------------------------| | | | | |------------------------------------| | button,button | `------------------------------------´ I want the buttons on the last row centered, so I assumed that it first requires that I span the 3 columns of the 4th row into one with the "span 3, center" component constraint on the button. This works nicely with just one button, but I'm having problems figuring out how to add the second button, while keeping both two buttons centered on the same row at the same time. If i add same constraints on the second button it appears perfectly centered below the first button on the next row.
has title: Java Swing MigLayout, centering two elements inside a spanned row
answer count: 3
downvote count: 0
favorite count: 0
tagged with: swing
type: AnsweredQuestion
tagged with: miglayout
tagged with: java
has answer: http://stackoverflow.com/a/13528298

http://stackoverflow.com/a/2603659
type: Answer
upvote count: 6
score: 6
downvote count: 0
answers question: http://stackoverflow.com/q/2603638
has body: MM stands for numeric month. Use MMM.

http://stackoverflow.com/q/2629297
has comment: http://stackoverflow.com/comment/2642979
has comment: http://stackoverflow.com/comment/2647272
type: Question
tagged with: gwt
upvote count: 20
possible better answer: http://stackoverflow.com/a/2629333
tagged with: intellij-idea
has comment: http://stackoverflow.com/comment/2644488
has answer: http://stackoverflow.com/a/2633669
score: 20
answer count: 2
downvote count: 0
accepted answer: http://stackoverflow.com/a/2633669
favorite count: 0
has comment: http://stackoverflow.com/comment/2647289
has body: I'm trying to move our Google Web Toolkit (GWT) development from Eclipse to IntelliJ 9 Community edition. So far I've been able to run and debug client/server code successfully via the GWT Maven plugin and its embedded Jetty container. However, I'm having trouble debugging client code when it is already running on a remote machine (and hence there's no need for the embedded Jetty container). Has anyone been successful at achieving this? Any help would be appreciated! UPDATE: I was finally able to accomplish this. Please see my own answer below...
type: AnsweredQuestion
tagged with: java
has title: Is it possible to debug GWT client code on a REMOTE server using IntelliJ 9 Community Edition?
has answer: http://stackoverflow.com/a/2629333

http://stackoverflow.com/q/2616474
downvote count: 0
tagged with: ldap
has answer: http://stackoverflow.com/a/2616530
answer count: 1
favorite count: 0
upvote count: 2
has body: I would like to list or search the root context(s) in a LDAP tree. I use Apache Directory Server and Java: Hashtable&lt;String, String&gt; contextParams = new Hashtable&lt;String, String&gt;(); contextParams.put("java.naming.provider.url", "ldap://localhost:10389"); contextParams.put("java.naming.security.principal", "uid=admin,ou=system"); contextParams.put("java.naming.security.credentials", "secret"); contextParams.put("java.naming.security.authentication", "simple"); contextParams.put("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory"); DirContext dirContext = new InitialDirContext(contextParams); NamingEnumeration&lt;NameClassPair&gt; resultList; //Works resultList = dirContext.list("ou=system"); while (resultList.hasMore()) { NameClassPair result = resultList.next(); System.out.println(result.getName()); } //Does not work resultList = dirContext.list(""); while (resultList.hasMore()) { NameClassPair result = resultList.next(); System.out.println(result.getName()); } I can list the sub nodes of ou=system. But I cannot list the sub nodes of the actual root node. I would like to have this list just like Apache Directory Studio can: alt text http://lesc.se/stackoverflow/ldap_root_contexts.png
accepted answer: http://stackoverflow.com/a/2616530
has title: List the root contexts in LDAP
type: AnsweredQuestion
score: 2
tagged with: apacheds
tagged with: java
type: Question

http://stackoverflow.com/comment/69066335
type: Comment
has text: Does this works for non-console output? It seem that the alignment will go crazy if I attempt to print this to TextArea in javafx
type: AnswerComment
comment on: http://stackoverflow.com/a/32515408
score: 0

http://stackoverflow.com/a/2599890
type: Answer
has body: Does this help? while ( rs.next() ) { bw.write(rs.getString(1)==null? "":rs.getString(1)); while(rs1.next()){ while(rs2.next()){ bw.write("\t"); bw.write(rs1.getString(1)==null? "":rs1.getString(1)); bw.write("\t"); bw.write(rs2.getString(1)==null? "":rs2.getString(1)); bw.write("\t"); bw.newLine(); } } }
has comment: http://stackoverflow.com/comment/2608701
has comment: http://stackoverflow.com/comment/2608988
has comment: http://stackoverflow.com/comment/2609872
score: 0
answers question: http://stackoverflow.com/q/2599860

http://stackoverflow.com/q/2760995
tagged with: initialization
favorite count: 0
accepted answer: http://stackoverflow.com/a/2761019
has title: ArrayList initialization equivalent to array initialization
duplicate of: http://stackoverflow.com/q/157944
has answer: http://stackoverflow.com/a/2761016
has answer: http://stackoverflow.com/a/2761025
has answer: http://stackoverflow.com/a/8358364
has body: I am aware that you can initialize an array during instantiation as follows: String[] names = new String[] {"Ryan", "Julie", "Bob"}; Is there a way to do the same thing with an ArrayList? Or must I add the contents individually with array.add()?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/24051030
has answer: http://stackoverflow.com/a/34876894
tagged with: java
duplicate of: http://stackoverflow.com/q/1005073
score: 311
type: Question
has answer: http://stackoverflow.com/a/2761018
answer count: 8
tagged with: arrays
possible better answer: http://stackoverflow.com/a/2761018
tagged with: arraylist
upvote count: 315
has answer: http://stackoverflow.com/a/2761026
downvote count: 4
has answer: http://stackoverflow.com/a/2761019
linked to: http://stackoverflow.com/q/1958636

jrubyonrails
tags question: http://stackoverflow.com/q/2735885
type: Tag
tag name: jrubyonrails

http://stackoverflow.com/comment/2663168
comment on: http://stackoverflow.com/a/2610365
type: AnswerComment
type: Comment
has text: @Joe @Rex launch4j (http://launch4j.sourceforge.net/) seems to support shipping a Java application as a Windows executable with a JRE embedded. OS X comes with a JRE installed, so you might not have an issue there.
score: 1

http://stackoverflow.com/comment/2787184
type: Comment
comment on: http://stackoverflow.com/a/2752190
score: 0
has text: This is what i assumed would be the correct answer, although i was hoping for some automation of the process on this level of SDK/device. For reference this approach loads an ArrayList with my data (my storage class is slightly more complicated than alex's) in 1ms on a Nexus One with some background tasks running, i assume the real timing is <1ms making it many times more battery efficient.
type: AnswerComment

http://stackoverflow.com/a/2723538
has comment: http://stackoverflow.com/comment/36688334
has comment: http://stackoverflow.com/comment/41687401
has comment: http://stackoverflow.com/comment/130687722
downvote count: 3
accepted answer of: http://stackoverflow.com/q/2723397
has comment: http://stackoverflow.com/comment/32173405
has comment: http://stackoverflow.com/comment/75513056
answers question: http://stackoverflow.com/q/2723397
has comment: http://stackoverflow.com/comment/88222556
has comment: http://stackoverflow.com/comment/48704855
has comment: http://stackoverflow.com/comment/36793775
upvote count: 1064
has comment: http://stackoverflow.com/comment/131728055
has comment: http://stackoverflow.com/comment/58388918
score: 1061
has comment: http://stackoverflow.com/comment/131782189
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/130663300
has comment: http://stackoverflow.com/comment/48705008
has comment: http://stackoverflow.com/comment/23544205
has body: tl;dr: "PECS" is from the collection's point of view. If you are only pulling items from a generic collection, it is a producer and you should use extends; if you are only stuffing items in, it is a consumer and you should use super. If you do both with the same collection, you shouldn't use either extends or super. Suppose you have a method that takes as its parameter a collection of things, but you want it to be more flexible than just accepting a Collection<Thing>. Case 1: You want to go through the collection and do things with each item. Then the list is a producer, so you should use a Collection<? extends Thing>. The reasoning is that a Collection<? extends Thing> could hold any subtype of Thing, and thus each element will behave as a Thing when you perform your operation. (You actually cannot add anything (except null) to a Collection<? extends Thing>, because you cannot know at runtime which specific subtype of Thing the collection holds.) Case 2: You want to add things to the collection. Then the list is a consumer, so you should use a Collection<? super Thing>. The reasoning here is that unlike Collection<? extends Thing>, Collection<? super Thing> can always hold a Thing no matter what the actual parameterized type is. Here you don't care what is already in the list as long as it will allow a Thing to be added; this is what ? super Thing guarantees.
type: Answer
has comment: http://stackoverflow.com/comment/98615013
has comment: http://stackoverflow.com/comment/75599256

http://stackoverflow.com/comment/7024328
type: AnswerComment
has text: ... although I'm not quite sure what to do now with the Objects I get back. Can't seem to cast them as String even though I know they're strings
comment on: http://stackoverflow.com/a/4799594
type: Comment
score: 1

http://stackoverflow.com/a/2761866
score: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/2710816
answers question: http://stackoverflow.com/q/2710816
has body: Well the problem was my web.xml file was located in my src/main/webapp/WEB-INF/web.xml even though my war plugin was configured to get my web.xml file from there it didnt place it in my war/WEB-INF/ folder. To fix it, I manually copied the web.xml file into the war/WEB-INF dir and it worked.
type: AcceptedAnswer

http://stackoverflow.com/comment/2705394
type: Comment
has text: toString() is not defined on arrays, is it?
comment on: http://stackoverflow.com/a/2685313
score: 0
type: AnswerComment

http://stackoverflow.com/q/2599172
tagged with: java
has body: When i run this code the paintComponent method is not being called It may be very simple error but i dont know why this, plz. package test; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Point; import java.awt.image.BufferedImage; import javax.swing.BorderFactory; import javax.swing.JPanel; class Userboard extends JPanel { static BufferedImage image; String shape; Point start; Point end; Point mp; String selected; int ex,ey;//eraser int w,h; public Userboard() { setOpaque(false); System.out.println("paper"); setBackground(Color.white); setBorder(BorderFactory.createLineBorder(Color.black)); } public void paintComponent(Graphics g) { System.out.println("userboard-paint"); try { //g.drawImage(image, 0, 0, this); Graphics2D g2 = (Graphics2D)g; g2.setPaint(Color.black); if(start!=null &amp;&amp; end!=null) { if(selected==("elipse")) { System.out.println("userboard-elipse"); g2.drawOval(start.x, start.y,(end.x-start.x),(end.y-start.y)); System.out.println("userboard-elipse drawn"); } else if(selected==("rect")) g2.drawRect(start.x, start.y, (end.x-start.x),(end.y-start.y)); else if(selected==("line")) g2.drawLine(start.x,start.y,end.x,end.y); } } catch(Exception e) {} } //Function to draw the shape on image public void draw() { System.out.println("Userboard-draw"); System.out.println(selected); System.out.println(start); System.out.println(end); Graphics2D g2 = image.createGraphics(); g2.setPaint(Color.black); if(start!=null &amp;&amp; end!=null) { if(selected=="line") g2.drawLine(start.x, start.y, end.x, end.y); else if(selected=="elipse") { System.out.println("userboard-elipse"); g2.drawOval(start.x, start.y, (end.x-start.x),(end.y-start.y)); System.out.println("userboard-elipse drawn"); } else if(selected=="rect") g2.drawRect(start.x, start.y, (end.x-start.x),(end.y-start.y)); } start=null; repaint(); g2.dispose(); } //To add the point to the board which is broadcasted by the server public void addPoint(Point ps,String var…
type: Question
possible better answer: http://stackoverflow.com/a/2599911
answer count: 2
accepted answer: http://stackoverflow.com/a/2599862
has answer: http://stackoverflow.com/a/2599911
has comment: http://stackoverflow.com/comment/2608343
score: 0
has answer: http://stackoverflow.com/a/2599862
has comment: http://stackoverflow.com/comment/2607941
has title: JPanel paint method is not being called, why?
tagged with: swing
type: AnsweredQuestion
tagged with: paint

http://stackoverflow.com/a/2682610
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/2681619
has body: From the exception that you posted, it looks like you are trying to use a detached Domain object with a new Action object. Before persisting the Action, you'll need to reattach the Domain object using the EntityManger.merge method: domainObject = entityManager.merge(domainObject); Action action = new Action(domainObject, "name", "description"); entityManager.persist(action); If you want to handle both cases described in your question, you can use merge instead of persist on the Action object. The merge method will persist the new Action, and will re-attach or persist the Domain object (since you have Cascade.MERGE specified). Action action = new Action(domainObject, "name", "description"); action = entityManager.merge(action); Just remember to use the new instance of the Domain object associated with the Action after the merge. If you are going to use the domain object after merging the Action object, be sure to do something like this: domainObject = action.getDomain();
upvote count: 2
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2703079
type: Answer
accepted answer of: http://stackoverflow.com/q/2681619

http://stackoverflow.com/q/2627992
has answer: http://stackoverflow.com/a/59940399
has answer: http://stackoverflow.com/a/2628109
downvote count: 0
possible better answer: http://stackoverflow.com/a/14858183
accepted answer: http://stackoverflow.com/a/2628560
has answer: http://stackoverflow.com/a/63001163
answer count: 13
favorite count: 0
has answer: http://stackoverflow.com/a/25763536
has answer: http://stackoverflow.com/a/55586892
has answer: http://stackoverflow.com/a/38709993
has body: I need to force any time related operations to GMT/UTC, regardless the timezone set on the machine. Any convenient way to so in code? To clarify, I'm using the DB server time for all operations, but it comes out formatted according to local timezone. Thanks!
tagged with: timezone
has answer: http://stackoverflow.com/a/16636323
has answer: http://stackoverflow.com/a/2628560
has answer: http://stackoverflow.com/a/5053005
tagged with: utc
linked to: http://stackoverflow.com/q/308683
has answer: http://stackoverflow.com/a/14858183
tagged with: gmt
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/64284320
tagged with: java
has answer: http://stackoverflow.com/a/16167283
has answer: http://stackoverflow.com/a/13858201
score: 119
type: Question
has title: Force Java timezone as GMT/UTC
upvote count: 119

http://stackoverflow.com/q/2675824
favorite count: 0
has body: I am using a small java smtp library (http://code.google.com/p/subethasmtp/), by this I need to parse the incoming emails in separate components viz body, attachments etc. I am trying to use mime4j , but the documentation suggests that mime4j can only give event notification or token notification and nothing else. For stripping out body and attachments etc I had to use my own custom logic inside the event handlers. Is my observation correct? If yes then how can I use mime4j to use for my requirement. Please suggest. I badly need an approach that takes in the smtp data stream and returns me with an array of attachment references or streams in fully parsed out form in java. Please help. Thanks in advance Ashish Sharma
accepted answer: http://stackoverflow.com/a/2727912
tagged with: mime
has answer: http://stackoverflow.com/a/6270939
upvote count: 6
has answer: http://stackoverflow.com/a/2727912
score: 6
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2750660
tagged with: java
has comment: http://stackoverflow.com/comment/7298711
type: Question
answer count: 2
tagged with: perl
has title: Email attachment parsing via mime4j
downvote count: 0
possible better answer: http://stackoverflow.com/a/6270939
tagged with: smtp

http://stackoverflow.com/comment/2751509
comment on: http://stackoverflow.com/a/2724832
has text: I have already checked the java version using the command line and the result is 1.6.0_19. Neither does the PATH command return any info regarding the a jre/jdk of a version < 1.6..
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/2652735
type: Comment
comment on: http://stackoverflow.com/a/2634791
type: AnswerComment
has text: @arrages Validator has been designed to perform simple validation. Something like isInteger, isNotBlank, isNotNull, nothing else. When using complex validation, You had better to place it inside your business logic. Notice i also use, as said by yourself, pretty complex with a lot of relationships, methods, without no problem.
score: 0

http://stackoverflow.com/comment/2798093
type: QuestionComment
has text: Please post a complete stack trace of your NullPointerException. It should help reveal exactly where the problem is occurring.
type: Comment
score: 2
comment on: http://stackoverflow.com/q/2765614

classloader
tags question: http://stackoverflow.com/q/2614095
tags question: http://stackoverflow.com/q/2760867
tags question: http://stackoverflow.com/q/2705107
tags question: http://stackoverflow.com/q/2632362
tags question: http://stackoverflow.com/q/2717667
tags question: http://stackoverflow.com/q/2599183
tags question: http://stackoverflow.com/q/2614989
tags question: http://stackoverflow.com/q/2642606
type: Tag
tags question: http://stackoverflow.com/q/2618230
tags question: http://stackoverflow.com/q/2681459
tag name: classloader
tags question: http://stackoverflow.com/q/2735994

http://stackoverflow.com/a/13509785
answers question: http://stackoverflow.com/q/2735839
downvote count: 0
has body: Use InputStreamEntity. I used httpclient 4.2.1. For example: HttpPost httppost = new HttpPost(url); InputStream inputStream=new ByteArrayInputStream(xmlString.getBytes());//init your own inputstream InputStreamEntity inputStreamEntity=new InputStreamEntity(inputStream,xmlString.getBytes()); httppost.setEntity(inputStreamEntity);
score: 6
type: Answer
upvote count: 6

http://stackoverflow.com/a/2705737
type: Answer
upvote count: 2
score: 2
has comment: http://stackoverflow.com/comment/2729354
has body: t1 has the lock of the t1 instance. t2 has the lock of the t2 instance. But your example doesnt make much sense.. Maybe this example will help you: public class Test extends Thread { private String name; public Test(String name) { this.name = name; } public synchronized void run() { System.out.println(name); while(true) { // loop endless } } public static void main(String args[]) { Thread t1= new Test("t1"); Thread t2= new Test("t2"); t1.start(); t2.start(); } } The output is: t1 t2
has comment: http://stackoverflow.com/comment/2729358
accepted answer of: http://stackoverflow.com/q/2705695
answers question: http://stackoverflow.com/q/2705695
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2729345

http://stackoverflow.com/q/2683889
has answer: http://stackoverflow.com/a/2684149
tagged with: java-ee-6
linked to: http://stackoverflow.com/q/2690461
score: 1
favorite count: 0
has body: I am using a JSF 2.0 to create a web app (purely jee6, without spring/seam etc.). I would like to have a single xhtml page but pass the proper backing bean / entity into it. For example, I would like to be able to edit a user other than the logged in user, I have a user edit page which displays the information of the logged in user (being tracked by my session), I would like to instead pass in a user selected from a list and edit that user's information, without switching the user that is stored in the session or creating a separate xhtml page (violating DRY). The "best" way I can see to achieve this would be to reuse the exact same xhtml page that I am using to display the logged-in-user's edit page, but simply pass in a different entity in some way. Perhaps calling the setter in the backing bean before redirecting to the page (if this is even possible) or some other solution that does not violate DRY. Perhaps I have designed this all wrong, is there a way to pass in entities to JSF pages? thanks.
has title: How can I pass a dynamic backing bean into a JSF 2.0 page using facelets?
upvote count: 1
accepted answer: http://stackoverflow.com/a/2684149
type: AnsweredQuestion
tagged with: facelets
tagged with: jsf
tagged with: java
type: Question
answer count: 1
downvote count: 0

http://stackoverflow.com/a/73532751
type: Answer
has comment: http://stackoverflow.com/comment/129953029
has body: I'm using a function like this where I pass the get string result into it so I don't have to constantly check null and it either returns the string you passed back or empty if it's null: public static String safeGet(String str) { try { if (str == null) throw new Exception(); return &quot;&quot; + str; } catch (Exception e) { return &quot;&quot;; } }
answers question: http://stackoverflow.com/q/2601978
score: 0

http://stackoverflow.com/comment/2728079
has text: Thomas I hope you are always around when I have encryption problems! That absolutely fixed the problem. laz - RSACryptoServiceProvider.KeyExchangeAlgorithm is the property you set. The default ( as Thomas Pornin pointed out ) is "RSA-PKCS1-KeyEx".
comment on: http://stackoverflow.com/a/2699032
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/2716391
has answer: http://stackoverflow.com/a/10122579
type: AnsweredQuestion
upvote count: 9
tagged with: java
has answer: http://stackoverflow.com/a/2716506
score: 9
type: Question
has answer: http://stackoverflow.com/a/2718758
downvote count: 0
accepted answer: http://stackoverflow.com/a/2718758
favorite count: 0
has title: Is there a mechanism to distribute an app with its own JRE?
tagged with: software-distribution
possible better answer: http://stackoverflow.com/a/2716506
has comment: http://stackoverflow.com/comment/2744317
answer count: 4
tagged with: distribution
has answer: http://stackoverflow.com/a/3364217
has body: These fine folks are my users: http://www.youtube.com/watch?v=o4MwTvtyrUQ If you don't want to enjoy the video here is the gist: my users can't tell between a file and a folder, between a browser and a web site. I need to create a Java web app (Tomcat or Jetty) and deploy it in as many of their computers, Windows and Mac. The question is: Is there a mechanism to distribute an app with its own JRE? (in the Tcl world there are starpacks and starkits, in the Python world there's py2exe and others, that's the idea). And also, is it legal? I know the VM is open source but I'm not clear about the libraries, and I know about GNU Classpath but I don't know if all the packages are there. I don't want to depend on the installed JRE or on the user having enough privileges to install one. On the Mac I don't want to depend on Apple (I had to switch from Tiger to Snow Leopard just to have Java 1.6, I can't put my users in that position) Any info greatly appreciated. Thanks! jb edit: I'm wondering if I can just paste the JRE folder under my app folder. Is that allowed?

http://stackoverflow.com/a/2761241
has body: Why not use Composition instead of Inheritance? class ABetterA { private A a; public ABetterA() { } // write wrapper methods calling class' A methods and maybe doing something more } This way, you could also mimic multiple inheritance...
type: Answer
upvote count: 2
score: 2
answers question: http://stackoverflow.com/q/2761172
downvote count: 0

http://stackoverflow.com/comment/13242602
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/3751841
has text: Thank you for your comment. I actually discovered the solution shortly after writing this question. As a specific example to answer this question I'm including a sample log4j.xml file that will disable the logging in the 3rd party jboss weld jar.

http://stackoverflow.com/a/2633234
score: 0
has comment: http://stackoverflow.com/comment/2646833
type: Answer
has body: What's the point ? Whichever technology you choose, the executable file won't be more than a few kilobytes (not including resources such as images). Nowadays, hard drives have gigabytes of storage and Internet connections can transfer several megabytes per second. You could worry about a big app (say, more than 50 or 100 MB), but in your case it just doesn't make sense...
has comment: http://stackoverflow.com/comment/2647133
upvote count: 1
downvote count: 1
answers question: http://stackoverflow.com/q/2633185
has comment: http://stackoverflow.com/comment/2646821

http://stackoverflow.com/comment/78442939
type: QuestionComment
has text: @J.F.Sebastian Well OP is not asking for the IPC with the most functionality, he is asking for what is the fastest (lowest latency) IPC.
type: Comment
comment on: http://stackoverflow.com/q/2635272
score: 0

http://stackoverflow.com/comment/2706776
score: 0
type: Comment
has text: In that case make it an instance variable of the enclosing class. Non-static inner classes can access the members of the enclosing class (and vice versa). See http://java.sun.com/docs/books/tutorial/java/javaOO/nested.html
comment on: http://stackoverflow.com/a/2679039
type: AnswerComment

http://stackoverflow.com/a/2687190
score: 7
type: Answer
upvote count: 7
has comment: http://stackoverflow.com/comment/123680107
answers question: http://stackoverflow.com/q/2687121
has comment: http://stackoverflow.com/comment/2709811
has body: I'm using 2 PU in stateless EJB and each of them is invoked on one method Indeed. But you're calling the second method from the first one so you're doing a distributed transaction and you need to use XA for this (at least for one of the resource since GlassFish supports the last agent optimization allowing to involve one non-XA resource). In other words, setting one of your datasource as a XADataSource is the way to go. If you get an error when doing this, please add details about what you did exactly and the stacktrace.
downvote count: 0

http://stackoverflow.com/comment/2729058
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2704455
has text: @igouy: well, I'm pretty sure that there's an intention gccgo will do garbage collection, which currently it doesn't. There are still some features to go into the g compilers too, for instance they don't currently use host threads particularly well (specifically, the goroutine scheduler isn't pre-emptive). Beyond that, I don't know Google's plans, whether the g compilers will ever be fiercely optimising, or if only gccgo will.

http://stackoverflow.com/comment/21427212
score: 0
type: AnswerComment
type: Comment
has text: Were you able to figure something out for the choppiness?
comment on: http://stackoverflow.com/a/2727775

http://stackoverflow.com/a/50785820
answers question: http://stackoverflow.com/q/2638200
type: Answer
upvote count: 4
has body: For the latest version of lucene 7.3.1 // Test the tokenizer Analyzer testAnalyzer = new CJKAnalyzer(); String testText = "Test Tokenizer"; TokenStream ts = testAnalyzer.tokenStream("context", new StringReader(testText)); OffsetAttribute offsetAtt = ts.addAttribute(OffsetAttribute.class); try { ts.reset(); // Resets this stream to the beginning. (Required) while (ts.incrementToken()) { // Use AttributeSource.reflectAsString(boolean) // for token stream debugging. System.out.println("token: " + ts.reflectAsString(true)); System.out.println("token start offset: " + offsetAtt.startOffset()); System.out.println(" token end offset: " + offsetAtt.endOffset()); } ts.end(); // Perform end-of-stream operations, e.g. set the final offset. } finally { ts.close(); // Release resources associated with this stream. } Reference: https://lucene.apache.org/core/7_3_1/core/org/apache/lucene/analysis/package-summary.html
downvote count: 0
score: 4

http://stackoverflow.com/a/2598254
has comment: http://stackoverflow.com/comment/2607419
has comment: http://stackoverflow.com/comment/51324819
has comment: http://stackoverflow.com/comment/90556473
has comment: http://stackoverflow.com/comment/51348304
score: 20
has body: Most likely the reason for this is because iterators are not reusable; you need to get a fresh Iterator from the Iterable collection each time you want to iterate over the elements. However, as a quick fix: private static &lt;T&gt; Iterable&lt;T&gt; iterable(final Iterator&lt;T&gt; it){ return new Iterable&lt;T&gt;(){ public Iterator&lt;T&gt; iterator(){ return it; } }; } //.... { // ... // Now we can use: for ( X x : iterable(it) ){ // do something with x } // ... } //.... That said, the best thing to do is simply pass around the Iterable&lt;T&gt; interface instead of Iterator&lt;T&gt;
has comment: http://stackoverflow.com/comment/51365311
upvote count: 20
downvote count: 0
answers question: http://stackoverflow.com/q/2598219
has comment: http://stackoverflow.com/comment/6794165
type: Answer
has comment: http://stackoverflow.com/comment/2606850
has comment: http://stackoverflow.com/comment/2606824

http://stackoverflow.com/comment/2790286
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2729607
score: 1
has text: This was the simplest and easiest solution to my problem. I had made an early mistake by extending Swing components and letting Guice instantiating them. After switching to composition, i.e. building services which reference Swing components and having them created explicitly in EDT everything went fine. Application behaves more responsive and there are no more UI glitches. TIP: Substance look and feel is a great tool for testing if Swing code is used outside of EDT.

http://stackoverflow.com/comment/2849500
score: 2
has text: Thanks for the hint. Actually I just needed to add a timer task which will just fetch a property from configuration file, this action will automatically trigger FileChangedReloadingStrategy+ConfigurationListener.
type: AnswerComment
comment on: http://stackoverflow.com/a/2731448
type: Comment

http://stackoverflow.com/comment/2679293
has text: This is a very useful page to learn regex: http://www.zytrax.com/tech/web/regex.htm
comment on: http://stackoverflow.com/q/2661849
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/23441974
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2699273
has text: Thanks - still wouldn't the answer be more complete if you caught the close() exception and log it ?
type: AnswerComment

http://stackoverflow.com/a/2741329
type: Answer
downvote count: 0
has body: As of 1.6, ResultSet has an isClosed method. I'm assuming your exception is happening on a ResultSet. That being said, I agree with the other answers that if you are seeing your ResultSet close out from under you, you likely have a flaw in your usage and just testing for isClosed isn't going to help you get out of that problem - you will just find that it is closed when you need it to be open.
score: 1
has comment: http://stackoverflow.com/comment/2770920
upvote count: 1
answers question: http://stackoverflow.com/q/2741276
has comment: http://stackoverflow.com/comment/2770299

http://stackoverflow.com/a/65542799
has body: You can use this implementation that ExecutorService provides invokeAll(Collection&lt;? extends Callable&lt;T&gt;&gt; tasks,long timeout, TimeUnit unit) as executor.invokeAll(Arrays.asList(task), 2 , TimeUnit.SECONDS); However, in my case, I could not as Arrays.asList took extra 20ms.
score: 0
answers question: http://stackoverflow.com/q/2758612
type: Answer

http://stackoverflow.com/a/20821556
type: Answer
answers question: http://stackoverflow.com/q/2739392
has body: You need to override hashCode() function as well since you are using HashSet in edges. Otherwise, it will raise unexpected bugs. EXP: Add two instances with same from and to into the hashset. The 2nd one won't be overritten without hashCode() which it's supposed to be overwritten.
score: 0

http://stackoverflow.com/comment/2799737
has text: It looks good, but it's not exactly what I'm looking for. I edited my question in order to be more accurate. Thanks.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2766981
type: Comment

http://stackoverflow.com/comment/2695608
type: Comment
comment on: http://stackoverflow.com/a/2669451
type: AnswerComment
has text: Sometimes I wish I had a DBA. It's just me. :) I'm using hsqldb as my database, and these are actually images (not text). The InputStream idea is interesting though: can you point me to a tutorial or something I can read to get me started?
score: 0

http://stackoverflow.com/a/2774526
has comment: http://stackoverflow.com/comment/2809406
type: Answer
has comment: http://stackoverflow.com/comment/2813486
has body: Neither of these is supported in C#. Covariant returns are also not supported in the underlying runtime (the CLR). It appears that it may be possible to do something along the lines of your property example on the CLR, but not in C#. Under the hood, a property essentially consists of a name, the property type, and references to the getter and setter methods (as applicable), which are typically named get_&lt;Property&gt; and set_&lt;Property&gt; (but which are not required to follow that convention in non-CLS-compliant classes). It is possible to create a property in a base class which has only a getter, and then another property in the derived class with the same name and getter, but which has its own setter. However, I don't know that any .NET languages allow such a definition.
answers question: http://stackoverflow.com/q/2771669
score: 0

http://stackoverflow.com/a/2774256
type: Answer
has comment: http://stackoverflow.com/comment/2808841
has comment: http://stackoverflow.com/comment/2808238
has body: I want to copy this ArrayList.toString() into my editor to build a test against this edge case If at all you are copying, can't you just copy values omitting the square brackets and call an Arrays.asList(...) ?
score: 0
answers question: http://stackoverflow.com/q/2774142
has comment: http://stackoverflow.com/comment/2808192

http://stackoverflow.com/comment/2698972
type: AnswerComment
has text: erm that's nice but I'm running the entire app of one class
type: Comment
score: 0
comment on: http://stackoverflow.com/a/2679301

http://stackoverflow.com/q/2602048
has title: Read-only view of a Java list with more general type parameter
has comment: http://stackoverflow.com/comment/2611548
has answer: http://stackoverflow.com/a/2602788
possible better answer: http://stackoverflow.com/a/2602111
answer count: 4
has answer: http://stackoverflow.com/a/2602086
score: 1
upvote count: 1
has body: Suppose I have class Foo extends Superclass. I understand why I can't do this: List&lt;Foo&gt; fooList = getFooList(); List&lt;Superclass&gt; supList = fooList; But, it would seem reasonable for me to do that if supList were somehow "read-only". Then, everything would be consistent as everything that would come out of an objList would be a Foo, which is a Superclass. I could probably write a List implementation that would take an underlying list and a more general type parameter, and would then return everything as the more general type instead of the specific type. It would work like the return of Collections.unmodifiableList() except that the type would be made more general. Is there an easier way? The reason I'm considering doing this is that I am implementing an interface that requires that I return an (unmodifiable) List&lt;Superclass&gt;, but internally I need to use Foos, so I have a List&lt;Foo&gt;. I can't just cast.
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/252055
has comment: http://stackoverflow.com/comment/2611412
tagged with: java
accepted answer: http://stackoverflow.com/a/2602788
linked to: http://stackoverflow.com/q/251298
type: Question
downvote count: 0
tagged with: generics
favorite count: 0
has answer: http://stackoverflow.com/a/2602090
has answer: http://stackoverflow.com/a/2602111

http://stackoverflow.com/comment/2706405
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2681908
has text: @Tom, Why does a good function have only one exit?
type: Comment

http://stackoverflow.com/q/2724063
has body: I am developing a Java Desktop Application and designing the GUI with the help of Netbeans Swing GUI builder. I want to use a JSpinner in my app. I have dragged and dropped it to a JPanel. Now, I want to set its two properties: First, It should display numbers in the range of 1 to 50. Neither less than 1 nor greater than 50. How can I set that range? Second, when I try to get the value of it by spinner.getValue() it returns an Object. As my spinner's data type is Integer, would it be better to downcast the Object into Integer or Is there any other way to get that numeric value?
score: 3
possible better answer: http://stackoverflow.com/a/2724113
has answer: http://stackoverflow.com/a/2724113
has answer: http://stackoverflow.com/a/2724132
has title: Java Swing - Problem in JSpinner
tagged with: user-interface
downvote count: 0
tagged with: spinner
has answer: http://stackoverflow.com/a/4178951
favorite count: 0
has answer: http://stackoverflow.com/a/2724144
answer count: 5
has answer: http://stackoverflow.com/a/2724232
type: AnsweredQuestion
tagged with: jspinner
upvote count: 3
tagged with: java
tagged with: swing
type: Question
accepted answer: http://stackoverflow.com/a/2724144

http://stackoverflow.com/a/7796833
has comment: http://stackoverflow.com/comment/71707500
downvote count: 0
has comment: http://stackoverflow.com/comment/9652400
upvote count: 30
has body: Well, the easiest way would be to just use the Capture in the IAnswer implementation... when doing this inline you have to declare it final of course. MyService mock = createMock(MyService.class); final Capture&lt;ParamAndReturnType&gt; myCapture = new Capture&lt;ParamAndReturnType&gt;(); expect(mock.someMethod(capture(myCapture))).andAnswer( new IAnswer&lt;ParamAndReturnType&gt;() { @Override public ParamAndReturnType answer() throws Throwable { return myCapture.getValue(); } } ); replay(mock) This is probably the most exact way, without relying on some context information. This does the trick for me every time.
type: Answer
score: 30
answers question: http://stackoverflow.com/q/2667172

http://stackoverflow.com/comment/4174546
type: AnswerComment
has text: The problem with attempting to rely on setFetchSize(int) is that you are required to stay connected as you do the fetching. Pagination might take minutes (as users navigate back and fort). Holding a connection for that long is just not reasonable. Using (vendor-specific) SQL syntax for limiting/scoping the result is more scalable. Pull a connection from the pool and exec a paginating SQL statement (parameterized to *where* it is in the pagination), return the connection to the pool and display the results. If the user navigates away, re-parameterize the SQL statement and repeat.
type: Comment
comment on: http://stackoverflow.com/a/3006053
score: 1

http://stackoverflow.com/a/2605990
has comment: http://stackoverflow.com/comment/2616104
has comment: http://stackoverflow.com/comment/139601641
has comment: http://stackoverflow.com/comment/2616108
type: AcceptedAnswer
upvote count: 19
type: Answer
has body: Pass the HttpServletResponse to your action method and set the content type there: public String yourAction(HttpServletResponse response) { response.setContentType("application/json"); }
downvote count: 0
answers question: http://stackoverflow.com/q/2605976
score: 19
accepted answer of: http://stackoverflow.com/q/2605976
has comment: http://stackoverflow.com/comment/2616060

http://stackoverflow.com/comment/124738343
has text: As @GerardBosch mentioned, this is *not* same as BOM approach. In BOM approach, the BOM POM declares managed dependencies which are then imported into a project POM using the special `scope` called `import` and then the project needs to further declare them as direct dependencies. The above approach brings in all required dependencies transitively and would be considered an anti-pattern and not advisable as a generic alternative to BOM.
type: Comment
type: AnswerComment
score: 2
comment on: http://stackoverflow.com/a/19931136

http://stackoverflow.com/a/2774916
has body: I figured it out.... public class CustomerResource extends ServerResource { @Get("xml") public Representation toXml() throws ResourceException, Exception { try { //get param from request getQuery().getValues("userId") //call DAO with parameter } catch(Exception e) { throw e; } } }
score: 31
has comment: http://stackoverflow.com/comment/3067903
answers question: http://stackoverflow.com/q/2773626
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/41042024
type: Answer
accepted answer of: http://stackoverflow.com/q/2773626
upvote count: 31

http://stackoverflow.com/q/2775687
answer count: 1
downvote count: 0
favorite count: 0
type: AnsweredQuestion
score: 2
tagged with: fonts
has body: My release script produces images of the version number to save me the trouble of manually going into the MoinMoin wiki software and changing it by hand for each release. Unfortunately, since the fonts look a little different on each platform's JVM, the result is ugly. I solved the the font inconsistency by using Lucide Sans (comes with every Java system). (Loading Fonts from TTF files is another option.) The result is much better, producing the exact same image on Mac/Windows (http://img718.imageshack.us/img718/9089/winq.png), but a slightly different one on OpenJDK (http://img441.imageshack.us/img441/4247/openjdk.png). I believe this is caused by OpenJDK having a different font rendering system (as opposed to different fonts). Is there any way I can get all three of my target platforms (Sun Windows, Mac, OpenJDK Linux) to produce images of text that look identical? [Update: ugly link is no longer ugly since am correcting things by hand until I can find an automatic solution]
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/2795773
accepted answer: http://stackoverflow.com/a/2795773
upvote count: 2
has title: producing pixel-identical images of text between Sun Java and OpenJDK

http://stackoverflow.com/comment/2758656
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/2726182
type: Comment
has text: @James B: Couldn't agree more. An IDE is great while you are able to work at its level, but when something goes wrong under the covers ...

http://stackoverflow.com/a/2662342
has body: Generics are only a compile-time concept in order to increase type-safety. You can't use them to filter the values added to a collection at run-time. You have to do the filtering manually (using instanceOf, for example) For example this would work and will let you add a Date: List&lt;String&gt; list = new ArrayList&lt;String&gt;(); ((List) list).add(new Date()); So the solution to your (yet-unseen by us) problem is not to use the raw type when adding elements.
type: Answer
answers question: http://stackoverflow.com/q/2662333
upvote count: 4
has comment: http://stackoverflow.com/comment/2679751
downvote count: 0
has comment: http://stackoverflow.com/comment/2679760
score: 4
has comment: http://stackoverflow.com/comment/2679748
has comment: http://stackoverflow.com/comment/2679724
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2679815
accepted answer of: http://stackoverflow.com/q/2662333

http://stackoverflow.com/q/2727698
has comment: http://stackoverflow.com/comment/2754914
favorite count: 0
has comment: http://stackoverflow.com/comment/2755281
has answer: http://stackoverflow.com/a/2727733
has answer: http://stackoverflow.com/a/2727719
has body: I have a class Movie in it i have a start Date, a duration and a stop Date. Start and stop Date are Date Objects (private Date startDate ...) (It's an assignment so i cant change that) now I want to automatically calculate the stopDate by adding the duration (in min) to the startDate. By my knowledge working with the time manipulating functions of Date is deprecated hence bad practice but on the other side i see no way to convert the Date object to a calendar object in order to manipulate the time and reconvert it to a Date object. Is there a way? And if there is what would be best practice
has answer: http://stackoverflow.com/a/2727716
has answer: http://stackoverflow.com/a/51384423
has answer: http://stackoverflow.com/a/67599551
accepted answer: http://stackoverflow.com/a/2727735
possible better answer: http://stackoverflow.com/a/2727719
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/65463825
tagged with: calendar
linked to: http://stackoverflow.com/q/6185966
type: Question
answer count: 8
linked to: http://stackoverflow.com/q/36639154
has answer: http://stackoverflow.com/a/39057364
upvote count: 69
linked to: http://stackoverflow.com/q/38922754
tagged with: date
has title: Date object to Calendar [Java]
has answer: http://stackoverflow.com/a/2727735
has answer: http://stackoverflow.com/a/2727746
score: 69
downvote count: 0
linked to: http://stackoverflow.com/q/6905288

http://stackoverflow.com/q/2681759
has body: Artifacts from dependencies can be excluded by declaring an element inside a But in this case it's needed to exclude an artifact inherited from a parent project. An excerpt of the POM under discussion follows: 4.0.0 test jruby 0.0.1-SNAPSHOT base es.uniovi.innova 1.0.0 com.liferay.portal ALL-DEPS 1.0 provided pom base artifact, depends on javax.mail:mail-1.4.jar, and ALL-DEPS depends on another version of the same library. Due to the fact that mail.jar from ALL-DEPS exist on the execution environment, although not exported, collides with the mail.jar that exists on the parent, which is scoped as compile. A solution could be to rid off mail.jar from the parent POM, but most of the projects that inherit base, need it (as is a transtive dependency for log4j). So What I would like to do is to simply exclude parent's library from the child project, as it could be done if base was a dependency and not the parent pom: ... base es.uniovi.innova 1.0.0 pom javax.mail mail ...
has title: Is there anyway to exclude artifacts inherited from a parent POM?
has comment: http://stackoverflow.com/comment/130062118
tagged with: pom.xml
has answer: http://stackoverflow.com/a/77360128
score: 176
tagged with: maven-2
has answer: http://stackoverflow.com/a/13128748
upvote count: 176
answer count: 12
has answer: http://stackoverflow.com/a/66152824
has answer: http://stackoverflow.com/a/2686464
has answer: http://stackoverflow.com/a/37676239
possible better answer: http://stackoverflow.com/a/19931136
has answer: http://stackoverflow.com/a/2684291
tagged with: maven
has answer: http://stackoverflow.com/a/19931136
type: Question
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/59214817
accepted answer: http://stackoverflow.com/a/2684291
has answer: http://stackoverflow.com/a/70393506
has answer: http://stackoverflow.com/a/48103554
tagged with: java
has answer: http://stackoverflow.com/a/55970293
has answer: http://stackoverflow.com/a/47933295
downvote count: 0
favorite count: 0

http://stackoverflow.com/a/12646465
score: 6
answers question: http://stackoverflow.com/q/2691235
downvote count: 0
upvote count: 6
has comment: http://stackoverflow.com/comment/17545834
has body: I've also been searching for an answer/example, but found nowhere working code. Finally, here's the code that's working for me: MyMapActivity.java public class MyMapActivity extends MapActivity implements OnGestureListener, OnDoubleTapListener { private MapView mapView; @Override public void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.main); mapView = (MapView)findViewById(R.id.mapView); } @Override public boolean onDoubleTap(MotionEvent e) { int x = (int)e.getX(), y = (int)e.getY();; Projection p = mapView.getProjection(); mapView.getController().animateTo(p.fromPixels(x, y)); mapView.getController().zoomIn(); return true; } // Here will be some autogenerated methods too OnDoubleTap.java public class OnDoubleTap extends MapView { private long lastTouchTime = -1; public OnDoubleTap(Context context, AttributeSet attrs) { super(context, attrs); } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_DOWN) { long thisTime = System.currentTimeMillis(); if (thisTime - lastTouchTime &lt; ViewConfiguration.getDoubleTapTimeout()) { // Double tap this.getController().zoomInFixing((int) ev.getX(), (int) ev.getY()); lastTouchTime = -1; } else { // Too slow lastTouchTime = thisTime; } } return super.onInterceptTouchEvent(ev); } } main.xml &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;azizbekyan.andranik.map.OnDoubleTap android:id="@+id/mapView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:enabled="true" android:clickable="true" android:apiKey="YOUR_API_KEY" /&gt; &lt;/LinearLayout&gt; Don't forget to replace here the android:apiKey value with your apiKey.
type: Answer

http://stackoverflow.com/q/2619643
type: Question
accepted answer: http://stackoverflow.com/a/2620619
has answer: http://stackoverflow.com/a/2619688
upvote count: 0
score: -2
has body: $ javac InitInt.java InitInt.java:7: variable right might not have been initialized InitInt(){} ^ 1 error $ cat InitInt.java import java.util.*; import java.io.*; public class InitInt { private final int right; // Design Problem? // I feel the initialization problem is just due to bad style. InitInt(){} InitInt{ // Still the error, "may not be initialized" // How to initialise it? if(snippetBuilder.length()&gt;(charwisePos+25)){ right=charwisePos+25; }else{ right=snippetBuilder.length()-1; } } public static void main(String[] args) { InitInt test = new InitInt(); System.out.println(test.getRight()); } public int getRight(){return right;} } Partial Solutions and Suggestions use "this" to access methods in the class, instead of creating empty constructor change final to non-final with final field value: initialize all final values in every constructor remove the empty constructor, keep your code simple and clean
answer count: 6
has comment: http://stackoverflow.com/comment/2635313
has answer: http://stackoverflow.com/a/2622298
has answer: http://stackoverflow.com/a/2620619
has answer: http://stackoverflow.com/a/2619654
tagged with: initialization
favorite count: 0
possible better answer: http://stackoverflow.com/a/2619671
tagged with: constructor
has comment: http://stackoverflow.com/comment/2634818
has title: Java: design problem with final-value and empty constructor
tagged with: design-patterns
has answer: http://stackoverflow.com/a/2619649
type: AnsweredQuestion
tagged with: java
downvote count: 2
has answer: http://stackoverflow.com/a/2619671

http://stackoverflow.com/comment/2751534
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2722434
type: AnswerComment
has text: @BalusC: Thanks for the edit! You realized I was too lazy ;) Are you German, by chance? s/I was so free to edit/I took the liberty of editing/

http://stackoverflow.com/q/2698086
has comment: http://stackoverflow.com/comment/2720534
upvote count: 6
type: AnsweredQuestion
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/2698181
has comment: http://stackoverflow.com/comment/2720616
has body: At work, we are developing an PHP application that would be later re-programmed into Java. With some basic knowledge of Java, we are trying to design everything to be easily re-written, without any headaches. Interesting problem came out when we tried to implement composite pattern with huge number of methods in leafs. What are we trying to achieve (not using interfaces, it's just a quick example): class Composite { ... } class LeafOne { public function Foo( ); public function Moo( ); } class LeafTwo { public function Bar( ); public function Baz( ); } $c = new Composite( Array( new LeafOne( ), new LeafTwo( ) ) ); // will call method Foo in all classes in composite that contain this method $c-&gt;Foo( ); // same with Bar $c-&gt;Bar( ); It seems like pretty much classic Composite pattern, but problem is that we will have quite many leaf classes and each of them might have ~5 methods (of which few might be different than others). One of our solutions, which seems to be the best one so far and might actually work, is using __call magic method to call methods in leafs. Unfortunately, we don't know if there is an equivalent of it in Java. So the actual question is: Is there a better solution for this, using code that would be eventually easily re-coded into Java? Or do you recommend any other solution? Perhaps there's some different, better pattern I could use here. In case there's something unclear, just ask and I'll edit this post. Edit: Actual problem is that not every leaf class contains, for example, method Baz. If we used simple foreach to call Baz in every class, it'd give use bunch of errors, as there are certain classes that don't contain this method. Classic solution would be to have every single method from every single leaf class implemented into Composite class, each with different implementation. But this would make our composite class huge and messy with amount of methods we use. So usual solution would look like this (Composite class): class Composite impl…
has title: Multiple leaf methods problem in composite pattern
answer count: 2
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/2720582
has answer: http://stackoverflow.com/a/2698181
possible better answer: http://stackoverflow.com/a/2698381
score: 6
tagged with: php
has answer: http://stackoverflow.com/a/2698381
tagged with: design-patterns

http://stackoverflow.com/a/32515408
score: 19
has comment: http://stackoverflow.com/comment/86192880
has body: I've created a project that can build much advanced table views. If you supposed to print the table, the width of the table going to have a limit. I have applied it in one of my own project to get a customer invoice print. Following is an example of the print view. PLATINUM COMPUTERS(PVT) LTD NO 20/B, Main Street, Kandy, Sri Lanka. Land: 812254630 Mob: 712205220 Fax: 812254639 CUSTOMER INVOICE +-----------------------+----------------------+ |INFO |CUSTOMER | +-----------------------+----------------------+ |DATE: 2015-9-8 |ModernTec Distributors| |TIME: 10:53:AM |MOB: +94719530398 | |BILL NO: 12 |ADDRES: No 25, Main St| |INVOICE NO: 458-80-108 |reet, Kandy. | +-----------------------+----------------------+ | SELLING DETAILS | +-----------------+---------+-----+------------+ |ITEM | PRICE($)| QTY| VALUE| +-----------------+---------+-----+------------+ |Optical mouse | 120.00| 20| 2400.00| |Gaming keyboard | 550.00| 30| 16500.00| |320GB SATA HDD | 220.00| 32| 7040.00| |500GB SATA HDD | 274.00| 13| 3562.00| |1TB SATA HDD | 437.00| 11| 4807.00| |RE-DVD ROM | 144.00| 29| 4176.00| |DDR3 4GB RAM | 143.00| 13| 1859.00| |Blu-ray DVD | 94.00| 28| 2632.00| |WR-DVD | 122.00| 34| 4148.00| |Adapter | 543.00| 28| 15204.00| +-----------------+---------+-----+------------+ | RETURNING DETAILS | +-----------------+---------+-----+------------+ |ITEM | PRICE($)| QTY| VALUE| +-----------------+---------+-----+------------+ |320GB SATA HDD | 220.00| 4| 880.00| |WR-DVD | 122.00| 7| 854.00| |1TB SATA HDD | 437.00| 7| 3059.00| |RE-DVD ROM | 144.00| 4| 576.00| |Gaming keyboard | 550.00| 6| 3300.00| |DDR3 4GB RAM | 143.00| 7| 1001.00| +-----------------+---------+-----+------------+ GROSS 59,928.00 DISCOUNT(5%) 2,996.40 RETURN 9,670.00 PAYABLE 47,261.60 CASH 20,000.00 CHEQUE 15,000.00 CREDIT(BALANCE) 12,261.60 --------------------- --------------------- CASH COLLECTOR GOODS RECEIVED BY soulution by clough.com This is the code for above print view and you can find the library (Wagu) in her…
has comment: http://stackoverflow.com/comment/86221879
has comment: http://stackoverflow.com/comment/86058695
has comment: http://stackoverflow.com/comment/57814982
upvote count: 19
has comment: http://stackoverflow.com/comment/57811377
has comment: http://stackoverflow.com/comment/69187038
has comment: http://stackoverflow.com/comment/86052261
has comment: http://stackoverflow.com/comment/69066335
downvote count: 0
answers question: http://stackoverflow.com/q/2745206
has comment: http://stackoverflow.com/comment/57809386
has comment: http://stackoverflow.com/comment/57784981
type: Answer
has comment: http://stackoverflow.com/comment/57791846

http://stackoverflow.com/a/2646854
has comment: http://stackoverflow.com/comment/2663405
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2646773
answers question: http://stackoverflow.com/q/2646773
has comment: http://stackoverflow.com/comment/2666539
has comment: http://stackoverflow.com/comment/2663626
type: Answer
has comment: http://stackoverflow.com/comment/2662659
has comment: http://stackoverflow.com/comment/2665517
has comment: http://stackoverflow.com/comment/2664045
upvote count: 9
has body: Please don't use a regex for this simple task. // If the last ) might not be the last character of the String String s = "Your String with) multiple)."; StringBuilder sb = new StringBuilder(s); sb.deleteCharAt(s.lastIndexOf(')')); s = sb.toString(); // s = "Your String with) multiple." // If the last ) will always be the last character of the String s = "Your String with))"; if (s.endsWith(")")) s = s.substring(0, s.length() - 1); // s = "Your String with)"
score: 9

http://stackoverflow.com/a/2762221
type: Answer
upvote count: 1
downvote count: 1
answers question: http://stackoverflow.com/q/2762171
has comment: http://stackoverflow.com/comment/2794412
has comment: http://stackoverflow.com/comment/2794534
has body: Since in a method, the arguments the references of objects are passed by value, couldn't you do something along the lines of: import java.awt.Point; public class Example { public static void main(String args[]) { Point pnt1 = new Point(0, 0); Point pnt2 = new Point(0, 0); System.out.println("X: " + pnt1.x + " Y: " + pnt1.y); System.out.println("X: " + pnt2.x + " Y: " + pnt2.y); System.out.println(" "); sillyMethod(pnt1, pnt2); System.out.println("X: " + pnt1.x + " Y: " + pnt1.y); System.out.println("X: " + pnt2.x + " Y: " + pnt2.y); } public static void sillyMethod(Point arg1, Point arg2) { arg1.x = 100; arg1.y = 100; arg2.x = 200; arg2.y = 200; } } This way, you are changing the values of the objects, without returning diverging types.
score: 0

http://stackoverflow.com/a/2690754
accepted answer of: http://stackoverflow.com/q/2690635
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2690635
has body: I found a way: http://texblog.wordpress.com/2008/04/02/include-source-code-in-latex-with-listings/ although, this way the code seems to run off the page..
type: Answer
upvote count: 1
score: 1

sqlite
tags question: http://stackoverflow.com/q/2623392
tags question: http://stackoverflow.com/q/2743167
tags question: http://stackoverflow.com/q/2743872
tags question: http://stackoverflow.com/q/2624665
type: Tag
tags question: http://stackoverflow.com/q/2738029
tags question: http://stackoverflow.com/q/2622995
tags question: http://stackoverflow.com/q/2605555
tags question: http://stackoverflow.com/q/2714326
tag name: sqlite

http://stackoverflow.com/comment/95804213
has text: @BasilBourque I meant cannot modify the list's structure by addition/deletion but can change the elements.
comment on: http://stackoverflow.com/a/34428978
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/2629922
has answer: http://stackoverflow.com/a/2630496
has comment: http://stackoverflow.com/comment/2650404
has body: There's plenty of information on running Java apps as services, but I need to know how to detect whether a windows service is running or not. Does anyone know how??? At the DOS prompt, I can run: tasklist /svc|findstr "NonRunningService" echo Return code for N onRunningService is %ERRORLEVEL% tasklist /svc|findstr "RunningService" echo Return code for RunningService is %ERRORLEVEL% I get the following: Return code for NonRunningService is 1 Return code for RunningService is 0 In code, I have: int retCode = Runtime.getRuntime.exec("tasklist /svc|findstr \"NonRunningService\"").waitFor(); System.out.println("Return code for NonRunningService is " + retCode); retCode = Runtime.getRuntime.exec("tasklist /svc|findstr \"RunningService\"").waitFor(); System.out.println("Return code for RunningService is " + retCode); I get the following output Return code for NonRunningService is 1 Return code for RunningService is 1 According to the JavaDocs, the waitFor() should block until the process finishes, and give me the exit value of the process. I've also tried using the Process/ProcessBuilder command line calls: //'tasklist /nh /fi "SERVICES eq RunningService"' will return a line for // each running service of the requested type. Process p1 = new ProcessBuilder("tasklist", "/nh", "/fi" "SERVICES eq RunningService").start(); p1.waitFor(); BufferedReader is = new BufferedReader(new InputStreamReader(p1.getInputStream())); String line = is.readLine(); System.out.println("Service - " + line); System.out.println("Running? ", (line==null?"No":"Yes"); gives: Service - Running? No even when I get lines in the output at the command line!
possible better answer: http://stackoverflow.com/a/2630751
downvote count: 0
has answer: http://stackoverflow.com/a/2630751
accepted answer: http://stackoverflow.com/a/2630496
answer count: 4
favorite count: 0
has answer: http://stackoverflow.com/a/2630361
has answer: http://stackoverflow.com/a/2629971
type: AnsweredQuestion
has title: Does anyone know how to detect whether a Windows Service is running through Java
score: 3
upvote count: 3
tagged with: java
has comment: http://stackoverflow.com/comment/2643113
tagged with: windows-services
type: Question

http://stackoverflow.com/comment/2813113
comment on: http://stackoverflow.com/a/2774070
score: 0
type: Comment
type: AnswerComment
has text: Thanks alot.. I got some thing.. I would like to know how can we verify by using fingerprints to authenticate clients. I dont want to use any third party CAs in my application. So i'm not using OpenSSL certificates. How we can authenticate clients by using Thumbprint?

http://stackoverflow.com/a/5379426
type: Answer
answers question: http://stackoverflow.com/q/2689245
has body: We had the same problem and ended up with writing a new JSF converter that uses a SimpleDateFormat created with new SimpleDateFormat(String pattern) for the date conversion.
score: 0

http://stackoverflow.com/q/2771868
upvote count: 1
has title: Can I access object from another JVM's memory without requesting that JVM?
type: Question
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/2771926
has answer: http://stackoverflow.com/a/2771992
tagged with: memory
has answer: http://stackoverflow.com/a/2771917
has answer: http://stackoverflow.com/a/2771922
linked to: http://stackoverflow.com/q/63926180
downvote count: 0
has body: Is there any way we can access other JVM's Heap memory? Will this be possible if I know the memory reference/address?
tagged with: jvm
favorite count: 0
answer count: 5
has comment: http://stackoverflow.com/comment/2805421
has answer: http://stackoverflow.com/a/2771923
type: UnansweredQuestion

http://stackoverflow.com/a/35950389
answers question: http://stackoverflow.com/q/2758654
score: 0
type: Answer
has body: I have a similar problem when reading from a socket and sending to another, but my problem was that I was writing the output with a BufferedOutputStream, when I change this to Output stream it works. I think that there is a problem with the buffer ouput stream. String mensaje ="what I want to send"; String ip = "192.168.161.165"; int port = 2042; tpSocket = new Socket(ip, port); os = tpSocket.getOutputStream(); byte[] myBytes= mensaje.getBytes(); ByteArrayInputStream byarris = new ByteArrayInputStream(myBytes); int resulta =0; byte[] bufferOutput= new byte[1]; while((resulta = byarris.read(bufferOutput))!= -1) { os.write(bufferOutput); }

http://stackoverflow.com/a/33101315
score: 1
answers question: http://stackoverflow.com/q/2642487
upvote count: 1
has body: Here is a good example about accessing packets information using Jpcap Packet
downvote count: 0
type: Answer

http://stackoverflow.com/a/52339232
type: Answer
has body: for best readability ,like it won't print 0 day or 0 hour or 0 minute. e.g- (if minute=1500,then it will print only 1 day 1 hour) int minute=150; StringBuilder sb=new StringBuilder(); int day=minute/1440; int rem=minute%1440; int hour=rem/60; int Minute=rem%60; if(day&gt;0) sb.append(day+" day "); if(hour&gt;0) sb.append(hour+" hour "); if(Minute&gt;0) sb.append(Minute+" minute"); System.out.println(sb);
answers question: http://stackoverflow.com/q/2751073
score: 0

http://stackoverflow.com/q/2749889
favorite count: 0
has answer: http://stackoverflow.com/a/2749950
has comment: http://stackoverflow.com/comment/2779981
answer count: 9
has answer: http://stackoverflow.com/a/2749911
upvote count: 10
downvote count: 1
has answer: http://stackoverflow.com/a/2770180
tagged with: python
has answer: http://stackoverflow.com/a/2750068
tagged with: c++
has answer: http://stackoverflow.com/a/2770017
has comment: http://stackoverflow.com/comment/2780686
accepted answer: http://stackoverflow.com/a/2749965
has title: Looking forward to a programming future but confused where to start
type: Question
type: AnsweredQuestion
has body: I am very new to this site and to programming. I started doing some basic programming with python a few weeks ago and recently, messing around with Java basics. My main problem is that I am completely overwhelmed and haven't got the slightest clue where I should be starting. I want to learn programming because I really enjoy doing it, the simple applications that I have managed to conjure up put a smile on my face. My plan is to eventually (by eventually I'm talking about 6 years+) go into games programming. I have been informed that C++ is the best way to go about this but haven't got the slightest clue what book/sight is optimal for someone who is still learning the very basics. These are my questions: I have been to the Definitive C++ Book Guide but am still unsure which book is best to start of with. Should I stick with Python or Java instead of moving on to C++? Is there any advice you would give to a beginner programmer? Thanks again for all your help. Edit: The book on Java I am currently using is Programming Video Games for the Evil Genius. Sadly it's riddled with errors and he doesn't go into explaining certain important commands.
has answer: http://stackoverflow.com/a/2749912
possible better answer: http://stackoverflow.com/a/2749911
has comment: http://stackoverflow.com/comment/2780601
tagged with: java
has comment: http://stackoverflow.com/comment/2779950
has answer: http://stackoverflow.com/a/2753542
has answer: http://stackoverflow.com/a/2749965
linked to: http://stackoverflow.com/q/388242
score: 9
has comment: http://stackoverflow.com/comment/2779942
has comment: http://stackoverflow.com/comment/2803519
has answer: http://stackoverflow.com/a/10661272

http://stackoverflow.com/comment/2790223
score: 0
has text: @Joachim Yes, I wasn't intending a criticism.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2758468

http://stackoverflow.com/comment/2727497
has text: It's due soon but it isnt my homework, it's one of my friends' and i'm interested in this problem, cos i don't know myself too.
comment on: http://stackoverflow.com/q/2703141
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/2622725
has text: You could also look at the value of `this` to see if it really is the same object, or whether multiple instances are being created.
comment on: http://stackoverflow.com/q/2611495
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/2678158
has comment: http://stackoverflow.com/comment/8553687
type: Answer
has body: The input size is limited to the size of the key. If you use a 1024 bit key, you are limited to 128 bytes. Typically, you are signing the digest (hash value), not the actual data.
downvote count: 1
answers question: http://stackoverflow.com/q/2678138
score: 7
has comment: http://stackoverflow.com/comment/8615015
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2678138
upvote count: 8

http://stackoverflow.com/a/2687197
score: -1
upvote count: 0
answers question: http://stackoverflow.com/q/2685293
has body: Hibernate is by far the most popular option. This is particularly nice when requiring support from a very large community. However, it also has its shortcomings -- like batch inserts. It really depends on what you're looking to do and what kind of performance you need. In general Hibernate is very fast.
type: Answer
downvote count: 1

http://stackoverflow.com/a/2735896
type: AcceptedAnswer
type: Answer
has body: set -XX:MaxHeapSize and -Xmx vm parameters
has comment: http://stackoverflow.com/comment/2764138
downvote count: 1
accepted answer of: http://stackoverflow.com/q/2735885
answers question: http://stackoverflow.com/q/2735885
score: -1
has comment: http://stackoverflow.com/comment/2764205
upvote count: 0

http://stackoverflow.com/q/2633185
has answer: http://stackoverflow.com/a/2633509
favorite count: 0
has answer: http://stackoverflow.com/a/2633210
score: 2
answer count: 9
upvote count: 2
type: UnansweredQuestion
has title: Smallest executable for Windows
has comment: http://stackoverflow.com/comment/2647056
has answer: http://stackoverflow.com/a/2633234
tagged with: air
tagged with: java
has answer: http://stackoverflow.com/a/2633392
type: Question
has comment: http://stackoverflow.com/comment/2646781
has comment: http://stackoverflow.com/comment/2646793
has answer: http://stackoverflow.com/a/2633275
downvote count: 0
tagged with: .net
has answer: http://stackoverflow.com/a/2633241
has answer: http://stackoverflow.com/a/2633462
has answer: http://stackoverflow.com/a/2633255
has body: I need to create a very simple GUI application for Windows(open a file, do some changes based on user input, upload the file to an intranet server). The client company has the latest release versions of Java SE, .NET and Adobe AIR installed on all their machines. And their #1 requirement is to have the smallest possible package for xcopy deployment. So which of the 3 listed platforms should I use? Another option of course is a native exe. Thanks, Andrew EDIT: Thanks for all answers, guys! The customer has offices in New Zealand and Australia, from what I've heard the connectivity there is very expensive and lacking. And the size requirement came from their IT operations department, which have refused to install custom apps in the past as too big for the features... I'm looking for a modern platform to develop the app in, C++ at least ;) So I'd change the question to which of the following platform will have minimal executable file size: MS VC++ 2010, .NET 4.0 or earlier, Java 1.6 or earlier, Adobe AIR 1.6 or earlier.
has answer: http://stackoverflow.com/a/2633221

http://stackoverflow.com/comment/2707255
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2663437
has text: Check http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#bnahw. As to the bookstore example, it's just an *explicit* reference to ensure that it doesn't return a "coincidental" `cart` instance in page or request scope (which are scanned *before* the session scope). This is just a "practice", but not necessary.

http://stackoverflow.com/q/2627653
answer count: 1
accepted answer: http://stackoverflow.com/a/2627702
favorite count: 0
score: 5
upvote count: 6
has title: Add DLL to NetBeans Project
tagged with: netbeans
downvote count: 1
type: AnsweredQuestion
has body: I want to add dll file into my project. But i don't know where and how to add my dll in NetBeans anyone please help me..
has answer: http://stackoverflow.com/a/2627702
tagged with: dll
tagged with: java
tagged with: import
type: Question

http://stackoverflow.com/a/2848621
type: AcceptedAnswer
downvote count: 0
has body: For an application that generates lots of short lived garbage and nothing long lived then one approach that can work is a big heap with nearly all of it young gen and nearly all of that eden and tenure anything that survives a YG collection more than once. For example (lets say you had a 32bit jvm) 3072M heap (Xms and Xmn) 128M tenured (i.e. Xmn 2944m) MaxTenuringThreshold=1 SurvivorRatio=190 (i.e. each survivor space is 1/192 of the YG) TargetSurvivorRatio=90 (i.e. fill those survivors as much as possible) The exact params you would use for this setup depend on what the steady state size of your working set is (i.e. how much is alive at the time of each collection). The thinking here obviously goes against the normal heap sizing rules but then you don't have an app that behaves in that way. The thinking is that the app is mostly v short lived garbage and a bit of static data so set the jvm up so that that static data gets into tenured quickly and then have a YG big enough that it doesn't get collected v often thus minimising the frequency of the pauses. You'd need to twiddle knobs repeatedly to work out what a good size is for you &amp; how that balances against the size of the pause you get per collection. You might find shorter but more frequent YG pauses are achieveable for example. You don't say how long your app runs for but the target here is to have no tenured collections at all for the life of the app. This may be impossible of course but it's worth aiming for. However it's not just the collection algo that is important in your case, it is where the memory is allocated. The NUMA collector (only compatible with the throughput collector and activated with UseNUMA switch) makes use of the observation that an object is often uses purely by the thread that created it &amp; thus allocates memory accordingly. I'm not sure what it is based on in linux but it uses MPO (memory placement optimisation) on Solaris, some details on one of the GC guys blogs Since you're u…
accepted answer of: http://stackoverflow.com/q/2781797
type: Answer
answers question: http://stackoverflow.com/q/2781797
score: 14
upvote count: 14

http://stackoverflow.com/a/2615837
has body: You can get all matches in a file simply by assigning inside while-loop, cool: $ javac MatchTest.java $ java MatchTest 1 16 31 46 $ cat MatchTest.java import java.util.*; import java.io.*; public class MatchTest { public static void main(String[] args){ String match = "hello"; String text = "hello0123456789hello0123456789hello1234567890hello3423243423232"; int i =0; while((i=(text.indexOf(match,i)+1))&gt;0) System.out.println(i); } }
type: Answer
has comment: http://stackoverflow.com/comment/2627453
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/2627436
answers question: http://stackoverflow.com/q/2615749
downvote count: 0

http://stackoverflow.com/a/2774410
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/2774173
has body: According to @Lord Torgamus question, here is a suggested java algorithm. Suppose you have two java Collection objects (and LinkedList, as an implementor of List, is also an implementor of Collection). To find their intersection, you only have to call Collection#retainAll method on the first object giving the second one as an argument.
type: Answer
downvote count: 0

http://stackoverflow.com/a/2670482
upvote count: 1
has body: You only want a single loop, but with indices going both ways: public int[] reverse(int[] nums) { int[] back = new int[nums.length]; int i,j; for (i=0,j=nums.length-1 ; i&lt;nums.length ; i++,j--) back[i] = nums[j]; return back; }
answers question: http://stackoverflow.com/q/2670460
downvote count: 0
score: 1
type: Answer

http://stackoverflow.com/comment/2675661
comment on: http://stackoverflow.com/a/2658594
type: AnswerComment
type: Comment
has text: I'm working with Java. This data is used to perform mathematical operations. I was wondering if there is anyway to store a matrix (16x16) in a column of the table.
score: 0

http://stackoverflow.com/comment/2631367
score: 0
type: AnswerComment
type: Comment
has text: Hmm, and I just realized you are proposing parsing the stream one byte at a time. I wonder what the performance hit of that would be; trying not to venture into premature optimization, of course.
comment on: http://stackoverflow.com/a/2619132

http://stackoverflow.com/q/2780284
answer count: 8
has answer: http://stackoverflow.com/a/2780375
tagged with: jdbc
tagged with: database-metadata
possible better answer: http://stackoverflow.com/a/16580430
has title: How to get all table names from a database?
has answer: http://stackoverflow.com/a/60056134
has answer: http://stackoverflow.com/a/16580430
tagged with: java
has answer: http://stackoverflow.com/a/41849227
has answer: http://stackoverflow.com/a/2784046
has answer: http://stackoverflow.com/a/56460483
has body: I'd like to retrieve all table names from a database schema, and, if possible, get all table starting with a specified prefix. I tried using JDBC's connection.getMetaData().getTables() but it didn't work at all. Connection jdbcConnection = DriverManager.getConnection("", "", ""); DatabaseMetaData m = jdbcConnection.getMetaData(); ResultSet tables = m.getTables(jdbcConnection.getCatalog(), null, "TAB_%", null); for (int i = 0; i &lt; tables.getMetaData().getColumnCount(); i++) { System.out.println("table = " + tables.getMetaData().getTableName(i)); } Could someone help me on this?
has answer: http://stackoverflow.com/a/22551227
score: 72
upvote count: 72
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2780375
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/69370042
type: Question

http://stackoverflow.com/comment/77083277
has text: Can you please also add the meaning of a "mappedBy" in a ManyToMany relationship? According to what you said, the real owner is an external table (which owns two references, one per side). So what's the point to put a "mappedBy" in one of the two sides?
type: AnswerComment
comment on: http://stackoverflow.com/a/21068644
score: 0
type: Comment

http://stackoverflow.com/comment/80556477
type: AnswerComment
has text: "immutability" confused me for a moment. You can obviously change the array's values. You cannot change its size, however.
type: Comment
comment on: http://stackoverflow.com/a/26076682
score: 1

http://stackoverflow.com/comment/2733342
type: Comment
has text: Wrong. He wants the outer `this`.
comment on: http://stackoverflow.com/a/2709154
type: AnswerComment
score: 0

http://stackoverflow.com/a/40729781
type: Answer
has body: Camel empowers you to define routing and mediation rules in a variety of domain-specific languages. Mule and SeriviceMix is ESB. ActiveMQ is Messaging service.
score: 2
upvote count: 2
downvote count: 0
answers question: http://stackoverflow.com/q/2705043

escaping
tags question: http://stackoverflow.com/q/2625466
type: Tag
tags question: http://stackoverflow.com/q/2644292
tag name: escaping
tags question: http://stackoverflow.com/q/2605757
tags question: http://stackoverflow.com/q/2646890

http://stackoverflow.com/a/2964326
has body: Have you tried doing it in java yourself? I tried this with (WARNING, big image, can crash your browser, use "save as...") this image. Needed to run with extra memory though (-Xmx400M). public class ImageTile { public static void main(String[] args) throws IOException { Dimension tileDim = new Dimension(250, 250); BufferedImage image = ImageIO.read(new File(args[0])); Dimension imageDim = new Dimension(image.getWidth(), image.getHeight()); for(int y = 0; y &lt; imageDim.height; y += tileDim.height) { for(int x = 0; x &lt; imageDim.width; x += tileDim.width) { int w = Math.min(x + tileDim.width, imageDim.width) - x; int h = Math.min(y + tileDim.height, imageDim.height) - y; BufferedImage tile = image.getSubimage(x, y, w, h); ImageIO.write(tile, "JPG", new File("tile-"+x+"-"+y+".jpg")); } } } }
upvote count: 4
type: AcceptedAnswer
downvote count: 0
score: 4
answers question: http://stackoverflow.com/q/2649048
type: Answer
accepted answer of: http://stackoverflow.com/q/2649048

http://stackoverflow.com/comment/2776444
score: 0
type: Comment
has text: Log4j may not be the darling of Java logging anymore, but it is still far superior to System.out/.error. Commons Logging is also being replaced and JDK logging was always a case of 'not invented here' syndrome.
comment on: http://stackoverflow.com/a/2746666
type: AnswerComment

http://stackoverflow.com/a/2752489
type: Answer
score: 4
answers question: http://stackoverflow.com/q/2752485
upvote count: 4
has body: Run using java chapter10.PropertiesTest. The Java command expects the fully qualified Java class name, not the pathname of the bytecode file. The Java command locates classes to be loaded by looking on the classpath. This is a list of directories or JAR files to be searched in order. The algorithm used is roughly as follows: Take the fully qualified name of the class, replace "." characters with the applicable file separator character (e.g. "/" or "\"), and append ".class" to the end. The result is a pathname. For each entry in the classpath, lookup the pathname relative to the entry. If the lookup succeeds, load the corresponding file. Otherwise, continue to the next classpath entry. If no lookup succeeded, throw a ClassNotFoundException. The classpath can be set using an explicit command line parameter (-cp &lt;path&gt;) or it can be picked up from a CLASSPATH environment variable. If no classpath is set by either of these methods, a default classpath of "." is assumed, where "." denotes the current directory. As @BalusC says, best practice is to use the "-cp" argument or create a wrapper script to launch your application. Relying on your shell's $CLASSPATH is a bit flakey, because you never know when it might be overridden or reset. (This is a simplified description. It does not cover "bootclasspath", classpaths set in loadable JAR files, classloading from URLs, how inner/anonymous classes are handled, etc, etc.)
downvote count: 0

http://stackoverflow.com/comment/13497014
score: 27
type: Comment
has text: -1 Because it is a terrible idea to accept all certificates. It is too bad that there are so many blogs and tutorials that happily guide Java developers along the path of doing the wrong thing.
comment on: http://stackoverflow.com/a/4837230
type: AnswerComment

http://stackoverflow.com/a/2694388
answers question: http://stackoverflow.com/q/2694281
type: AcceptedAnswer
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/2694281
score: 10
has body: Extend JEditorPane to override the getStream() method. Inside that method, you can open a URLConnection. Test whether it is an HttpsURLConnection. If it is, initialize your own SSLContext with a custom X509TrustManager that doesn't perform any checks. Get the context's SSLSocketFactory and set it as the socket factory for the connection. Then return the InputStream from the connection. This will defeat any attempts by the runtime to protect the user from a spoof site serving up malware. If that's really what you want&hellip;
upvote count: 10

http://stackoverflow.com/a/2704164
answers question: http://stackoverflow.com/q/2704151
upvote count: 0
has body: You could read the byte array and turn it into a String. The problem will be the InputStream. There's a StringBufferInputStream, but it's deprecated in favor of StringReader. byte [] b = Assets.get(); InputStream is = new StringBufferInputStream(new String(b)); Pattern.load(is);
score: -1
has comment: http://stackoverflow.com/comment/2727723
has comment: http://stackoverflow.com/comment/2727649
downvote count: 1
type: Answer

http://stackoverflow.com/comment/2694791
type: Comment
type: QuestionComment
has text: I'm guessing no one else has written such a thing. I know for a fact it's not in the standard library, as it's a highly specialized, limited use collection.
comment on: http://stackoverflow.com/q/2675929
score: 0

http://stackoverflow.com/q/2682913
has answer: http://stackoverflow.com/a/2682956
accepted answer: http://stackoverflow.com/a/2682956
has comment: http://stackoverflow.com/comment/2702625
has title: automatically generate header
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2702583
possible better answer: http://stackoverflow.com/a/2682943
has comment: http://stackoverflow.com/comment/2702579
tagged with: java
tagged with: eclipse
has comment: http://stackoverflow.com/comment/2702601
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/2702587
score: 0
has answer: http://stackoverflow.com/a/2682943
has body: I wonder if you could automatically generate header header class functions automatically for a given package (make a batch processing) ..? Thank you.

http://stackoverflow.com/a/2761256
has comment: http://stackoverflow.com/comment/2793300
score: 10
upvote count: 10
type: AcceptedAnswer
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/2761177
has body: Although you don't specify which product you are talking about, I'm going to assume you mean the open source platform itself. The short answer is no, but it can be used to write a distributed cache, and it has been in one of their own products (Ehcache). You can see an overview of what the core engine is about here (it seems that they are hiding the information on their open source platform behind a registration wall now). It is a clustering engine that does not use J2EE technology, and its main purpose is to simplify distributed computing development. Besides caching, obvious use cases involve high availability and scalability needs. Think of it as enabling relatively plain java code to run "in the cloud" without having to worry about a lot of the details that that might involve.
answers question: http://stackoverflow.com/q/2761177

http://stackoverflow.com/a/2621718
type: Answer
score: -7
has body: no, it has a number of methods, info(), debug(), warn(), etc (this replaces the priority field) have a look at http://www.slf4j.org/api/org/slf4j/Logger.html for the full Logger api.
upvote count: 1
has comment: http://stackoverflow.com/comment/2634024
has comment: http://stackoverflow.com/comment/43039819
answers question: http://stackoverflow.com/q/2621701
downvote count: 8

http://stackoverflow.com/a/2626498
downvote count: 0
has body: Use generics: abstract class Airplane&lt;M extends Measurable&gt;{ public abstract Airplane addAMeasurableThing(M m, int position); } class PassengerAirplane extends Airplane&lt;People&gt;{ @Override public Airplane addAMeasurableThing(People p, int position{ ... } }
upvote count: 6
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2626482
accepted answer of: http://stackoverflow.com/q/2626482
score: 6
type: Answer

http://stackoverflow.com/a/2729096
downvote count: 0
answers question: http://stackoverflow.com/q/2729038
has comment: http://stackoverflow.com/comment/2766726
has comment: http://stackoverflow.com/comment/2757618
has comment: http://stackoverflow.com/comment/2759291
type: Answer
has body: I am not sure it is exactly what you are looking for, but the following link can maybe help you : http://www.rgagnon.com/javadetails/java-0487.html
has comment: http://stackoverflow.com/comment/2757210
upvote count: 2
has comment: http://stackoverflow.com/comment/2766466
has comment: http://stackoverflow.com/comment/2767258
score: 2

http://stackoverflow.com/a/2673400
has comment: http://stackoverflow.com/comment/73188305
score: 0
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2673371
has body: You need to make sure you've created a web application project in Netbeans, then you should be able to run your Servlet as part of it. This guide is for Netbeans 5 but the principles should be still the same: https://www.java-tips.org/java-tutorials/1506-introduction-to-java-servlets-with-netbeans.html]1
type: Answer
accepted answer of: http://stackoverflow.com/q/2673371
upvote count: 1
downvote count: 1

http://stackoverflow.com/comment/2690471
type: Comment
comment on: http://stackoverflow.com/a/2671799
score: 0
type: AnswerComment
has text: No, I never did that, thanks! I've used JavaScript through javax.script before without doing anything, so I clearly missed that step. Let me try it now...

http://stackoverflow.com/comment/2678792
has text: Users don't read explicit error messages, but they do read tooltips attached to mini exclamation marks with completely non-obvious meaning? Sorry, I don't buy that...
comment on: http://stackoverflow.com/a/2661352
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/2678091
has comment: http://stackoverflow.com/comment/2697441
type: Question
score: 3
tagged with: flash
has answer: http://stackoverflow.com/a/2678301
accepted answer: http://stackoverflow.com/a/2678301
upvote count: 3
answer count: 2
favorite count: 0
tagged with: python
has answer: http://stackoverflow.com/a/2678227
has title: Scraping data from Flash (Games)
has body: I saw this video, and I am really curious how it was performed. Does anyone have any ideas? My intuition is that he scraped pixels from the screen (one per 'box'), and then fed that into some program to determine the next move. Is scraping pixel-by-pixel the way to do this, or is there a better way? I am looking to do something similar with either Java or Python. Thanks
type: AnsweredQuestion
downvote count: 0
tagged with: screen-scraping
tagged with: java
possible better answer: http://stackoverflow.com/a/2678227

http://stackoverflow.com/comment/33656386
type: Comment
score: 1
has text: if you are wondering why not Serializable: "The problem with this approach is that reflection is used and it is a slow process. This mechanism also tends to create a lot of temporary objects and cause quite a bit of garbage collection." from http://www.developerphil.com/parcelable-vs-serializable/
type: AnswerComment
comment on: http://stackoverflow.com/a/2736612

http://stackoverflow.com/comment/11517262
type: AnswerComment
has text: All problems resolved mime4j works much much much better than java mail api.
type: Comment
comment on: http://stackoverflow.com/a/2727912
score: 0

http://stackoverflow.com/comment/2820375
has text: Its not so much system idle time i need to find. I just need to find it a user has been using there PC within say the last 10 mins. Basically. I want notifications to only show if the user is actually at their PC.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/2777647
type: Comment

http://stackoverflow.com/a/2715906
type: Answer
answers question: http://stackoverflow.com/q/2715860
has body: I'm guessing your server program is trying to write to standard output or perhaps standard error (System.out / System.err in Java terms) which it implicitly inherited from your Java program but which turn into pumpkins when your Java program goes away. A simple solution might be for your Java program to exec a shell script which starts your server as a background process (using START (Windows) or &amp; (Unix)) with explicitly redirected I/O streams. The Java library has recently gotten some nice updates to the Process class (I think) that allow you to do a lot of fiddling with the streams, but I don't have much experience there so I can't offer a detailed suggestion. EDIT: My suggestion from the middle paragraph. Untested, sorry! File server-runner.sh: #!/bin/bash /path/mmserver &gt;/dev/null &amp; You'll need to chmod +x server-runner.sh, of course. Then, from your Java program, you exec the script server-runner.sh rather than your mmserver. If you want to kill mmserver, you'll have to find it in ps -ux and use kill on the process number.
has comment: http://stackoverflow.com/comment/2741466
has comment: http://stackoverflow.com/comment/2761173
has comment: http://stackoverflow.com/comment/2741568
has comment: http://stackoverflow.com/comment/2744632
score: 0
has comment: http://stackoverflow.com/comment/2762895
has comment: http://stackoverflow.com/comment/2742316

http://stackoverflow.com/comment/2808370
type: AnswerComment
comment on: http://stackoverflow.com/a/2774178
has text: Your choice. I just wanted to prove that it *works*. You namely mentioned that it "do not work". Since you already gave the answer using Google Collections yourself beforehand, I did not want to waste time to duplicate it.
type: Comment
score: 0

http://stackoverflow.com/a/47418443
upvote count: 0
score: -1
type: Answer
answers question: http://stackoverflow.com/q/2598129
has body: I resolve a similar exercise of the book : crackring the coding interview using recursion. package crackingcodeinterview; public class Exercise { static String textString = "this is a random text of example!@#$%^(^452464156"; public static void main(String[] args) { filterLetters(0, ""); } public static void filterLetters(int position, String letters) { if (position != textString.length()) { boolean p = false; for (int i = 0; i &lt; letters.length(); i++) { if (letters.charAt(i) == textString.charAt(position)) { p = true; break; } } if (!p) { letters += textString.charAt(position); } position++; filterLetters(position, letters); } else { System.out.println(letters); } } } Other solution using substring and recursion public class MyClass { public static void main(String args[]) { getUnicLetter("esta es una cadena con letras repetidas",""); } public static String getUnicLetter(String originalWord,String finalWord){ if(originalWord.isEmpty()) return null; System.out.print(finalWord); return getUnicLetter(originalWord.replace(originalWord.substring(0,1),""),finalWord.contains(originalWord.substring(0,1)) ? "" : originalWord.substring(0,1)); } }
downvote count: 1

http://stackoverflow.com/q/2772303
has answer: http://stackoverflow.com/a/2772381
downvote count: 0
accepted answer: http://stackoverflow.com/a/2772416
score: 7
has answer: http://stackoverflow.com/a/2772373
has title: Refactoring a complicated if-condition
has answer: http://stackoverflow.com/a/2776714
favorite count: 0
has answer: http://stackoverflow.com/a/2772350
answer count: 10
possible better answer: http://stackoverflow.com/a/2775286
has answer: http://stackoverflow.com/a/2775286
has answer: http://stackoverflow.com/a/2772384
type: AnsweredQuestion
tagged with: refactoring
tagged with: java
has body: Can anyone suggest best way to avoid most if conditions? I have below code, I want avoid most of cases if conditions, how to do it ? any solution is great help; if (adjustment.adjustmentAccount.isIncrease) { if (adjustment.increaseVATLine) { if (adjustment.vatItem.isSalesType) { entry2.setDebit(adjustment.total); entry2.setCredit(0d); } else { entry2.setCredit(adjustment.total); entry2.setDebit(0d); } } else { if (adjustment.vatItem.isSalesType) { entry2.setCredit(adjustment.total); entry2.setDebit(0d); } else { entry2.setDebit(adjustment.total); entry2.setCredit(0d); } } } else { if (adjustment.increaseVATLine) { if (adjustment.vatItem.isSalesType) { entry2.setCredit(adjustment.total); entry2.setDebit(0d); } else { entry2.setDebit(adjustment.total); entry2.setCredit(0d); } } else { if (adjustment.vatItem.isSalesType) { entry2.setDebit(adjustment.total); entry2.setCredit(0d); } else { entry2.setCredit(adjustment.total); entry2.setDebit(0d); } } }
upvote count: 7
has answer: http://stackoverflow.com/a/2772416
type: Question
tagged with: conditional-statements
has answer: http://stackoverflow.com/a/2776605
tagged with: if-statement
has answer: http://stackoverflow.com/a/2772403
has answer: http://stackoverflow.com/a/2772329

http://stackoverflow.com/a/2687763
has comment: http://stackoverflow.com/comment/2708561
downvote count: 0
answers question: http://stackoverflow.com/q/2687599
upvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/2708616
score: 2
has body: If your data set is small or if you do not care about speed, bart's answer should suffice. But when you have a large data set and do not want the O(N*N) complexity, you can use this (assuming no product name duplicated) Set&lt;String&gt; productsSet = new HashSet&lt;String&gt;(products); Then use Bart's code with products replaced by productsSet. This should give you the result in O(N) time, although will cost more memory.

http://stackoverflow.com/q/2691957
answer count: 2
has comment: http://stackoverflow.com/comment/2713295
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/2713263
type: UnansweredQuestion
tagged with: annotations
upvote count: 1
score: 1
tagged with: java
tagged with: hibernate
type: Question
has answer: http://stackoverflow.com/a/2692002
has title: Why Hibernates ignores the name attribute of the @Column annotation?
tagged with: websphere
tagged with: db2-400
has answer: http://stackoverflow.com/a/2692027
has body: Using Hibernate 3.3.1 and Hibernate Annotations 3.4, the database is DB2/400 V6R1, running that on WebSphere 7.0.0.9 I have the following class @Entity public class Ciinvhd implements Serializable { @Id private String ihinse; @Id @Column(name="IHINV#") private BigDecimal ihinv; .... } For reasons I can't figure, Hibernate ignores the specified column name and uses 'ihinv' to generate the SQL: select ciinvhd0_.ihinse as ihinse13_, ciinvhd0_.ihinv as ihinv13_, ... Which of course gives me the following error: Column IHINV not in table CIINVHD Edit: I switched the log level of hibernate to DEBUG, and I see that it does not process the column annotation for that field. Tried several random things it just doesn't work. Did anyone had this problem before? I have other entities that are very alike in the way that they are using # in their database field names and that are part of the PK and I don't have this problem with them.
has comment: http://stackoverflow.com/comment/2713434

http://stackoverflow.com/a/44539996
type: Answer
answers question: http://stackoverflow.com/q/2707903
score: 0
has body: I am using the context of eclipselink and ejb,i found that when I query entities,it will auto be cached,but I also run a function to change record in database,so I may get old data in the cache,so I disable cache by adding the following to the file persistence.xml: NONE it do works!

http://stackoverflow.com/q/2677564
upvote count: 34
favorite count: 0
has answer: http://stackoverflow.com/a/7428109
accepted answer: http://stackoverflow.com/a/7428109
answer count: 4
downvote count: 0
possible better answer: http://stackoverflow.com/a/13017949
score: 34
has body: How do I create custom javadoc tags such as @pre / @post? I found some links that explain it but I haven't had luck with them. These are some of the links: http://www.developer.com/java/other/article.php/3085991/Javadoc-Programming.html http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javadoc.html
type: Question
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/42730768
tagged with: java
tagged with: javadoc
has title: How to create custom javadoc tags?
has answer: http://stackoverflow.com/a/2678219
has answer: http://stackoverflow.com/a/13017949

http://stackoverflow.com/comment/2763140
type: Comment
has text: Thanks Pascal. I'm not in charge of production systems and, tbh, I'm not convinced that nearly enough regression testing would happen to make me happy about changing versions! Looking through the change control history the other day I noticed that it was originally set as validate and someone had updated it to 'udpate'. Given that, I think it's safer to remove it - hopefully someone is less likely to add in a whole line than to tweak a value in future!
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/2696175

http://stackoverflow.com/comment/2811752
has text: Can you ping acidrayne.net from the machine you are running this on?
comment on: http://stackoverflow.com/q/2777226
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/2816905
comment on: http://stackoverflow.com/q/2781845
score: 0
type: Comment
has text: The code you posted doesn't compile as written because both method1() and method2() would need to be static to be called by main. Once you make them static, the compile error is in main because it doesn't handle or throw the checked exception.
type: QuestionComment

http://stackoverflow.com/a/9686909
score: 4
has body: I check date from what an atomic time server will send me at the beginning at the code. Then, I will compare that date with a specific date. If the atomic time is less, then System.exit(0). public static GregorianCalendar getAtomicTime() throws IOException { BufferedReader in = null; try { URLConnection conn = new URL("http://64.90.182.55:13").openConnection(); GregorianCalendar calendar = new GregorianCalendar(); conn.setConnectTimeout(1000); in = new BufferedReader(new InputStreamReader(conn.getInputStream())); String atomicTime; while (true) { if ((atomicTime = in.readLine()).indexOf("*") &gt; -1) { break; } } //System.out.println("DEBUG : " + atomicTime); String[] fields = atomicTime.split(" "); String[] date = fields[1].split("-"); calendar.set(Calendar.YEAR, 2000 + Integer.parseInt(date[0])); calendar.set(Calendar.MONTH, Integer.parseInt(date[1]) - 1); calendar.set(Calendar.DATE, Integer.parseInt(date[2])); // deals with the timezone and the daylight-saving-time TimeZone tz = TimeZone.getDefault(); int gmt = (tz.getRawOffset() + tz.getDSTSavings()) / 3600000; //System.out.println("DEBUG : " + gmt); String[] time = fields[2].split(":"); calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(time[0]) + gmt); calendar.set(Calendar.MINUTE, Integer.parseInt(time[1])); calendar.set(Calendar.SECOND, Integer.parseInt(time[2])); return calendar; } catch (IOException e) { throw e; } finally { if (in != null) { in.close(); } } }
has comment: http://stackoverflow.com/comment/66654295
type: Answer
upvote count: 4
downvote count: 0
answers question: http://stackoverflow.com/q/2769384

http://stackoverflow.com/q/2621319
upvote count: 1
tagged with: guice
favorite count: 0
has body: I have been using spring for a while as my IOC. It has also a very nice way of injecting properties in your beans. Now I am participating in a new project where the IOC is Guice. I dont understand fully the concept how should I inject properties in to my beans using Guice. The question : Is it actually possible to inject raw properties ( strings , ints ) into my guice beans. If the answer is no , than maybe you know some nice Properties Framework for java. Because right now I wanted to use the ResourceBundle class for simple properties management in my app. But after using spring for a while this just dont seem seriously enought for me.
has title: Properties framework in java apps
has answer: http://stackoverflow.com/a/2629148
has answer: http://stackoverflow.com/a/2621408
downvote count: 0
score: 1
tagged with: spring
type: Question
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2622316
accepted answer: http://stackoverflow.com/a/2622316
tagged with: java
possible better answer: http://stackoverflow.com/a/2621408
linked to: http://stackoverflow.com/q/25765
answer count: 3

http://stackoverflow.com/comment/35880019
type: AnswerComment
comment on: http://stackoverflow.com/a/2685931
score: 0
type: Comment
has text: I found that I needed to add `-certfile [intermediate certificate]` to the `pkcs12 -export` command in order to export my CA's intermediate certificate as well.

http://stackoverflow.com/q/2708229
has answer: http://stackoverflow.com/a/2709729
score: 2
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2708232
downvote count: 0
tagged with: java
type: Question
upvote count: 2
has title: Is this a safe way to release resources in Java?
accepted answer: http://stackoverflow.com/a/2708270
answer count: 3
has answer: http://stackoverflow.com/a/2708232
has comment: http://stackoverflow.com/comment/2732224
favorite count: 0
has answer: http://stackoverflow.com/a/2708270
has comment: http://stackoverflow.com/comment/2732257
has comment: http://stackoverflow.com/comment/2732242
has body: Usually when code needs some resource that needs to be released I see it done like this: InputStream in = null; try{ in = new FileInputStream("myfile.txt"); doSomethingWithStream(in); }finally{ if(in != null){ in.close(); } } What I don't like is that you have to initialize the variable to null and after that set it to another value and in the finally block check if the resource was initialized by checking if it is null. If it is not null, it needs to be released. I know I'm nitpicking, but I feel like this could be done cleaner. What I would like to do is this: InputStream in = new FileInputStream("myfile.txt"); try{ doSomethingWithStream(in); }finally{ in.close(); } To my eyes this looks almost as safe as the previous one. If resource initialization fails and it throws an exception, there's nothing to be done(since I didn't get the resource) so it doesn't have to be inside the try block. The only thing I'm worried is if there is some way(I'm not Java certified) that an exception or error can be thrown between operations? Even simpler example: Inputstream in = new FileInputStream("myfile.txt"); in.close(); Is there any way the stream would be left open that a try-finally block would prevent? Edit: Maybe I should have left out the last example because it confuses everyone. This is not supposed to be a beginner level question. I know what try-finally does and I know that it is not safe if there was doSomethingWithStream in the middle in the last example. That is why it is not there. I accepted Eyals answer because it was precisely what I was looking for. There is a way to cause an exception between two operations, which would make the middle example unsafe(using Thread.stop), but since it is made using deprecated call and can mess you up no matter what you do so I feel safe using the middle example.

http://stackoverflow.com/a/2717469
has body: I think the goal of requiring that everything is enclosed in classes is to minimize the number of concepts that you need to deal with in the language. In C# or Java, you only need to understand the object-model (which is fairly complex, though). However, you only have classes with members and instances of classes (objects). I think this is a very important goal that most of the languages try to follow in one way or another. If C# had some global code (for example to allow interactive evaluation and specification of the startup code without Main method), you'd have one additional concept to learn (top-level code). The choice made by C#/Java is of course just one way to get the simplicity. Of course, it is a question whether this is the right choice. For example: In functional languages, programs are structured using types (type declarations) and expressions. The body of the program is simply an expression that is evaluated, which is a lot simpler than a class with Main method and it also enables interactive scripting (as in Python). In Erlang (and similar languages), program is structured as concurrently executing processes with one main process that starts other processes. This is a dramatically different approach, but it makes a good sense for some types of applications. In general, every language has some way of looking at the world and modelling it and uses this point of view when looking at everything. This works well in some scenarios, but I think that none of the models is fully universal. That may be a reason why languages that mix multiple paradigms are quite popular today. As a side-note, I think that the use of Main method is somewhat arguable choice (probably inheriting from C/C++ languages). I would suppose that more clear object-oriented solution would be to start the program by creating an instance of some Main class.
accepted answer of: http://stackoverflow.com/q/2717348
type: Answer
has comment: http://stackoverflow.com/comment/2754323
answers question: http://stackoverflow.com/q/2717348
has comment: http://stackoverflow.com/comment/2743390
has comment: http://stackoverflow.com/comment/2743997
upvote count: 18
type: AcceptedAnswer
downvote count: 0
score: 18

http://stackoverflow.com/comment/117336182
has text: So does this mean assert can be used in production ready code?
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/19425549

http://stackoverflow.com/q/2639551
upvote count: 5
tagged with: java
has title: Java specification
has answer: http://stackoverflow.com/a/2639577
type: Question
possible better answer: http://stackoverflow.com/a/15954158
score: 5
has answer: http://stackoverflow.com/a/2639590
has answer: http://stackoverflow.com/a/15954158
downvote count: 0
has answer: http://stackoverflow.com/a/2639571
favorite count: 0
has body: Java JDK or JRE or both are specifications? Can anyone quote some relevant implementations?
answer count: 4
accepted answer: http://stackoverflow.com/a/2639571
type: AnsweredQuestion

http://stackoverflow.com/a/2715777
downvote count: 1
answers question: http://stackoverflow.com/q/2715764
has body: Tasks are guaranteed to be executed in any order that satisfies their mutual dependencies. I don't think it's safe to make any assumption beyond that. You can set up the chain using depends= in the targets, as you probably know. Or you can set up targets that run the other targets in sequence.
score: 0
type: Answer
upvote count: 1

http://stackoverflow.com/comment/2669240
type: Comment
has text: Thanks, I will try to use this solution, then i will post if it worked well
comment on: http://stackoverflow.com/a/2652479
type: AnswerComment
score: 0

http://stackoverflow.com/a/2888005
has body: There is an open source project called titl that sounds exactly what you're looking for. The repository is here: https://github.com/josephw/titl
upvote count: 8
type: Answer
has comment: http://stackoverflow.com/comment/2938187
score: 8
answers question: http://stackoverflow.com/q/2622690
accepted answer of: http://stackoverflow.com/q/2622690
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/2799919
type: AnswerComment
has text: Sun's Java isn't exactly Apple's.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2767261

http://stackoverflow.com/q/2737456
type: UnansweredQuestion
has title: How do I create persistent socket connection on Android?
tagged with: java
score: 4
type: Question
upvote count: 4
answer count: 2
has answer: http://stackoverflow.com/a/2782731
downvote count: 0
favorite count: 0
tagged with: android
has body: First off, let me say that feel free to recommend me if long lived TCP persistent connections are the way to go or persistent HTTP connections are better. I've also pre-read that instead of having a persistent connection, I can have a polling mechanism. I'm just asking in the curious interest of how can I create a persistent connection from Android to a server? Thanks!
has answer: http://stackoverflow.com/a/2737545

http://stackoverflow.com/q/2760294
has answer: http://stackoverflow.com/a/2760447
tagged with: synchronization
favorite count: 0
possible better answer: http://stackoverflow.com/a/2760350
upvote count: 2
has title: Java Thread - Synchronization issue
tagged with: multithreading
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2760363
has answer: http://stackoverflow.com/a/2760341
has answer: http://stackoverflow.com/a/2760577
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/2760428
has answer: http://stackoverflow.com/a/2760354
has answer: http://stackoverflow.com/a/2762852
downvote count: 0
has body: From Sun's tutorial: Synchronized methods enable a simple strategy for preventing thread interference and memory consistency errors: if an object is visible to more than one thread, all reads or writes to that object's variables are done through synchronized methods. (An important exception: final fields, which cannot be modified after the object is constructed, can be safely read through non-synchronized methods, once the object is constructed) This strategy is effective, but can present problems with liveness, as we'll see later in this lesson. Q1. Is the above statements mean that if an object of a class is going to be shared among multiple threads, then all instance methods of that class (except getters of final fields) should be made synchronized, since instance methods process instance variables?
accepted answer: http://stackoverflow.com/a/2760577
has answer: http://stackoverflow.com/a/2760350
score: 2
has answer: http://stackoverflow.com/a/2760328
has answer: http://stackoverflow.com/a/2760691
answer count: 10

http://stackoverflow.com/a/2690600
score: 3
answers question: http://stackoverflow.com/q/2690441
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2690441
type: Answer
has body: The conditions are: the request method must be post the content-type must start with multipart/ Check these two via request.getMethod() and request.getContentType()
upvote count: 3

http://stackoverflow.com/a/2656018
upvote count: 2
has comment: http://stackoverflow.com/comment/2690774
has comment: http://stackoverflow.com/comment/2681287
downvote count: 0
answers question: http://stackoverflow.com/q/2655718
type: Answer
has body: The usual MVC approach is to override the HttpServlet#service() method and let the business logic depend on the request method as well, as obtained by HttpServletRequest#getMethod(). Also see this answer. An alternative approach is indeed to let doGet() and doPost() do both the same logic, but I would not delegate the one to the other, I would rather delegate them both to the same independent method. E.g. (semi-pseudo): protected void doGet(request, response) { process(request, response); } protected void doPost(request, response) { process(request, response); } private void process(request, response) { // Do your thing here. } As opposed to HttpServlet#service() method, this does not take the HTTP HEAD, TRACE, PUT, OPTIONS and DELETE request methods into account. You may namely want to ignore them and let the servletcontainer handle them the "default" way (i.e. returning HTTP 405 Method Not Allowed).
score: 2
has comment: http://stackoverflow.com/comment/2681420

http://stackoverflow.com/q/2783611
accepted answer: http://stackoverflow.com/a/2783647
has title: how to disable JList selection change event and invoke it only on double click?
upvote count: 3
tagged with: swing
has body: As the title says... I'd like items in a JList to be "selected" only when they are double clicked. what would be the best way to achieve this kind of behavior ?
type: AnsweredQuestion
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/2783647
answer count: 1
downvote count: 0
favorite count: 0
tagged with: jlist
score: 3
tagged with: events

http://stackoverflow.com/q/2783915
favorite count: 0
has title: Peculiar JRE behaviour running RMI server under load, should I worry?
tagged with: garbage-collection
has answer: http://stackoverflow.com/a/2783992
type: AnsweredQuestion
score: 1
tagged with: java
upvote count: 1
type: Question
has body: I've been developing a minimalistic Java rich client CRUD application framework for the past few years, mostly as a hobby but also actively using it to write applications for my current employer. The framework provides database access to clients either via a local JDBC based connection or a lightweight RMI server. Last night I started a load testing application, which ran 100 headless clients, bombarding the server with requests, each client waiting only 1 - 2 seconds between running simple use cases, consisting of selecting records along with associated detail records from a simple e-store database (Chinook). This morning when I looked at the telemetry results from the server profiling session I noticed something which to me seemed strange (and made me keep the setup running for the remainder of the day), I don't really know what conclusions to draw from it. Here are the results: Memory GC activity Threads CPU load Interesting, right? So the question is, is this normal or erratic? Is this simply the JRE (1.6.0_03 on Windows XP) doing it's thing (perhaps related to the JRE configuration) or is my framework design somehow causing this? Running the server against MySQL as opposed to an embedded H2 database does not affect the pattern. I am leaving out the details of my server design, but I'll be happy to elaborate if this behaviour is deemed erratic.
accepted answer: http://stackoverflow.com/a/2783992
has comment: http://stackoverflow.com/comment/2819252
answer count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/2819261
has comment: http://stackoverflow.com/comment/2819358

http://stackoverflow.com/comment/22822010
comment on: http://stackoverflow.com/a/2618081
score: 0
type: AnswerComment
type: Comment
has text: Just as an aside: JavaScript's native `isNaN(...)` does not work like @quazgar's function. Instead, it even returns `true` when passing it a non-number, like a primitive string, an object, or `undefined`. In those cases, `x !== x` yields `false` instead. So, quazgar's version nicely checks if `x` is a NaN *number*. (I know the question is about Java, not JavaScript.)

http://stackoverflow.com/a/2657045
score: 0
type: Answer
has body: If you regularly need to get the key of the nth item, consider: using a TreeMap, which efficiently keeps keys in sorted order then using a double map (i.e. one TreeMap mapping integer > float, the other mapping float > integer) You have to weigh up the inelegance and potential risk of bugs from needing to maintain two maps with the scalability benefit of having a structure that efficiently keeps the keys in order. You may need to think about two keys mapping to the same float... P.S. Forgot to mention: if this is an occasional function, and you just need to find the nth largest item of a large number of items, you could consider implementing a selection algorithm (effectively, you do a sort, but don't actually bother sorting subparts of the list that you realise you don't need to sort because their order makes no difference to the position of the item you're looking for).
answers question: http://stackoverflow.com/q/2656995

http://stackoverflow.com/a/2599659
accepted answer of: http://stackoverflow.com/q/2599643
answers question: http://stackoverflow.com/q/2599643
type: Answer
score: 22
has comment: http://stackoverflow.com/comment/2608422
upvote count: 22
has body: I can think of two better solutions to this than using reflection. Any decent IDE will auto-fill in switch statements for you. I use IntelliJ and it does this (you just press ctrl-enter). I'm sure Eclipse/Netbeans have something similar; and Enums make a far better choice for constants than public static primitives. The added advantage is they will relieve you of this problem. But to find out what you want via reflection, assuming: interface Foo { public static final int CONST_1 = 1; public static final int CONST_2 = 3; public static final int CONST_3 = 5; } Run: public static void main(String args[]) { Class&lt;Foo&gt; c = Foo.class; for (Field f : c.getDeclaredFields()) { int mod = f.getModifiers(); if (Modifier.isStatic(mod) &amp;&amp; Modifier.isPublic(mod) &amp;&amp; Modifier.isFinal(mod)) { try { System.out.printf("%s = %d%n", f.getName(), f.get(null)); } catch (IllegalAccessException e) { e.printStackTrace(); } } } } Output: CONST_1 = 1 CONST_2 = 3 CONST_3 = 5
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/2612576
tagged with: http://stackoverflow.com/tag/html
tagged with: templates
upvote count: 16
has answer: http://stackoverflow.com/a/19602525
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/24238187
downvote count: 1
has title: Android Lightweight HTML Template Engine
type: Question
tagged with: java
score: 15
has body: I am after a very lightweight template engine that supports / can be embedded inside Android programs. I've looked at the MiniTemplator (I think that is how you spell it) and that looks great but it loads in only from file and I need to load templates from string and I am not fully confident in changing that code lol. Can anyone recommend a very lightweight (preferably no jars, single source files etc) that I can use ? I do not need it to parse XML or anything like, just normal HTML files with keywords embedded into them betwee %% tags etc.,
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/2629999
has comment: http://stackoverflow.com/comment/2624206
tagged with: android

http://stackoverflow.com/comment/48855208
type: AnswerComment
type: Comment
score: 0
has text: @JethroLarson: The last node in a linked list points to a known address (in many implementations, this is NULL). Terminate the for-loop when that known address is reached.
comment on: http://stackoverflow.com/a/2663136

http://stackoverflow.com/comment/2766683
has text: Not really, a Set is just a Map where you ignore the values. You could easily write a wrapper to make it look more like a `Set` if you don't want to deal with it all the time in your application.
comment on: http://stackoverflow.com/a/2738259
score: 4
type: AnswerComment
type: Comment

printing
tags question: http://stackoverflow.com/q/2678812
tag name: printing
tags question: http://stackoverflow.com/q/2645241
tags question: http://stackoverflow.com/q/2622045
type: Tag
tags question: http://stackoverflow.com/q/2705411

http://stackoverflow.com/comment/2636016
type: Comment
score: 1
comment on: http://stackoverflow.com/q/2623453
type: QuestionComment
has text: because there will be less data on the stack?

http://stackoverflow.com/comment/2753055
has text: @Phil: I have read somewhere that they weren't going to port over Joda Time into Java 7, but to try to learn from it.
type: AnswerComment
comment on: http://stackoverflow.com/a/2725945
type: Comment
score: 0

http://stackoverflow.com/comment/2759773
score: 0
type: Comment
type: AnswerComment
has text: @BalusC I don't see a write(char c) method in RandomAccessFile. And if you are not specifying the encoding you are writing the code point not the encoded value.
comment on: http://stackoverflow.com/a/2725993

http://stackoverflow.com/a/12631271
answers question: http://stackoverflow.com/q/2694529
score: 12
upvote count: 12
downvote count: 0
has body: My experience using JUnit for an Acceptance Testing framework. Our company did a very similar thing where we started with FitNesse and then went to JUnit. We did this mainly because FitNesse was sitting on top of Java already, so switching to JUnit was easy. FitNesse seemed to not fit (no pun intended) our needs. Here are my pros and cons of using JUnit: Pros: JUnit has a lot of flexibility (because it's Java), so it's relatively easy to create an Internal Domain Specific Language[Fowler]. The DSL can be modified so that it's easy for domain experts (not software engineers) to read/write. Since it's JUnit you can use Eclipse as an IDE, which gives you auto-complete, syntax checking, debugging, etc. Specific for our application, we have a CORBA interface to the UI. Java can easily use this CORBA interface as well. Cons: People hear JUnit and think unit test. This gets confusing when people start referring to the acceptance tests as "JUnit tests". To provide a simplified testing environment you have to spend some time extending the framework and developing your DSL. So in summary, JUnit works just fine for Acceptance Tests if you are willing to spend the time to extend it into you own domain specific testing environment. Otherwise I think I would look elsewhere for something more out of the box.
type: Answer

http://stackoverflow.com/a/34472498
score: -1
has body: Couldn't you just make the numbers strings, concatenate them, and convert the strings to an integer value?
downvote count: 1
type: Answer
upvote count: 0
answers question: http://stackoverflow.com/q/2674707

http://stackoverflow.com/a/2718240
has comment: http://stackoverflow.com/comment/2745065
upvote count: 1
has body: Are you enabling/disabling the JCheckBox using an ActionListener? If so, then that is normal because when you click on the checkbox, the isSelected() status changes. What you can do is to add checks using isSelected() and the setSelected() methods.
type: Answer
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/2744239
answers question: http://stackoverflow.com/q/2718110

http://stackoverflow.com/a/2698728
score: 1
answers question: http://stackoverflow.com/q/2698690
upvote count: 1
type: Answer
downvote count: 0
has body: You define an array in a constructor just like you would any other variable. So, it would look something like: // define an array of size 3 String[] contactListNames = new String[3]; The reason you are getting exceptions is because you don't actually initialize the array. You declare it but you never set it to a value (or give it a size). You should post the stack trace of the error but I suspect it's a NullPointerException.

http://stackoverflow.com/comment/14565331
type: Comment
score: 1
has text: Edited the reply to a method some extra steps that are needed for this to work. The getBroadcast is important for the PendingIntent to be broadcast, rather than getActivity from the example.
comment on: http://stackoverflow.com/a/2748723
type: AnswerComment

http://stackoverflow.com/a/2772282
answers question: http://stackoverflow.com/q/2772259
score: 0
has body: DumpHD is a well-written application in Java; it works perfectly in Windows and Linux.
type: Answer

http://stackoverflow.com/a/2712665
has comment: http://stackoverflow.com/comment/49888693
has comment: http://stackoverflow.com/comment/2737537
answers question: http://stackoverflow.com/q/2712637
downvote count: 3
accepted answer of: http://stackoverflow.com/q/2712637
score: 13
upvote count: 16
has body: JButton has a border by default, you can remove it: button.setBorder(null); If you want to keep the border, reduce the margin (see Eugenes answer)
has comment: http://stackoverflow.com/comment/54999748
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/24519160
type: Answer

http://stackoverflow.com/comment/2683349
type: Comment
type: QuestionComment
has text: it says about using JDialog, in myeclipse i am importing java.awt.* but JDialog is unrecognized. any help on that ?
score: 0
comment on: http://stackoverflow.com/q/2665355

http://stackoverflow.com/q/2599993
score: 3
has answer: http://stackoverflow.com/a/2600014
has title: How can I close a JFrame by click on a button?
has answer: http://stackoverflow.com/a/3968689
possible better answer: http://stackoverflow.com/a/2600050
upvote count: 3
answer count: 3
tagged with: user-interface
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2600050
tagged with: jframe
tagged with: java
accepted answer: http://stackoverflow.com/a/2600014
has body: I would like to have a button in my window such that if I click it (button) the window is closed. I found out that I can close a window in the following way: referenceToTheFrame.hide(); //hides the frame from view refToTheFrame.dispose(); //disposes the frame from memory But if I do this way, compiler complains: Note: myProgram.java uses or overrides a deprecated API Note: Recompile with -Xlint:deprication for details. Do I do something unsafe?
has comment: http://stackoverflow.com/comment/2608788
tagged with: swing
type: Question
type: AnsweredQuestion

try-catch-finally
tags question: http://stackoverflow.com/q/2671103
type: Tag
tag name: try-catch-finally

jcomponent
tags question: http://stackoverflow.com/q/2696285
tag name: jcomponent
tags question: http://stackoverflow.com/q/2689916
tags question: http://stackoverflow.com/q/2783377
type: Tag
tags question: http://stackoverflow.com/q/2716647
tags question: http://stackoverflow.com/q/2626403

http://stackoverflow.com/a/2803989
type: Answer
has body: I found an excellent example of how to create lists with icons here: http://commonsware.com/Android/excerpt.pdf The The Busy Coder's Guide to Android Development book in general is very enlightening.
score: 0
accepted answer of: http://stackoverflow.com/q/2709496
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2709496

uri
tags question: http://stackoverflow.com/q/2709087
tags question: http://stackoverflow.com/q/2765782
tag name: uri
tags question: http://stackoverflow.com/q/2597653
tags question: http://stackoverflow.com/q/2605757
type: Tag

http://stackoverflow.com/comment/2672658
has text: Do you thing Jetty will be a good choice? and maybe use RESTlet to implement the RESTful web service?
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2655365

http://stackoverflow.com/comment/2647860
score: 0
type: Comment
type: QuestionComment
has text: Cross posted: http://www.coderanch.com/t/491367/Swing-AWT-SWT-JFace/java/jframe-import-multiple-jpanel
comment on: http://stackoverflow.com/q/2633582

http://stackoverflow.com/a/2676308
type: Answer
score: 0
has body: Best solutions are already discussed. For the heck of it, you could do this as well: Given that you are always dealing with 5 digits, (new java.util.Formatter().format("%d%d%d%d%d", a,b,c,d,e)).toString() I am not claiming this is the best way; just adding an alternate way to look at similar situations. :)
answers question: http://stackoverflow.com/q/2674707

http://stackoverflow.com/comment/2617778
score: 0
type: Comment
comment on: http://stackoverflow.com/q/2607515
type: QuestionComment
has text: What happens if you declare your `output` member variable as `volatile`?

event-handling
tag name: event-handling
tags question: http://stackoverflow.com/q/2645039
tags question: http://stackoverflow.com/q/2604005
tags question: http://stackoverflow.com/q/2705040
tags question: http://stackoverflow.com/q/2614355
type: Tag

http://stackoverflow.com/comment/2768427
score: 0
comment on: http://stackoverflow.com/q/2739725
has text: Sorry dude, I don't want to be rude, but RTFM gives pretty obvious answer to this
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2672811
has title: Initializing Multidimensional Arrays in Java
tagged with: java
upvote count: 1
has answer: http://stackoverflow.com/a/2672848
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/2694261
tagged with: arrays
score: 0
has answer: http://stackoverflow.com/a/2672924
favorite count: 0
has comment: http://stackoverflow.com/comment/2691548
type: UnansweredQuestion
has body: I have a 3-multidimensional array: int[][][] env; which I would like to initialize with data in a text file. The data in the text file looks like this: { { { 0, 1,-1}, { 0, 2,-1}, {-1,-1,-2}, { 0, 0, 0} }, { { 0, 0,-1}, { 0, 0,-1}, {-1,-1,-2}, { 0, 0, 0} } } Actually the accolades can be removed and replaced with different characters if it is necessary. If there are any better way to format the values in the text file, then it is welcomed. I am looking for the best way to initialize the array in the java program with the values from the text file.
downvote count: 1

http://stackoverflow.com/comment/2764312
type: AnswerComment
type: Comment
has text: I tried it with the 1st pair of your coordinates and it gave me an address: geo.getFromLocation(1.40502, 103.793449, 3); For your code you would need to iterate for your String locations, and use the second part, probably splitting it with String.split(",") to get latitude and longitude separate and for each one you get the address. I added some more code to my answer.
comment on: http://stackoverflow.com/a/2728451
score: 0

http://stackoverflow.com/q/2685512
type: Question
has body: I generate a certification key with openssl. Here is my command: openssl genrsa -des3 -out enc_key.pem 1024 I export into cer file, then with java keytool I import into java keystore (jks). The keystore sounds good. I can load the keystore from my java app. The problem is when client connect to the server (In this case is FTP server, not web server, and I use apache mina), the exception occured: javax.net.ssl.SSLHandshakeException: SSL handshake failed. at org.apache.mina.filter.ssl.SslFilter.messageReceived(SslFilter.java:433) at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434) at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$5(DefaultIoFilterChain.java:429) ... Caused by: javax.net.ssl.SSLHandshakeException: no cipher suites in common at com.sun.net.ssl.internal.ssl.Handshaker.checkThrown(Unknown Source) at com.sun.net.ssl.internal.ssl.SSLEngineImpl.checkTaskThrown(Unknown Source) at com.sun.net.ssl.internal.ssl.SSLEngineImpl.writeAppRecord(Unknown Source) at com.sun.net.ssl.internal.ssl.SSLEngineImpl.wrap(Unknown Source) at javax.net.ssl.SSLEngine.wrap(Unknown Source) ... Caused by: javax.net.ssl.SSLHandshakeException: no cipher suites in common at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source) at com.sun.net.ssl.internal.ssl.SSLEngineImpl.fatal(Unknown Source) There is a few things that I want to ask: What is the cipher of certification that I generate with openssl? How can we know? maybe by command line openssl xxx? I go to http://java.sun.com/j2se/1.5.0/docs/guide/security/jsse/JSSERefGuide.html#AppA. And I put SSL_RSA_xxx to enabled cipher suites, but still can't work (I put SSL_RSA because it the SSL is using ssl implisit, and genrsa, just my opinion genrsa is generate RSA). Is it correct? Anybody knows the solution? Or, anybody knows how to generate the standard keystore from openssl command line until can be used in java app (off course with the cipher). Because…
has title: Can a Java key store import a key pair generated by OpenSSL?
has answer: http://stackoverflow.com/a/2685931
tagged with: openssl
answer count: 1
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/2685931
tagged with: keystore
type: AnsweredQuestion
tagged with: java
score: 24
upvote count: 24

http://stackoverflow.com/a/2639372
answers question: http://stackoverflow.com/q/2639343
has comment: http://stackoverflow.com/comment/2653732
has body: for the first question, you can stop the user from resizing your window using the method setResizable(boolean): frame.setResizable(false); I don't use GridBagLayout, so I can't help you with the second question.
score: 2
downvote count: 0
type: Answer
upvote count: 2

http://stackoverflow.com/comment/2803230
type: AnswerComment
comment on: http://stackoverflow.com/a/2763448
has text: I think there's a system property that disables it. See the JSSE Reference Guide.
score: 0
type: Comment

http://stackoverflow.com/q/2659839
has answer: http://stackoverflow.com/a/2659873
has title: Extracting startup errors from Spring contexts
has body: Consider the following output from a Tomcat server under Eclipse: INFO: Initializing Coyote HTTP/1.1 on http-8080 INFO: Initialization processed in 634 ms INFO: Starting service Catalina INFO: Starting Servlet Engine: Apache Tomcat/6.0.20 SEVERE: Error listenerStart SEVERE: Context [/MyServlet] startup failed due to previous errors I would like to figure out what exception caused "Error listenerStart", but Spring seems to be preventing me from finding the error via Eclipse. I'd love to start Catalina manually, but that doesn't seem to do anything. What's the best way to find the hidden exception? I'm not afraid to use torture methods.
tagged with: tomcat
answer count: 3
upvote count: 1
favorite count: 0
tagged with: spring
has answer: http://stackoverflow.com/a/2660531
type: AnsweredQuestion
downvote count: 0
accepted answer: http://stackoverflow.com/a/2660058
score: 1
tagged with: java
possible better answer: http://stackoverflow.com/a/2659873
tagged with: eclipse
type: Question
has answer: http://stackoverflow.com/a/2660058

http://stackoverflow.com/q/2704473
tagged with: code-formatting
has answer: http://stackoverflow.com/a/2705674
possible better answer: http://stackoverflow.com/a/2705674
upvote count: 16
has body: I'm familiar with printing time difference in milliseconds: long time = System.currentTimeMillis(); //do something that takes some time... long completedIn = System.currentTimeMillis() - time; But, is there a nice way print a complete time in a specified format (eg: HH:MM:SS) either using Apache Commons or even the dreaded platform API's Date/Time objects? In other words, what is the shortest, simplest, no nonsense way to write a time format derived from milliseconds in Java?
type: AnsweredQuestion
has title: Most idiomatic way to print a time difference in Java?
tagged with: java
answer count: 6
has answer: http://stackoverflow.com/a/2704494
type: Question
has answer: http://stackoverflow.com/a/17322243
has comment: http://stackoverflow.com/comment/2727954
accepted answer: http://stackoverflow.com/a/2704494
linked to: http://stackoverflow.com/q/38922754
downvote count: 0
has answer: http://stackoverflow.com/a/2704486
has answer: http://stackoverflow.com/a/41800442
favorite count: 0
score: 16
tagged with: idioms
has answer: http://stackoverflow.com/a/2704489
tagged with: datetime

http://stackoverflow.com/comment/2650703
comment on: http://stackoverflow.com/a/2633943
has text: @Jens: Yes, you won't have any problems if fully qualifiead names are different.
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/q/2773717
tagged with: java
has title: Handling a binary operation that makes sense only for part of a hierarchy
type: Question
score: 0
answer count: 3
has comment: http://stackoverflow.com/comment/2807428
has body: I have a hierarchy, which I'll simplify greatly, of implementations of interface Value. Assume that I have two implementations, NumberValue, and StringValue. There is an average operation which only makes sense for NumberValue, with the signature NumberValue average(NumberValue numberValue){ ... } At some point after creating such variables and using them in various collections, I need to average a collection which I know is only of type NumberValue, there are three possible ways of doing this I think: Very complicated generic signatures which preserve the type info in compile time (what I'm doing now, and results in hard to maintain code) Moving the operation to the Value level, and: throwing an unsupportedOperationException for StringValue, and casting for NumberValue. Casting at the point where I know for sure that I have a NumberValue, using slightly less complicated generics to insure this. Does anybody have any better ideas, or a recommendation on oop best practices?
has answer: http://stackoverflow.com/a/2773798
has answer: http://stackoverflow.com/a/3104308
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/3224679
has answer: http://stackoverflow.com/a/2774266
tagged with: oop
has comment: http://stackoverflow.com/comment/2808065

http://stackoverflow.com/q/2665773
answer count: 3
has answer: http://stackoverflow.com/a/79429946
accepted answer: http://stackoverflow.com/a/2665821
has body: I am writing a junit test in order to (surprisingly) test a part of my app as a standalone. Thing is I execute the following line in a constructor being invoked in the unit test: WebApplicationContext webApplicationContext = ContextLoader.getCurrentWebApplicationContext(); How would I go about to set up a web context when running a simple unit test? Thanks
score: 2
downvote count: 0
type: AnsweredQuestion
has title: Spring: I wish to create a junit test for a web application - WebApplicationContext needed
has comment: http://stackoverflow.com/comment/20780084
favorite count: 0
has answer: http://stackoverflow.com/a/2665821
type: Question
upvote count: 2
linked to: http://stackoverflow.com/q/10441622
possible better answer: http://stackoverflow.com/a/2665813
tagged with: spring
has answer: http://stackoverflow.com/a/2665813
tagged with: unit-testing
tagged with: java

http://stackoverflow.com/q/2741101
tagged with: object
type: AnsweredQuestion
tagged with: java
has body: I have a string of kml coming in on a request object. I have used xjc to create the kml java objects. I am looking for an easy way to create the kml nested java objects from this string. I could parse the string and create each object in the tree by hand but wouldn't it be cool if there was a library or something that would create the java objects for me? Something like KmlType type = parseKML(mykmlStringFromTheRequest); Then type would be a Tree of kml objects. Thanks for the help all.
accepted answer: http://stackoverflow.com/a/2894749
type: Question
score: 0
answer count: 1
tagged with: kml
tagged with: string
has title: String of KML needs to be converted to java objects
has answer: http://stackoverflow.com/a/2894749

http://stackoverflow.com/comment/95445100
type: AnswerComment
type: Comment
has text: So does it mean arraycopy runs in O(1) and not O(length)?
comment on: http://stackoverflow.com/a/2772176
score: 0

http://stackoverflow.com/a/2762108
downvote count: 0
has comment: http://stackoverflow.com/comment/2794251
type: Answer
answers question: http://stackoverflow.com/q/2762093
has comment: http://stackoverflow.com/comment/2794262
has body: Assuming hash1 and hash2 List&lt; String &gt; sames = whatever List&lt; String &gt; diffs = whatever int count = 0; for( String key : hash1.keySet() ) { if( hash2.containsKey( key ) ) { sames.add( key ); } else { diffs.add( key ); } } //sames.size() contains the number of similar elements.
upvote count: 1
has comment: http://stackoverflow.com/comment/134233376
score: 1

http://stackoverflow.com/q/2710422
tagged with: java
has answer: http://stackoverflow.com/a/2710812
type: Question
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/438844
has comment: http://stackoverflow.com/comment/2734943
has body: Is breaking and continuing the only uses of labeled statements in Java? When have you used Labeled Statements in your programs? Sorry the code snippet has been deleted. I am splitting the question
has answer: http://stackoverflow.com/a/2710436
has comment: http://stackoverflow.com/comment/2734948
tagged with: continue
answer count: 3
accepted answer: http://stackoverflow.com/a/2710812
downvote count: 0
favorite count: 0
upvote count: 8
tagged with: labeled-statements
tagged with: break
possible better answer: http://stackoverflow.com/a/2710443
score: 8
has answer: http://stackoverflow.com/a/2710443
has title: Please explain the usage of Labeled Statements

http://stackoverflow.com/comment/2652112
comment on: http://stackoverflow.com/a/2637280
has text: The well known name for frozen flakes of water coming down from the sky is snow. The name for the pattern of that happening 4 months out of the year is winter.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/2705452
type: Answer
has body: The words first time and after make me wonder about a synchronization problem. If the initialization of Logic.getInstance() is deferred, you might look at the Initialization On Demand Holder Idiom, also discussed in item 71 of Effective Java.
has comment: http://stackoverflow.com/comment/3340776
score: 0
answers question: http://stackoverflow.com/q/2704705

http://stackoverflow.com/a/2631350
score: 0
type: Answer
has body: Use JAAS JAAS is a generic framework and would not give any application specific features such as disable/enable buttons etc. you will have to embed that authorization logic into your application, JAAS provides you a handle to the authenticated/authorized Principal object that comes handy in such scenarios.
answers question: http://stackoverflow.com/q/2622555

http://stackoverflow.com/a/2607204
has comment: http://stackoverflow.com/comment/2617505
downvote count: 0
has body: Are you running the application in an IDE such as Eclipse or IntelliJ IDEA? Try using the command line instead. Some IDEs will screw up calls to System.console().
type: Answer
answers question: http://stackoverflow.com/q/2607177
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/2617305

http://stackoverflow.com/q/2645652
possible better answer: http://stackoverflow.com/a/2646199
answer count: 3
upvote count: 4
has answer: http://stackoverflow.com/a/2646199
favorite count: 0
accepted answer: http://stackoverflow.com/a/2645675
tagged with: multithreading
type: AnsweredQuestion
has title: Java: Allowing the child thread to kill itself on InterruptedException?
has answer: http://stackoverflow.com/a/2645675
downvote count: 0
has body: I am using a ThreadPool via ExecutorService. By calling shutDownNow() it interrupts all running threads in the pool. When this happens I want these threads to give up their resources (socket and db connections) and simply die, but without continuing to run anymore logic, eg: inserting anything into the DB. What is the simplest way to achieve this? Bellow is some sample code: edit: forgot to mention that all my connections are released via finally. I just need to make sure that reaching that doesn't invoke various DB inserts in a reliable way. public void threadTest() { Thread t = new Thread(new Runnable() { public void run() { try { Thread.sleep(999999); } catch (InterruptedException e) { //invoke thread suicide logic here } } }); t.start(); t.interrupt(); try { Thread.sleep(4000); } catch (InterruptedException e) { } }
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/2645767
score: 4

http://stackoverflow.com/a/2624883
has comment: http://stackoverflow.com/comment/2800275
downvote count: 0
answers question: http://stackoverflow.com/q/2624655
upvote count: 2
has comment: http://stackoverflow.com/comment/2638320
type: AcceptedAnswer
has body: but after bundling the software, it doesn't work any more. You cannot browse to URL's which points to resources inside a JAR file. You need to extract the resource (just get InputStream using getResourceAsStream()) and store it somewhere else (as temp file?) and then browse it instead.
has comment: http://stackoverflow.com/comment/2638140
has comment: http://stackoverflow.com/comment/2800864
type: Answer
score: 2
accepted answer of: http://stackoverflow.com/q/2624655

http://stackoverflow.com/q/2730325
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/2733933
accepted answer: http://stackoverflow.com/a/2733933
score: 0
has title: Test problem using JUnitPerf
answer count: 1
tagged with: junit
has body: I'm writing a JUnit test using JUnitPerf. Here, I want to generate some entries and use them to update a database. To test the capacity of the database, I want several test to run simultaneously or randomly, so I use, for example: Test loadTest = new LoadTest(testCase, n); But, still, I have to insure that in each test, a different update source will be used so that a different entry in the database will be updated. So my question is how can I realize this? Thanks a lot Allen
tagged with: junitperf
type: AnsweredQuestion

http://stackoverflow.com/a/2693188
type: Answer
answers question: http://stackoverflow.com/q/2693180
accepted answer of: http://stackoverflow.com/q/2693180
has comment: http://stackoverflow.com/comment/38406533
has comment: http://stackoverflow.com/comment/38378415
has comment: http://stackoverflow.com/comment/102589696
has body: Unchecked cast means that you are (implicitly or explicitly) casting from a generic type to a nonqualified type or the other way around. E.g. this line Set&lt;String&gt; set = new HashSet(); will produce such a warning. Usually there is a good reason for such warnings, so you should try to improve your code instead of suppressing the warning. Quote from Effective Java, 2nd Edition: Eliminate every unchecked warning that you can. If you eliminate all warnings, you are assured that your code is typesafe, which is a very good thing. It means that you won’t get a ClassCastException at runtime, and it increases your confidence that your program is behaving as you intended. If you can’t eliminate a warning, and you can prove that the code that provoked the warning is typesafe, then (and only then) suppress the warning with an @SuppressWarnings("unchecked") annotation. If you suppress warnings without first proving that the code is typesafe, you are only giving yourself a false sense of security. The code may compile without emitting any warnings, but it can still throw a ClassCastException at runtime. If, however, you ignore unchecked warnings that you know to be safe (instead of suppressing them), you won’t notice when a new warning crops up that represents a real problem. The new warning will get lost amidst all the false alarms that you didn’t silence. Of course, it is not always as easy to eliminate warnings as with the code above. Without seeing your code, there is no way to tell how to make it safe though.
has comment: http://stackoverflow.com/comment/48324753
has comment: http://stackoverflow.com/comment/48640487
has comment: http://stackoverflow.com/comment/6575526
upvote count: 49
has comment: http://stackoverflow.com/comment/38430980
type: AcceptedAnswer
downvote count: 10
has comment: http://stackoverflow.com/comment/38421190
score: 39
has comment: http://stackoverflow.com/comment/6575275

http://stackoverflow.com/a/2770448
has body: The add method is add(E e), so all is right with the world in that respect. The remove(Object o) and contains(Object o) methods will operate based on o.equals(e). This allows you to do some tricky things with special-purpose comparison objects that aren't necessarily the type of object that are in the collection. List&lt;Integer&gt; list = Arrays.asList(20, 30, 40, 50, 100); boolean moreThan60 = list.contains(new Object() { public boolean equals(Object rhs) { return ((Integer)rhs) &gt; 60; } }); System.out.println("moreThan60 = " + moreThan60); Not that this is always recommended, or even a best practice. But it is a neat trick.
accepted answer of: http://stackoverflow.com/q/2770394
type: Answer
upvote count: 4
score: 3
has comment: http://stackoverflow.com/comment/2805492
answers question: http://stackoverflow.com/q/2770394
type: AcceptedAnswer
downvote count: 1

http://stackoverflow.com/comment/2665552
type: AnswerComment
has text: The logic which determines how many times I want to execute it, is defined in onJobDone()... not in onNewEvent()... because sometimes, job may be sent for execution.. but it can't be done.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2649416

http://stackoverflow.com/q/2752141
accepted answer: http://stackoverflow.com/a/2752163
has comment: http://stackoverflow.com/comment/2782727
has title: How should I handle searching through byte arrays in Java?
has comment: http://stackoverflow.com/comment/2782704
answer count: 2
tagged with: arrays
downvote count: 0
has comment: http://stackoverflow.com/comment/2782716
tagged with: parsing
favorite count: 0
has answer: http://stackoverflow.com/a/2752163
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2752177
score: 1
tagged with: java
upvote count: 1
tagged with: http
possible better answer: http://stackoverflow.com/a/2752177
type: Question
has body: Preliminary: I am writting my own httpclient in Java. I am trying to parse out the contents of chunked encoding. Here is my dilema: Since I am trying to parse out chunked http transfer encoding with a gzip payload there is a mix of ascii and binary. I can't just take the http resp content and convert it to a string and make use of StringUtils since the binary data can easily contain nil characters. So what I need to do is some basic things for parsing out each chunk and its chunk length (as per chunked transfer/HTTP/1.1 spec). Are there any helpful ways of searching through byte arrays of binary/part ascii data for certain patterns (like a CR LF) (instead of just a single byte) ? Or must I write the for loops for this?

http://stackoverflow.com/comment/2643171
has text: @Shervin Interesting, Shervin (+1) Why does Injection of the ComponentA fails when injecting in ComponentC (I suppose it is because of create=true) Am i right ?
type: Comment
comment on: http://stackoverflow.com/a/2630027
score: 0
type: AnswerComment

http://stackoverflow.com/a/2609196
type: Answer
answers question: http://stackoverflow.com/q/2609141
has body: A couple of suggestions: Add a tooltip to the JTable using setToolTipText(String). You'll need to add it to the surrounding JScrollPane in order for the tooltip to be displayed when the user hovers on the empty viewport. Add a titled Border; e.g. scrollPane.setBorder(BorderFactory.createTitledBorder("Drag items here"));
upvote count: 1
has comment: http://stackoverflow.com/comment/2619912
score: 1
downvote count: 0

webpage-screenshot
type: Tag
tags question: http://stackoverflow.com/q/2746289
tag name: webpage-screenshot

http://stackoverflow.com/q/2608039
has answer: http://stackoverflow.com/a/2608059
type: Question
has title: java: how can I create a dynamic array without forcing the type of the values?
has answer: http://stackoverflow.com/a/2608050
has body: I need to create a dynamic array in Java, but the values type differ from String to Int to float. how can I create a dynamic list that I don't need to give it in advanced the type of the values? The keys just need to be ascending numbers (1,2,3,4 or 0,1,2,3,4) I checked ArrayList but it seems that I have to give it a fixed type for the values. thanks!
has answer: http://stackoverflow.com/a/2608268
upvote count: 5
tagged with: java
score: 5
tagged with: arrays
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/2608050
has answer: http://stackoverflow.com/a/2608302
possible better answer: http://stackoverflow.com/a/2608059
answer count: 4
type: AnsweredQuestion

http://stackoverflow.com/q/2710814
has answer: http://stackoverflow.com/a/2710999
upvote count: 2
possible better answer: http://stackoverflow.com/a/2710862
answer count: 3
tagged with: http://stackoverflow.com/tag/html
has answer: http://stackoverflow.com/a/2710862
downvote count: 1
favorite count: 0
tagged with: jlabel
has answer: http://stackoverflow.com/a/2710979
accepted answer: http://stackoverflow.com/a/2710979
tagged with: swing
type: AnsweredQuestion
score: 1
has title: Restrict number of lines in html JLabel
tagged with: java
type: Question
has body: I have a JLabel that needs to display some html-formatted text. However, I want to restrict this to being 4 lines long (and if so, provide a button to see everything). So far, I've tried setting the maximum size manually or via a layout manager. However, both of these solutions can cause part of a line to be displayed. edit: To add a little more details, I need to force 4 lines even when respecting line wrapping correctly, resizing components, and changing font sizes. I've considered handling resize/fontsize changes by replacing the label with a new one that fits correctly. JLabel seems to handle incomplete tags well, so I could probably do something like a binary search on the input string finding which character would cause it to go over the 4 line limit (using FontMetric to determine how many pixels 4 lines would be), and then replacing an existing label with the new one. The big downside to this approach is that I need to run the computation every time the user resizes the panel or changes fonts (and it feels like a dirty dirty hack).

http://stackoverflow.com/comment/2774830
has text: @Peter: class literals aren't types. Many genericized types, which are invariant and not assignment-compatible among each other, really are instances of the same class at run-time. It doesn't make any sense to allow generics for class literals.
type: Comment
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/2745230

http://stackoverflow.com/a/2633509
answers question: http://stackoverflow.com/q/2633185
has body: Use VC++ to create a native application, then compress it using an executable file compressor.
score: 0
type: Answer

http://stackoverflow.com/comment/29428094
score: 1
has text: @naxa Better something than nothing. Also, you can nest pairs.
comment on: http://stackoverflow.com/a/14174832
type: AnswerComment
type: Comment

http://stackoverflow.com/a/2641575
answers question: http://stackoverflow.com/q/2640727
score: 0
type: Answer
has body: I'm not a Java master, but I think that you'd better avoid naming the parameters the same way as you name a class. When you write: public static void printDice (Dice Dice) { /* ... */ } you're walking on the thin ice, dude. Reading your code it's hard to know if you call the static methods or the instance ones. I have to admit that i was surprised that Java allows something like that as it seems to be very dangerous and hard to understand when reading. In a free time - while not coding - read some Uncle Bob's texts ;) Peace!

authentication
tags question: http://stackoverflow.com/q/2687864
tags question: http://stackoverflow.com/q/2636113
tags question: http://stackoverflow.com/q/2622555
tags question: http://stackoverflow.com/q/2666817
tag name: authentication
tags question: http://stackoverflow.com/q/2758248
type: Tag
tags question: http://stackoverflow.com/q/2675524
tags question: http://stackoverflow.com/q/2725043
tags question: http://stackoverflow.com/q/2671295
tags question: http://stackoverflow.com/q/2669375
tags question: http://stackoverflow.com/q/2668698

http://stackoverflow.com/a/18148206
has comment: http://stackoverflow.com/comment/116141289
has comment: http://stackoverflow.com/comment/115959020
downvote count: 0
has comment: http://stackoverflow.com/comment/116142480
has body: For me the easiest way was to: Font font = new Font("Helvetica",Font.PLAIN,12); Canvas c = new Canvas(); FontMetrics fm = c.getFontMetrics(font); Benefits: If you call c.getGraphics() it will return null (thus there is no graphics object) This (canvas) will also work in headless mode. Now you can easily get height and width...
type: Answer
score: 12
has comment: http://stackoverflow.com/comment/116096492
upvote count: 12
answers question: http://stackoverflow.com/q/2753514

http://stackoverflow.com/comment/2624330
score: 0
type: AnswerComment
type: Comment
has text: Hi, I installed this tool, got it working etc, but can you get it to sort of draw up everything automatically like assosiations and what not?
comment on: http://stackoverflow.com/a/2600272

http://stackoverflow.com/comment/2723520
has text: It's `IllegalArgumentException`, but this is the right answer.
score: 1
comment on: http://stackoverflow.com/a/2700778
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2772370
has text: `setBounds` actually *sets* the bounds, so yes, you could constrain the height in that call. If you want you could `setMaximumSize` on the `JList`, and then respect maximum / minimum / preferred size when adjusting the bounds.
type: AnswerComment
comment on: http://stackoverflow.com/a/2742966
type: Comment
score: 1

http://stackoverflow.com/a/2667408
has body: Well, as this event may trigger table repaint, it should be in the EDT, yes. But you can rely upon SwingUtilities.invokeLater to have only the relevant part called in EDT.
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2667346
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2667346
upvote count: 2
type: Answer
score: 2

http://stackoverflow.com/comment/2716257
score: 0
type: AnswerComment
has text: It's a scope problem, not a shadowing problem.
type: Comment
comment on: http://stackoverflow.com/a/2694482

http://stackoverflow.com/comment/2677674
has text: converting the milliseconds into minutes (which was what I was looking for) isn't hard at all :) (dividing by 60,000) thanks!
comment on: http://stackoverflow.com/a/2660080
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/2690899
has comment: http://stackoverflow.com/comment/2712405
answer count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/2718029
has title: Can IDEA connect to a CVS repo over extssh?
favorite count: 0
has comment: http://stackoverflow.com/comment/2712608
type: AnsweredQuestion
score: 1
tagged with: java
upvote count: 1
has comment: http://stackoverflow.com/comment/2713172
tagged with: cvs
has body: Looks like IDEA is not supporting the extssh protocol for connecting to CVS by default. Is there a workaround available for accessing CVS through extssh? Thanks in advance.
type: Question
has answer: http://stackoverflow.com/a/2691045
accepted answer: http://stackoverflow.com/a/2691045
tagged with: intellij-idea
has comment: http://stackoverflow.com/comment/2711976

http://stackoverflow.com/comment/68874751
has text: Have a look at the HandlerExceptionResolver: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-exceptionhandlers
comment on: http://stackoverflow.com/q/2689989
type: Comment
score: 1
type: QuestionComment

http://stackoverflow.com/a/2713100
answers question: http://stackoverflow.com/q/2713033
type: AcceptedAnswer
score: 27
type: Answer
upvote count: 27
has body: The problem is that your Class1 needs a reference to IServiceReference and not the concrete reference of Class2 @Controller public class Class1 { @Autowired private IServiceReference object2; ... } The reason this is that Spring is creating a dynamic proxy for classes that you marked @Transactional. Thus when Class2 is created its wrapped in a Proxy object that is obviously not of type Class2 but is of type IServiceReference. If you want the behavior of using Class2 with proxy support you will have to turn on CGLIB Read below: From Springs Doc: Spring AOP defaults to using standard J2SE dynamic proxies for AOP proxies. This enables any interface (or set of interfaces) to be proxied. Spring AOP can also use CGLIB proxies. This is necessary to proxy classes, rather than interfaces. CGLIB is used by default if a business object does not implement an interface. As it is good practice to program to interfaces rather than classes, business classes normally will implement one or more business interfaces. It is possible to force the use of CGLIB, in those (hopefully rare) cases where you need to advise a method that is not declared on an interface, or where you need to pass a proxied object to a method as a concrete type. It is important to grasp the fact that Spring AOP is proxy-based. See the section entitled Section 6.6.1, “Understanding AOP proxies” for a thorough examination of exactly what this implementation detail actually means.
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2713033

http://stackoverflow.com/a/2599489
score: 2
downvote count: 0
has body: Using clone can be risky very risky if you don't check the implementation of this clone method... as you can suppose a clone impl can act in different ways... shallow or deep clone... and some developpers may not always check what kind of clone they will retrieve... In a big application, big team, it's also risky because when cloning is used, if you modify the clone implementation you may modify the application behaviour and create new bugs... and have to check everywhere the clone was called (but it can be the same for other object methods like equals, toString... When modifying the clone of a small subclass A (from Deep to Shallow clone for exemple), if an instance of B has a reference to A and a deep clone impl, then since the objects referenced in A are not shallow cloned, the B clone won't be a deep clone anymore (and it's the same for any class referencing a B instance...). It's not easy to deal with the deepness of your clone methods. Also when you have an interface (extending Clonable) and many (many!) implementations, sometimes you will check some impl and see that clones are deep, and call a clone on the inteface but you can't be sure at runtime all impl really have deep clone and can introduce bugs... Think it could be better to impl for each method a shallowClone and a deepClone method, and on very specific needs implement customised methods (for exemple you want a clone and limit the depth of this clone to 2, make a custom impl for that in all classes concerned). Don't think it's a big matter to use a clone method on a JDK class since it's not going to be changed by another developper, or at least not often. But you'd better not call clone on JDK classes if you don't know the class implementation at compile time. I mean calling the clone on an ArrayList is not a matter but calling it on a Collection could be dangerous since another Collection implementation could be introduced by another developper (he can even extends a Collection impl) and nothing tel…
upvote count: 2
type: Answer
answers question: http://stackoverflow.com/q/2597965

http://stackoverflow.com/a/2676848
has comment: http://stackoverflow.com/comment/2696551
score: 5
answers question: http://stackoverflow.com/q/2676829
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2676829
type: Answer
has comment: http://stackoverflow.com/comment/2697614
has comment: http://stackoverflow.com/comment/2695823
has comment: http://stackoverflow.com/comment/2695941
upvote count: 5
has body: The method decompile is thread-safe (it will never be running on two threads concurrently), but if anything other than that method also uses the namesMap, then no, overall this is not thread-safe: Another method other than decompile running on a different thread could modify the map while the decompile method is using it, presumably causing mayhem. :-) You might look at the classes in the java.util.concurrent namespace (for instance, ConcurrentHashMap) to see if any of those are applicable to what you're doing. Edit (Responding to your comment.) If the static member namesMap is only ever used by decompile and not by anything else (you don't get a reference to it to anything else, etc.), then you're fine. The fact it's a static doesn't matter, if the only place it's used is serialized.

http://stackoverflow.com/q/2606424
has answer: http://stackoverflow.com/a/70871675
favorite count: 0
answer count: 5
tagged with: size
has body: I've developed a module for a Java project. The module depends on external library (fastutil). The problem is, the fastutil.jar file is a couple of times heavier than the whole project itself (14 MB). I only use a tiny subset of the classes from the library. The module is now finished, and no-one is likely to extend it in future. Is there a way I could extract only the relevant class to some fastutil_small.jar so that others don't have to download all this extra weight?
has answer: http://stackoverflow.com/a/2606459
score: 8
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2616645
downvote count: 0
has title: Reduce external jar file size
upvote count: 8
type: Question
has answer: http://stackoverflow.com/a/2606486
accepted answer: http://stackoverflow.com/a/2606456
tagged with: java
possible better answer: http://stackoverflow.com/a/2606482
has answer: http://stackoverflow.com/a/2606456
tagged with: jar
has answer: http://stackoverflow.com/a/2606482

http://stackoverflow.com/a/2629377
upvote count: 2
type: Answer
score: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/65239022
answers question: http://stackoverflow.com/q/2629357
has body: Java has references. All objects are accessed through having references to their instances. You create a new instance using new, which returns a reference to the object. Java references are not like pointers in C, you cannot "look under the hood" at the raw memory that makes up the object.

http://stackoverflow.com/q/2681086
favorite count: 0
has title: How do I keep a dialog box always on top?
has body: I created a dialog box like this: String response = JOptionPane.showInputDialog(null,"message","title",JOptionPane.PLAIN_MESSAGE); I'd like to keep it always on top of all windows. Do you have any idea? Thanks!
score: 2
has answer: http://stackoverflow.com/a/2681124
upvote count: 2
tagged with: swing
possible better answer: http://stackoverflow.com/a/2681157
has answer: http://stackoverflow.com/a/2681157
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/2681124
type: Question
answer count: 2
tagged with: modal-dialog
downvote count: 0

http://stackoverflow.com/comment/131170336
score: 2
has text: I like this because its better than superclassThingList = new Array(subclassOfThingList);
type: AnswerComment
comment on: http://stackoverflow.com/a/72196150
type: Comment

http://stackoverflow.com/a/2637332
answers question: http://stackoverflow.com/q/2632211
downvote count: 0
type: Answer
score: 1
upvote count: 1
has body: Most of the current regex email validators doesn't take into account that "unicode characters" like Chinese and Arabic in domain names are to be allowed in the near future. Everyone has to change the email regex used, because those characters are surely not to be covered by [a-z]/i nor \w in common regex solutions. They will all fail. After all, the best way to validate the email address is still to actually send an email to the address in question to validate the address. The enduser can namely stil enter a syntactically valid emailaddress like w40ejk5gdf8sg@xl5er8kw8tklt.com but which is obviously non-existent. If the email address is part of user authentication (register/login/etc), then you can perfectly combine it with the user activation system. I.e. send an email with a link with an unique activation key to the specified email address and only allow login when the user has activated the newly created account using the link in the email. If the purpose of the regex is just to quickly inform the user in the UI that the specified email address doesn't look like in the right format, best is still to check if it matches basically the following regex: ^([^.@]+)(\.[^.@]+)*@([^.@]+\.)+([^.@]+)$ Simple as that. No need to care about the characters used in the name and domain. It's after all the client's responsibility to enter a legit email address, not the server's. In Java you could use the above regex as: public static boolean isValidEmail(String value) { return value.matches("^([^.@]+)(\\.[^.@]+)*@([^.@]+\\.)+([^.@]+)$"); }

http://stackoverflow.com/comment/65311493
score: 1
has text: Just discovered for myself that eclipse has "Generate hashCode() and equals" under Source menu.
type: AnswerComment
comment on: http://stackoverflow.com/a/2642709
type: Comment

http://stackoverflow.com/q/2721390
answer count: 10
has answer: http://stackoverflow.com/a/63929086
has answer: http://stackoverflow.com/a/31279873
has title: How to add two java.lang.Numbers?
favorite count: 0
has answer: http://stackoverflow.com/a/30479040
has answer: http://stackoverflow.com/a/2721519
has answer: http://stackoverflow.com/a/2721491
upvote count: 54
has comment: http://stackoverflow.com/comment/2748105
has answer: http://stackoverflow.com/a/2721438
type: AnsweredQuestion
score: 54
has body: I have two Numbers. Eg: Number a = 2; Number b = 3; //Following is an error: Number c = a + b; Why arithmetic operations are not supported on Numbers? Anyway how would I add these two numbers in java? (Of course I'm getting them from somewhere and I don't know if they are Integer or float etc).
tagged with: java
has answer: http://stackoverflow.com/a/2721492
type: Question
accepted answer: http://stackoverflow.com/a/2721491
has answer: http://stackoverflow.com/a/30110482
has comment: http://stackoverflow.com/comment/2748128
has answer: http://stackoverflow.com/a/2721511
has answer: http://stackoverflow.com/a/2721416
possible better answer: http://stackoverflow.com/a/30110482
downvote count: 0

http://stackoverflow.com/a/2710812
downvote count: 0
has body: JLS 14.7 Labeled statements (edited for clarity) Statements may have label prefixes (Identifier : Statement). The Identifier is declared to be the label of the immediately contained Statement. Unlike C and C++, the Java programming language has no goto statement; identifier statement labels are used with break (§14.15) or continue (§14.16) statements appearing anywhere within the labeled statement. So the JLS is clear that labels are used with break or continue, and no other grammatical element of the Java programming language uses it. Strictly speaking, break and continue, labeled or not, are NEVER necessary. They can always be written out of the code. Used idiomatically, however, they can lead to more readable code. Here's an illustrative example: given an int[], we want to : print "One (1)" on 1 print "Two (2)" on 2 print "Zero " on 0 immediately stop processing on any other number int[] arr = { 1, 2, 0, 1, -1, 0, 2 }; loop: for (int num : arr) { switch (num) { case 1: System.out.print("One "); break; case 2: System.out.print("Two "); break; case 0: System.out.print("Zero "); continue loop; default: break loop; } System.out.print("(" + num + ") "); } // prints "One (1) Two (2) Zero One (1) " Here we see that: The different numbers are processed in a switch Unlabeled break in the switch is used to avoid "fall-through" between cases Labeled continue loop; is used to skip post-processing on case 0: (the label is not necessary here) Labeled break loop; is used to terminate the loop on default: (the label is necessary here; otherwise it's a switch break) So labeled break/continue can also be used outside of nested loops; it can be used when a switch is nested inside a loop. More generally, it's used when there are potentially multiple break/continue target, and you want to choose one that is not immediately enclosing the break/continue statement. Here's another example: morningRoutine: { phase1: eatBreakfast(); if (grumpy) break morningRoutine; phase2: kissWife(); pha…
type: Answer
score: 21
has comment: http://stackoverflow.com/comment/29830231
has comment: http://stackoverflow.com/comment/138042740
upvote count: 21
accepted answer of: http://stackoverflow.com/q/2710422
answers question: http://stackoverflow.com/q/2710422
type: AcceptedAnswer

http://stackoverflow.com/a/2631894
has body: Same issue as here, I think: http://forums.sun.com/thread.jspa?threadID=5435426 At least the solution works for this issue, too: add "-Dsun.security.ssl.allowUnsafeRenegotiation=true"
answers question: http://stackoverflow.com/q/2606873
downvote count: 2
type: Answer
upvote count: 3
score: 1
accepted answer of: http://stackoverflow.com/q/2606873
type: AcceptedAnswer

http://stackoverflow.com/a/2756831
answers question: http://stackoverflow.com/q/2756772
accepted answer of: http://stackoverflow.com/q/2756772
type: AcceptedAnswer
downvote count: 0
type: Answer
upvote count: 7
has body: &lt;h:graphicImage&gt; uses context-relative paths. &lt;h:outputLink&gt; uses absolute paths. That's why you can't use the / (unless in the root context). You can use something like value="#{facesContext.externalContext.context.contextPath}/#{bean.path}" to specify that the start of the path is the context root, not the server root.
score: 7

http://stackoverflow.com/comment/15201528
has text: You can simply replace your inner loop with `result *= 10;`.
score: 2
type: AnswerComment
comment on: http://stackoverflow.com/a/10578427
type: Comment

http://stackoverflow.com/comment/2747064
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/2720689
has text: To all those that depend on interrupt: Just wish to say that life is never that simple and there are times when one calls interrupt on a non interruptible "activity" and that activity takes absolutely no notice of the interrupt. This from experience. Despite that, I do not know of a better way... Please take a careful view of the API: http://java.sun.com/javase/6/docs/api/index.html?java/lang/Thread.html check out the interrupt() method

http://stackoverflow.com/a/2616405
type: Answer
answers question: http://stackoverflow.com/q/2616341
score: 7
upvote count: 7
downvote count: 0
has body: You cannot do that. The behavior of Alt+Ctrl+Del is enforced by the operating system, for good reasons: it makes sure that you can always bail-out of a faulty application.

http://stackoverflow.com/comment/2697255
type: Comment
has text: The queues are not Strings. The queues are queues. We have a conceptual disconnect here. If you have two threads mutating a queue concurrently, absent inter-thread synchronization, how do you know which thread completed the mutation first? What are your expectations about message ordering that isn't being met by the program that makes you think there's a bug *anywhere*?
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2677547

http://stackoverflow.com/comment/2722491
type: AnswerComment
comment on: http://stackoverflow.com/a/2676700
type: Comment
has text: While the potential problems with long being represented as two words with no guaranteed atomic writes is a general issue, agreed, in the case of switch it would be an even more pronounced danger. It's like sending an envelope with a message where half the address is from one person, half is from another - the final address could be valid and correspond to a totally random chap who would then receive the envelope and act accordingly. It's one thing reading garbage and producing garbage (like a wrong boolean), but reading garbage and doing random jumps *does* sound a tad more dangerous to me.
score: 0

http://stackoverflow.com/comment/2795257
score: 0
type: Comment
comment on: http://stackoverflow.com/q/2762936
type: QuestionComment
has text: You might want to check out this thread - http://stackoverflow.com/questions/371538/any-good-orm-tools-for-android-development

http://stackoverflow.com/q/2686181
favorite count: 0
upvote count: 8
has answer: http://stackoverflow.com/a/2686222
has title: How to access a superclass method from a nested class?
type: AnsweredQuestion
tagged with: java
possible better answer: http://stackoverflow.com/a/2686200
type: Question
accepted answer: http://stackoverflow.com/a/2686222
answer count: 2
has answer: http://stackoverflow.com/a/2686200
has body: I hope this code explains the problem: class Foo { void a() { / *stuff */ } } class Bar extends Foo { void a() { throw new Exception("This is not allowed for Bar"); } class Baz { void blah() { // how to access Foo.a from here? } } } I know that I may be doing something wrong, because inheritance perhaps shouldn't be used in such way. But it's the easiest way in my situation. And, beside that, I'm just curious. Is it possible?
tagged with: inheritance
downvote count: 0
score: 8

http://stackoverflow.com/comment/78033531
type: Comment
comment on: http://stackoverflow.com/a/2717366
score: 4
type: AnswerComment
has text: .. and with a ton of source files. I just want a ten line program . Where is it?

http://stackoverflow.com/q/2765876
answer count: 2
accepted answer: http://stackoverflow.com/a/2768649
favorite count: 0
has title: Java object to XML Elements?
has body: I'm working on a webservices client app and I have it mostly working. I can retrieve and read data from the third-party webservice fine. Now I need to submit some data and I'm stuck. The classes for the objects I'm retrieving/submitting were generated from XSD files via the xjc tool. The part I'm stuck on is turning one of those objects into an XML tree to submit to the webservice. When I retrieve/send a request from/to the ws, it contains a 'payload' object. This is defined in java code as (partial listing): @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "PayloadType", propOrder = { "compressed", "document", "any", "format" }) public class PayloadType { @XmlElement(name = "Compressed") protected String compressed; @XmlElement(name = "Document") protected List&lt;String&gt; document; @XmlAnyElement protected List&lt;Element&gt; any; protected String format; public List&lt;Element&gt; getAny() { if (any == null) { any = new ArrayList&lt;Element&gt;(); } return this.any; } } The only field I'm concerned with is the 'any' field which contains an XML tree. When I retrieve data from the ws, I read that field with something like this: ('root' is of org.w3c.dom.Element type and is the result of calling 'getAny().get(0)' on the payload object) NodeList nl = root.getElementsByTagName("ns1:Process"); // "ns1:Process" is an XML node to do something with if (nl != null &amp;&amp; nl.getLength() &gt; 0) { for (int i = 0; i &lt; nl.getLength(); i++) { Element proc = (Element) nl.item(i); try { // do something with the 'proc' Element here... } catch (Exception ex) { // handle problems here... } } } Submitting data is where I'm stuck. How do I take a java object created from one of the classes generated from XSD and turn it into an Element object that I can add to the 'any' List of the payload object?? For instance, if I have a DailyData class and I create and populate it with data: DailyData dData = new DailyData(); dData.setID = 34; dData.setValues = "3,5,76,23"; How do I …
tagged with: web-services
upvote count: 4
has answer: http://stackoverflow.com/a/2768649
tagged with: http://stackoverflow.com/tag/xml
possible better answer: http://stackoverflow.com/a/2767195
type: AnsweredQuestion
downvote count: 0
has comment: http://stackoverflow.com/comment/2801145
tagged with: java
tagged with: jaxb
type: Question
has answer: http://stackoverflow.com/a/2767195
score: 4
has comment: http://stackoverflow.com/comment/6133761

http://stackoverflow.com/comment/16532029
type: AnswerComment
type: Comment
has text: Do you mean anonymous class rather than inner class?
comment on: http://stackoverflow.com/a/2600481
score: 0

http://stackoverflow.com/comment/2695788
type: AnswerComment
comment on: http://stackoverflow.com/a/2675376
has text: @Roman well, yes, that would be better, except for the fact there is no a method to know if a port is available. If `new ServerSocket(0)` is not working for your the alternative is this. I think there are 85% of possibilities you end up using my suggestion.
type: Comment
score: 2

http://stackoverflow.com/comment/10323005
type: Comment
score: 1
has text: this is a good suggestion but http://stackoverflow.com/questions/807263/how-do-i-detect-which-kind-of-jre-is-installed-32bit-vs-64bit suggests that `"os.arch"` returns inconsistent results.
type: AnswerComment
comment on: http://stackoverflow.com/a/4133954

http://stackoverflow.com/a/2629249
upvote count: 5
has comment: http://stackoverflow.com/comment/2642547
has comment: http://stackoverflow.com/comment/2642307
has comment: http://stackoverflow.com/comment/2643347
has comment: http://stackoverflow.com/comment/2642507
has comment: http://stackoverflow.com/comment/2642287
has body: finalize method of the Object class is called just before the GC collects the object. Override the method in your class as follows: @Override protected void finalize() throws Throwable { System.out.println(this+" collected"); super.finalize(); } Note that you can only monitor your own classes with this method. So, since String is a final class, you cannot monitor a String object with this way.
score: 4
type: Answer
has comment: http://stackoverflow.com/comment/2642573
has comment: http://stackoverflow.com/comment/2642318
has comment: http://stackoverflow.com/comment/65304309
downvote count: 1
has comment: http://stackoverflow.com/comment/2642529
answers question: http://stackoverflow.com/q/2629180

capture
tags question: http://stackoverflow.com/q/2667172
type: Tag
tag name: capture

http://stackoverflow.com/a/2730868
has comment: http://stackoverflow.com/comment/2758803
score: 1
answers question: http://stackoverflow.com/q/2730796
has body: I can suggest you only exception-based solution i.e. try to read each file with ImageIO and if exception is thrown then it's not an image file. But it's a bad solution. You'd better find an opportunity to distinguish them in some other more logical way.
upvote count: 1
has comment: http://stackoverflow.com/comment/2758550
downvote count: 0
type: Answer

http://stackoverflow.com/a/2679869
type: Answer
has comment: http://stackoverflow.com/comment/2912186
downvote count: 0
has comment: http://stackoverflow.com/comment/2702889
score: 13
has body: I experimented a bit with the performance of various constructs, and unfortunately I discovered that Java regex doesn't perform what I consider very doable optimizations. Java regex takes O(N) to match "(?s)^.*+$" This is very disappointing. It's understandable for ".*" to take O(N), but with the optimization "hints" in the form of anchors (^ and $) and single-line mode Pattern.DOTALL/(?s), even making the repetition possessive (i.e. no backtracking), the regex engine still could not see that this will match every string, and still have to match in O(N). This pattern isn't very useful, of course, but consider the next problem. Java regex takes O(N) to match "(?s)^A.*Z$" Again, I was hoping that the regex engine can see that thanks to the anchors and single-line mode, this is essentially the same as the O(1) non-regex: s.startsWith("A") &amp;&amp; s.endsWith("Z") Unfortunately, no, this is still O(N). Very disappointing. Still, not very convincing because a nice and simple non-regex alternative exists. Java regex takes O(N) to match "(?s)^.*[aeiou]{3}$" This pattern matches strings that ends with 3 lowercase vowels. There is no nice and simple non-regex alternative, but you can still write something non-regex that matches this in O(1), since you only need to check the last 3 characters (for simplicity, we can assume that the string length is at least 3). I also tried "(?s)^.*$(?&lt;=[aeiou]{3})", in an attempt to tell the regex engine to just ignore everything else, and just check the last 3 characters, but of course this is still O(N) (which follows from the first section above). In this particular scenario, however, regex can be made useful by combining it with substring. That is, instead of seeing if the whole string matches the pattern, you can manually restrict the pattern to attempt to match only the last 3 characters substring. In general, if you know before hand that the pattern has a finite length maximum match, you can substring the necessary amount of char…
has comment: http://stackoverflow.com/comment/2699526
has comment: http://stackoverflow.com/comment/2699723
has comment: http://stackoverflow.com/comment/83561667
upvote count: 13
answers question: http://stackoverflow.com/q/2667015

http://stackoverflow.com/comment/2610154
has text: @PeterMmm good. btw, it is an accepted practice to upvote useful (inc. the accepted) answers. You have only 2 upvotes, which is contrary to the idea of SO.
comment on: http://stackoverflow.com/a/2600890
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/102333257
score: 2
comment on: http://stackoverflow.com/a/50274496
type: AnswerComment
type: Comment
has text: Thank you! Just change `TrustAllStrategy.INSTANCE` with `TrustSelfSignedStrategy.INSTANCE` in this answer.

http://stackoverflow.com/a/44042759
score: 0
type: Answer
has body: i am using this code. it can also help. private String getText(int minutes){ int weeks = minutes / 10080; int aboveWeeks = minutes % 10080; int days = aboveWeeks / 1440; int aboveDays = aboveWeeks % 1440; int hours = aboveDays / 60; int aboveHours = aboveDays % 60; int minute = aboveHours / 60; if(weeks &gt; 0 &amp;&amp; days &gt; 0) { if(weeks &gt; 1 &amp;&amp; days &gt; 1){ return weeks + " weeks " + days + " days before"; } else { return weeks + " weeks " + days + " day before"; } } else if (weeks &gt; 0){ if (weeks &gt; 1){ return weeks + " weeks before"; } else { return weeks + " week before"; } } else if(days &gt; 0 &amp;&amp; hours &gt; 0){ if(days &gt; 1 &amp;&amp; hours &gt; 1){ return days + " days " + hours + " hours before"; } else { return days + " days " + hours + " hour before"; } } else if(days &gt; 0){ if (days &gt; 1){ return days + " days before"; } else { return days + " day before"; } } else if(hours &gt; 0 &amp;&amp; minute &gt; 0){ if(hours &gt; 1 &amp;&amp; minute &gt; 1){ return hours + " hours " + minute + " minutes before"; } else { return hours + " hours " + minute + " minute before"; } } else if(hours &gt; 0){ if (hours &gt; 1){ return hours + " hours before"; } else { return hours + " hour before"; } } else { if (minutes &gt; 1){ return minutes + " minutes before"; } else { return minutes + " minute before"; } } }
answers question: http://stackoverflow.com/q/2751073

http://stackoverflow.com/a/2642263
type: Answer
answers question: http://stackoverflow.com/q/2642144
score: 2
has body: not really an answer, but I think your code would be simpler if you used a boolean instead of an int, something like: public void actionPerformed(ActionEvent e){ final boolean isEnabled = UI.getInstance().change.isEnabled(); if(isEnabled){ UI.getInstance().startStop.setName("STOP"); }else{ UI.getInstance().startStop.setName("START"); } UI.getInstance().change.setEnabled(!isEnabled); }
upvote count: 2
downvote count: 0

integer-overflow
tags question: http://stackoverflow.com/q/2728793
tags question: http://stackoverflow.com/q/2632392
tag name: integer-overflow
type: Tag

http://stackoverflow.com/comment/2658485
comment on: http://stackoverflow.com/a/2636266
has text: Aah yes no that is not one I do. What we have done is hook the Organization directly (as foreign key) against all the relevant tables. Seemed like the easiest solutions, but it doesnt feel right. Thats why I wanted to know of a better solution
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/3265991
type: QuestionComment
comment on: http://stackoverflow.com/q/2674600
has text: Hi Jens, Take a look At: http://www.jroller.com/eyallupu/entry/hibernate_exception_simultaneously_fetch_multiple http://www.jroller.com/eyallupu/entry/solving_simultaneously_fetch_multiple_bags and https://forum.hibernate.org/viewtopic.php?t=974127 I hope it can be useful
score: 0
type: Comment

http://stackoverflow.com/comment/2714181
comment on: http://stackoverflow.com/a/2692604
type: AnswerComment
has text: My question was badly stated, really sorry to waste your time due to that. But if you read the comment I replied to the first answer I hope I managed to describe my problem I a better way. This was a real cool way to do it though. Cheers!
type: Comment
score: 0

http://stackoverflow.com/q/2680828
answer count: 4
score: 3
upvote count: 3
tagged with: java
has title: Java Refreshing a screen
has body: I have a screen in which one of its components is made invisible depending on a boolean value. If the boolean changes after the screen has been created, how do I refresh the screen to take this into account?
has answer: http://stackoverflow.com/a/2682713
tagged with: swing
type: Question
has answer: http://stackoverflow.com/a/2680909
has answer: http://stackoverflow.com/a/2680858
downvote count: 0
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2681166

http://stackoverflow.com/q/2700705
has comment: http://stackoverflow.com/comment/2723416
has answer: http://stackoverflow.com/a/2700746
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2700936
has comment: http://stackoverflow.com/comment/2724714
score: 1
has answer: http://stackoverflow.com/a/2700778
accepted answer: http://stackoverflow.com/a/2700778
type: Question
has answer: http://stackoverflow.com/a/2700975
has title: handling java exception
tagged with: java
answer count: 6
upvote count: 1
downvote count: 0
favorite count: 0
has body: This questions is related to java exceptions, why are there some cases that when an exception is thrown the program exits even though the exception was caught and there was no exit() statement? my code looks something like this void bindProxySocket(DefaultHttpClientConnection proxyConnection, String hostName, HttpParams params) { if (!proxyConnection.isOpen()) { Socket socket = null; try { socket = new Socket(hostName, 80); } catch (UnknownHostException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } try { proxyConnection.bind(socket, params); } catch(IOException e) { System.err.println ("couldn't bind socket"); e.printStackTrace(); } } } and then I call this method like this: bindProxySocket(proxyConn, hostName, params1); but, the program exits, although I want to handle the exception by doing something else, can it be because I didn't enclose the method call within a try catch clause? what happens if I catch the exception again even though it's already in the method? and what should I do if i want to clean resources in the finally clause only if an exception occurs and otherwise I want to continue with the program? I am guessing in this case I have to include the whole piece of code until I can clean the resources with in a try statement or can I do it in the handle exception statement? some of these questions are on this specific case, but I would like to get a thorough answer to all my questions for future reference. thanks edit: java.net.UnknownHostException: www.dsewew324f.com at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.&lt;init&gt;(Unknown Source) at java.net.Socket.&lt;init&gt;(Unknown Source) at homework3.Proxy.bindProxySocket(Proxy.java:666) at homework3.Proxy$3.handle(Proxy.java:220) at org.apache.http.protocol.HttpService.doService(HttpService.java:293) at org.apach…
possible better answer: http://stackoverflow.com/a/2700746
tagged with: exception
has answer: http://stackoverflow.com/a/2700782
has answer: http://stackoverflow.com/a/2700740

http://stackoverflow.com/comment/2816461
type: AnswerComment
has text: (continued) in the subclass that would just return a B. But this function would be an identical copy of A.getFoo, except that the object it returns would be declared as B instead of A. I can't imagine how writing the exact same code twice except using a subclass instead of the original would be considered a virtue. That's what generics were to supposed to be for: So we didn't have to write exactly the same code multiple times. (Besides, a B IS an A, so if someone wrote "B b=new B(); A a=b.getFoo()", it would work just fine. No contract is broken.)
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2769343

http://stackoverflow.com/q/2681415
answer count: 2
downvote count: 0
possible better answer: http://stackoverflow.com/a/2681637
linked to: http://stackoverflow.com/q/1072383
has title: Null-free "maps": Is a callback solution slower than tryGet()?
accepted answer: http://stackoverflow.com/a/2684447
tagged with: architecture
has body: In comments to "How to implement List, Set, and Map in null free design?", Steven Sudit and I got into a discussion about using a callback, with handlers for "found" and "not found" situations, vs. a tryGet() method, taking an out parameter and returning a boolean indicating whether the out parameter had been populated. Steven maintained that the callback approach was more complex and almost certain to be slower; I maintained that the complexity was no greater and the performance at worst the same. But code speaks louder than words, so I thought I'd implement both and see what I got. The original question was fairly theoretical with regard to language ("And for argument sake, let's say this language don't even have null") -- I've used Java here because that's what I've got handy. Java doesn't have out parameters, but it doesn't have first-class functions either, so style-wise, it should suck equally for both approaches. (Digression: As far as complexity goes: I like the callback design because it inherently forces the user of the API to handle both cases, whereas the tryGet() design requires callers to perform their own boilerplate conditional check, which they could forget or get wrong. But having now implemented both, I can see why the tryGet() design looks simpler, at least in the short term.) First, the callback example: class CallbackMap&lt;K, V&gt; { private final Map&lt;K, V&gt; backingMap; public CallbackMap(Map&lt;K, V&gt; backingMap) { this.backingMap = backingMap; } void lookup(K key, Callback&lt;K, V&gt; handler) { V val = backingMap.get(key); if (val == null) { handler.handleMissing(key); } else { handler.handleFound(key, val); } } } interface Callback&lt;K, V&gt; { void handleFound(K key, V value); void handleMissing(K key); } class CallbackExample { private final Map&lt;String, String&gt; map; private final List&lt;String&gt; found; private final List&lt;String&gt; missing; private Callback&lt;String, String&gt; handler; public CallbackExample(Map&lt;…
favorite count: 0
upvote count: 2
tagged with: collections
type: AnsweredQuestion
score: 2
tagged with: performance
tagged with: java
has answer: http://stackoverflow.com/a/2684447
has comment: http://stackoverflow.com/comment/2721485
type: Question
has answer: http://stackoverflow.com/a/2681637
has comment: http://stackoverflow.com/comment/2707897

http://stackoverflow.com/comment/2646726
has text: Not really but Lists are more practical when returning results using Hibernate.
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/2625229

http://stackoverflow.com/comment/2616879
comment on: http://stackoverflow.com/a/2606456
has text: Thanks for accepting this answer, but if you used autojar, you should probably have accepted that answer instead ;-)
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/2719253
tagged with: sockets
has body: I'm using a ServerSocket on my server and Sockets that use ObjectIOStreams to send serializable objects over the network connection. I'm developing an essentially more financial version of monopoly and thus packets being sent and confirmed as sent/received is required. Do I need to implement my own packet loss watcher or is that already taken care of with (Server)Sockets? I'm primarily asking about losing packets during network blips or whatnot, not full connection error. E.g. siblings move a lead plate between my router and computer's wi-fi adapter. http://code.google.com/p/inequity/source/browse/#svn/trunk/src/network Code can be found under network->ClientController and network->Server
type: AnsweredQuestion
tagged with: serversocket
score: 1
tagged with: java
upvote count: 1
has answer: http://stackoverflow.com/a/2719282
type: Question
tagged with: network-programming
accepted answer: http://stackoverflow.com/a/2719282
answer count: 1
downvote count: 0
favorite count: 0
has title: Can Java ServerSocket and Sockets using ObjectIOStreams lose packets?
tagged with: packet-loss

http://stackoverflow.com/comment/2808376
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2774434
has text: I may have over-simplified his question in an effort to clarify. Perhaps it's a bit more complex given the 'point' part.

http://stackoverflow.com/comment/2769383
comment on: http://stackoverflow.com/a/2740523
score: 0
type: AnswerComment
type: Comment
has text: Ok, so what should I put into attachment.setContent(attachmentData,"??") ?

http://stackoverflow.com/a/2608682
has comment: http://stackoverflow.com/comment/2619059
has comment: http://stackoverflow.com/comment/121981521
has comment: http://stackoverflow.com/comment/2619090
accepted answer of: http://stackoverflow.com/q/2608665
answers question: http://stackoverflow.com/q/2608665
has comment: http://stackoverflow.com/comment/2619040
upvote count: 322
has comment: http://stackoverflow.com/comment/2619215
has body: You can use String#replaceAll() with a pattern of ^\"|\"$ for this. E.g. string = string.replaceAll("^\"|\"$", ""); To learn more about regular expressions, have al ook at http://regular-expression.info. That said, this smells a bit like that you're trying to invent a CSV parser. If so, I'd suggest to look around for existing libraries, such as OpenCSV.
has comment: http://stackoverflow.com/comment/48656014
downvote count: 4
has comment: http://stackoverflow.com/comment/66492782
has comment: http://stackoverflow.com/comment/70050788
type: AcceptedAnswer
score: 318
has comment: http://stackoverflow.com/comment/42849319
has comment: http://stackoverflow.com/comment/2619039
has comment: http://stackoverflow.com/comment/48649126
type: Answer
has comment: http://stackoverflow.com/comment/2619516
has comment: http://stackoverflow.com/comment/2619101
has comment: http://stackoverflow.com/comment/121980866

http://stackoverflow.com/comment/36292234
comment on: http://stackoverflow.com/a/2618081
has text: @sstn agreed, although if it's a complex number then it's definitely _not_ not a number :)
score: 1
type: AnswerComment
type: Comment

http://stackoverflow.com/q/2772259
tagged with: desktop-application
answer count: 6
accepted answer: http://stackoverflow.com/a/2772321
has answer: http://stackoverflow.com/a/2772282
possible better answer: http://stackoverflow.com/a/2772266
has body: Are there any professional Java desktop applications in use? I'm asking this because I started to study Java and would like to know it's possibilities and/or domains in which java is used.
has answer: http://stackoverflow.com/a/2772266
favorite count: 0
has comment: http://stackoverflow.com/comment/2806285
has comment: http://stackoverflow.com/comment/2805844
has answer: http://stackoverflow.com/a/2854481
has answer: http://stackoverflow.com/a/2772321
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2805996
has comment: http://stackoverflow.com/comment/2805899
has comment: http://stackoverflow.com/comment/2817879
has title: Java desktop apps
has answer: http://stackoverflow.com/a/2772527
score: 1
upvote count: 3
tagged with: java
has comment: http://stackoverflow.com/comment/100727313
downvote count: 2
type: Question
has answer: http://stackoverflow.com/a/2772448
linked to: http://stackoverflow.com/q/168676
linked to: http://stackoverflow.com/q/7720
linked to: http://stackoverflow.com/q/521110

http://stackoverflow.com/comment/2710267
type: AnswerComment
score: 0
type: Comment
has text: well, I could do the evil thing and use the file system to list the package's directory... To me it makes perfect sense to put all `ParametricFunction`s into a package like `my.math.function.parametric`. But a configuration file would also require the class loader and providing an extended thing like (I'll edit the question right away) `static boolean checkParameters(...)` would still require the mechanism I asked for, no?
comment on: http://stackoverflow.com/a/2689350

http://stackoverflow.com/a/2662758
type: Answer
has body: It's not so clear but actually what you want to do is to inizialize a student without adding it to the array until you are sure that fields are correct Student[] s = new Student[5]; String name, major; double gpa; boolean isCorrect = false; Student currentStudent; // in your code there is i = 1, is it intended or mistake? for (int i=0; i &lt;= s.length; i++) { currentStudent = new Student(); while (!isCorrect) { name = JOptionPane.showInputDialog("Please Write Name for student n " + i); isCorrect = currentStudent.setName(name); if (!isCorrect) JOptionPane.showMessageDialog(null, "Errors in validating name!"); } isCorrect = false; while (!isCorrect) { major = JOptionPane.showInputDialog("Please Write Major for student n " + i); isCorrect = currentStudent.setMajor(major); if (!isCorrect) JOptionPane.showMessageDialog(null, "Errors in validating major!"); } isCorrect = false while (!isCorrect) { gpa = Double.parseDouble(JOptionPane.showInputDialog("Please Write GPA for student n " +i)); isCorrect = currentStudent.setGPA(gpa); if (!isCorrect) JOptionPane.showMessageDialog(null, "Errors in validating GPA!"); } s[i] = currentStudent; } This approach will keep asking the user the same field until it's correct.. of course your setters will need to return a boolean that is false if validation failed.
upvote count: 1
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/2662704

http://stackoverflow.com/a/2676358
has body: SpringMVC can be configured for this kind of URL routing since version 2.5. You have tu use annotations as described in http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-ann-requestmapping Good luck !
type: Answer
score: 1
answers question: http://stackoverflow.com/q/2676288
upvote count: 1
downvote count: 0

http://stackoverflow.com/comment/2786436
type: Comment
has text: Yes but from a design point of view what you are doing is relying in something that ends up looking like a static class. You have all your classes relying on an object that has a "global" state.
comment on: http://stackoverflow.com/a/2755152
type: AnswerComment
score: 0

http://stackoverflow.com/a/16786475
downvote count: 2
upvote count: 9
answers question: http://stackoverflow.com/q/2653855
has body: You do not have to write your own logging implementation, how about switching the logging framework to logback? Loback supports logging to database natively. As you use the SLF4J API both times your code won't change. Take a look at the ch.qos.logback.classic.db.DBAppender. If the default table layout does not fit your needs, you can implement ch.qos.logback.classic.db.names.DBNameResolver to customzie the table and coloum names.
type: Answer
score: 7

http://stackoverflow.com/a/5183563
type: Answer
score: 16
downvote count: 0
has body: You can have as many view technologies as you want on Spring MVC. I have FreeMarker and JSP view resolvers. When I run into a view that it's too complicated in FreeMarker (or just more convenient in JSP) I create a JSP view. For instance, Spring with JSTL makes a great job handling forms. For that I use JSP views, but for pretty much everything else I have FreeMarker views. Have a look to the Spring MVC documentation to see how to configure several view resolvers, basically: <property name="cache" value="true"/> <property name="prefix" value=""/> <property name="suffix" value=".ftl"/> <property name="order" value="1"/> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> <property name="order" value="2"/>
upvote count: 16
answers question: http://stackoverflow.com/q/2746598

http://stackoverflow.com/comment/2732239
comment on: http://stackoverflow.com/a/2708232
type: Comment
has text: Suppose an exception stops the `close` from being run. There's no guarantee how long it will be before the `FileInputStream` is garbage-collected (if ever), and until then the underlying file handle will be open. The total number of file handles that may be open at once in a process is usually fairly small (a few thousand is a common limit) so a leak of FDs, i.e., a leak of `FileInputStream` objects, is serious.
type: AnswerComment
score: 1

http://stackoverflow.com/q/2670460
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/2670484
has answer: http://stackoverflow.com/a/2670483
tagged with: arrays
has answer: http://stackoverflow.com/a/2670521
has answer: http://stackoverflow.com/a/73428394
downvote count: 0
answer count: 10
has comment: http://stackoverflow.com/comment/2719539
has body: CodingBat &gt; Java &gt; Array-1 &gt; reverse3: Given an array of ints length 3, return a new array with the elements in reverse order, so {1, 2, 3} becomes {3, 2, 1}. public int[] reverse3(int[] nums) { int[] values = new int[3]; for (int i = 0; i &lt;= nums.length - 1; i++) { for (int j = nums.length-1; j &gt;= 0; j--) { values[i] = nums[j]; } } return values; } I can't get this to work properly, usually the last int in the array, becomes every single int in the new array
has answer: http://stackoverflow.com/a/62484009
favorite count: 0
upvote count: 2
has answer: http://stackoverflow.com/a/2670479
has answer: http://stackoverflow.com/a/2670484
possible better answer: http://stackoverflow.com/a/2670550
has answer: http://stackoverflow.com/a/2671878
has answer: http://stackoverflow.com/a/2670550
has answer: http://stackoverflow.com/a/2670482
has answer: http://stackoverflow.com/a/57530262
score: 2
type: AnsweredQuestion
has title: Creating a New Reverse Java Array

google-app-engine
tags question: http://stackoverflow.com/q/2628586
tags question: http://stackoverflow.com/q/2598085
tag name: google-app-engine
tags question: http://stackoverflow.com/q/2656725
tags question: http://stackoverflow.com/q/2701565
type: Tag
tags question: http://stackoverflow.com/q/2605687
tags question: http://stackoverflow.com/q/2688473
tags question: http://stackoverflow.com/q/2612911
tags question: http://stackoverflow.com/q/2662092
tags question: http://stackoverflow.com/q/2686889
tags question: http://stackoverflow.com/q/2602527
tags question: http://stackoverflow.com/q/2757132
tags question: http://stackoverflow.com/q/2675371
tags question: http://stackoverflow.com/q/2753802
tags question: http://stackoverflow.com/q/2686993
tags question: http://stackoverflow.com/q/2753139
tags question: http://stackoverflow.com/q/2663890
tags question: http://stackoverflow.com/q/2618473
tags question: http://stackoverflow.com/q/2724696
tags question: http://stackoverflow.com/q/2702039
tags question: http://stackoverflow.com/q/2620799
tags question: http://stackoverflow.com/q/2754035
tags question: http://stackoverflow.com/q/2747544
tags question: http://stackoverflow.com/q/2731121
tags question: http://stackoverflow.com/q/2656819
tags question: http://stackoverflow.com/q/2638119
tags question: http://stackoverflow.com/q/2711231
tags question: http://stackoverflow.com/q/2712011
tags question: http://stackoverflow.com/q/2654124
tags question: http://stackoverflow.com/q/2713371
tags question: http://stackoverflow.com/q/2678232
tags question: http://stackoverflow.com/q/2637521
tags question: http://stackoverflow.com/q/2603745
tags question: http://stackoverflow.com/q/2781718
tags question: http://stackoverflow.com/q/2679759
tags question: http://stackoverflow.com/q/2664738
tags question: http://stackoverflow.com/q/2702749
tags question: http://stackoverflow.com/q/2752965
tags question: http://stackoverflow.com/q/2727718
tags question: http://stackoverflow.com/q/2642252
tags question: http://stackoverflow.com/q/2643744
tags question: http://stackoverflow.com/q/2628232
tags question: http://stackoverflow.com/q/2759805
tags question: http://stackoverflow.com/q/2704984
tags question: http://stackoverflow.com/q/2695631
tags question: http://stackoverflow.com/q/2615939
tags question: http://stackoverflow.com/q/2683833
tags question: http://stackoverflow.com/q/2761091
tags question: http://stackoverflow.com/q/2655580
tags question: http://stackoverflow.com/q/2597736
tags question: http://stackoverflow.com/q/2770266
tags question: http://stackoverflow.com/q/2741629
tags question: http://stackoverflow.com/q/2636952
tags question: http://stackoverflow.com/q/2621202
tags question: http://stackoverflow.com/q/2597854
tags question: http://stackoverflow.com/q/2767710
tags question: http://stackoverflow.com/q/2605923
tags question: http://stackoverflow.com/q/2609233
tags question: http://stackoverflow.com/q/2763340
tags question: http://stackoverflow.com/q/2703410
tags question: http://stackoverflow.com/q/2735237
tags question: http://stackoverflow.com/q/2690955
tags question: http://stackoverflow.com/q/2632360
tags question: http://stackoverflow.com/q/2758544
tags question: http://stackoverflow.com/q/2620758
tags question: http://stackoverflow.com/q/2626581
tags question: http://stackoverflow.com/q/2728859
tags question: http://stackoverflow.com/q/2678488
tags question: http://stackoverflow.com/q/2654161
tags question: http://stackoverflow.com/q/2676194

http://stackoverflow.com/q/2627856
upvote count: 2
has title: How to make Apache Common Logging Write to Specific Disc Log File
score: 2
type: AnsweredQuestion
has body: I am using Apache Common Logging in Desktop Application. private static final Log log = LogFactory.getLog(Utils.class); How can I direct, Apache Common Logging to write to disc log file, when I perform log.error(null, exp); Thanks.
has answer: http://stackoverflow.com/a/2627933
tagged with: java
has answer: http://stackoverflow.com/a/2627975
type: Question
possible better answer: http://stackoverflow.com/a/2627975
accepted answer: http://stackoverflow.com/a/2627933
answer count: 2
downvote count: 0
favorite count: 0

http://stackoverflow.com/q/2689090
tagged with: java
has title: Does hashCode() have to return a prime number?
has body: The signature of the hashCode() method is public int hashCode(){ return x; } in this case x must be an int(primitive) but plz can anyone explain it to me that the number which the hashCode() returns must be a prime number, even number...etc or there is no specification ? the reason behind i am asking this question is i have seen it in different ids the auto generated code always returns a prime number, so i need to know why? thanks in advance
answer count: 2
has comment: http://stackoverflow.com/comment/3801967
has comment: http://stackoverflow.com/comment/3703678
accepted answer: http://stackoverflow.com/a/2689097
score: 0
has answer: http://stackoverflow.com/a/3538022
linked to: http://stackoverflow.com/q/3613102
possible better answer: http://stackoverflow.com/a/3538022
type: Question
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2689097
tagged with: hashcode

http://stackoverflow.com/q/2734895
favorite count: 0
has title: When the last version of Java Media Framework was released?
has answer: http://stackoverflow.com/a/2734966
type: UnansweredQuestion
upvote count: 1
has body: When it was released the latest version of JMF? Is it useful to study about the JMF? Please suggest me.. But there is very small amount of source only there? Why? Suggest me..
tagged with: jmf
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/2734994
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/2763032
downvote count: 0

http://stackoverflow.com/a/2711553
answers question: http://stackoverflow.com/q/2684630
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/16989439
has comment: http://stackoverflow.com/comment/46559693
has comment: http://stackoverflow.com/comment/7995108
has comment: http://stackoverflow.com/comment/112494090
type: Answer
has comment: http://stackoverflow.com/comment/51799717
score: 1439
has comment: http://stackoverflow.com/comment/44794680
has body: Since Mockito 1.9.5+ and Java 8+ You can use a lambda expression, like: when(myMock.myFunction(anyString())).thenAnswer(i -> i.getArguments()[0]); Where i is an instance of InvocationOnMock. For older versions You can create an Answer in Mockito. Let's assume, we have an interface named MyInterface with a method myFunction. public interface MyInterface { public String myFunction(String abc); } Here is the test method with a Mockito answer: public void testMyFunction() throws Exception { MyInterface mock = mock(MyInterface.class); when(mock.myFunction(anyString())).thenAnswer(new Answer<String>() { @Override public String answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); return (String) args[0]; } }); assertEquals("someString",mock.myFunction("someString")); assertEquals("anotherString",mock.myFunction("anotherString")); }
downvote count: 7
has comment: http://stackoverflow.com/comment/68803273
has comment: http://stackoverflow.com/comment/52490000
upvote count: 1446
accepted answer of: http://stackoverflow.com/q/2684630

http://stackoverflow.com/a/2650469
has comment: http://stackoverflow.com/comment/2666568
type: Answer
score: 2
downvote count: 0
has body: Use AtomicBoolean.
answers question: http://stackoverflow.com/q/2650458
upvote count: 2
has comment: http://stackoverflow.com/comment/2666530

http://stackoverflow.com/q/2694521
has answer: http://stackoverflow.com/a/2694571
favorite count: 0
possible better answer: http://stackoverflow.com/a/2694653
has answer: http://stackoverflow.com/a/2694653
tagged with: server-side
downvote count: 0
has body: I want to make a business logic of server side Java application as a set of scripts. So I need from a scripting engine: Maximum Java interoperability (i.e. Spring framework) Script reloading and recompiling Easy DB access from scripting language Clear and simple syntax (some DSL capabilities would be nice to have), easy learning curve for non-hardcore developers Performance and stability I had some experience in the similar project with Rhino and it was pretty good. But I want to see if there is something better. Currently I'm looking into Groovy. JRuby and Jython are a bit more complex than I need for this task. Any other suggestion? What to take into consideration?
tagged with: scripting-language
has title: Scripting language to embed into a Java server application
type: AnsweredQuestion
score: 1
tagged with: java
accepted answer: http://stackoverflow.com/a/2694571
type: Question
answer count: 2
upvote count: 1

http://stackoverflow.com/a/31376154
answers question: http://stackoverflow.com/q/2736389
has body: Pass object from one activity to another activity. (1) source activity Intent ii = new Intent(examreport_select.this, BarChartActivity.class); ii.putExtra("IntentExamResultDetail", (Serializable) your List&lt;ArraList&lt;String&gt;&gt; object here); startActivity(ii); (2) destination acitivity List&lt;ArrayList&lt;String&gt;&gt; aa = (List&lt;ArrayList&lt;String&gt;&gt;) getIntent() .getSerializableExtra("IntentExamResultDetail");
score: 0
type: Answer

http://stackoverflow.com/q/2620758
has answer: http://stackoverflow.com/a/2620784
has title: output stream on appengine
type: Question
has answer: http://stackoverflow.com/a/2620885
score: 0
answer count: 3
accepted answer: http://stackoverflow.com/a/2620818
has body: while using the appengine sdk i can't view the Output of my System.out.println statements how can i view them they are like envaluable debugging tool for me .
tagged with: google-app-engine
type: AnsweredQuestion
tagged with: java
possible better answer: http://stackoverflow.com/a/2620784
has answer: http://stackoverflow.com/a/2620818

http://stackoverflow.com/a/2784059
has comment: http://stackoverflow.com/comment/83224334
accepted answer of: http://stackoverflow.com/q/2784009
has comment: http://stackoverflow.com/comment/2830462
upvote count: 150
answers question: http://stackoverflow.com/q/2784009
type: AcceptedAnswer
downvote count: 0
type: Answer
score: 150
has body: Because if it were an instance level field, then it would actually be "Per Thread - Per Instance", not just a guaranteed "Per Thread." That isn't normally the semantic you're looking for. Usually it's holding something like objects that are scoped to a User Conversation, Web Request, etc. You don't want them also sub-scoped to the instance of the class. One web request => one Persistence session. Not one web request => one persistence session per object.
has comment: http://stackoverflow.com/comment/34175173

http://stackoverflow.com/comment/2821423
score: 0
comment on: http://stackoverflow.com/q/2781939
type: QuestionComment
type: Comment
has text: I just copy and pasted your code and ran it. Same issue happened.. I am still having the same problem..

http://stackoverflow.com/comment/51223041
comment on: http://stackoverflow.com/a/7454611
score: 0
type: Comment
has text: There are millions of successful commercial projects which does not follow idealism completely, and +1 to Brian White for putting it in the correct way. When the crunch time approaches I'm pretty sure a shorter development time is preferred than a tiny degradation in performance.
type: AnswerComment

http://stackoverflow.com/q/2728093
linked to: http://stackoverflow.com/q/541912
has answer: http://stackoverflow.com/a/49973100
has title: To use the 'I' prefix for interfaces or not to
has answer: http://stackoverflow.com/a/2815003
has answer: http://stackoverflow.com/a/2728208
has comment: http://stackoverflow.com/comment/2762449
has answer: http://stackoverflow.com/a/2728113
has answer: http://stackoverflow.com/a/2728121
has answer: http://stackoverflow.com/a/61344153
has answer: http://stackoverflow.com/a/2728594
has answer: http://stackoverflow.com/a/2728123
downvote count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/2756455
has comment: http://stackoverflow.com/comment/2764076
has answer: http://stackoverflow.com/a/2728142
score: 35
has answer: http://stackoverflow.com/a/2729070
has answer: http://stackoverflow.com/a/2728119
linked to: http://stackoverflow.com/q/681700
has comment: http://stackoverflow.com/comment/2807688
linked to: http://stackoverflow.com/q/437649
upvote count: 36
has answer: http://stackoverflow.com/a/2728698
has answer: http://stackoverflow.com/a/2728221
answer count: 20
has answer: http://stackoverflow.com/a/2728140
has answer: http://stackoverflow.com/a/2729110
type: UnansweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/2728868
has body: That is the question? So how big a sin is it not to use this convention when developing a c# project? This convention is widely used in the .NET class library. However, I am not a fan to say the least, not just for asthetic reasons but I don't think it makes any contribution. For example is IPSec an interface of PSec? Is IIOPConnection An interface of IOPConnection, I usually go to the definition to find out anyway. So would not using this convention cause confusion? Are there any c# projects or libraries of note that drop this convention? Do any c# projects that mix conventions, as unfortunately Apache Wicket does? The Java class libraries have existed without this for many years, I don't feel I have ever struggled to read code without it. Also, should the interface not be the most primitive description? I mean IList&lt;T&gt; as an interface for List&lt;T&gt; in c#, is it not better to have List&lt;T&gt; and LinkedList&lt;T&gt; or ArrayList&lt;T&gt; or even CopyOnWriteArrayList&lt;T&gt;? The classes describe the implementation? I think I get more information here, than I do from List&lt;T&gt; in c#.
has answer: http://stackoverflow.com/a/2728246
has answer: http://stackoverflow.com/a/2728104
has answer: http://stackoverflow.com/a/2728167
has answer: http://stackoverflow.com/a/2728180
type: Question
has comment: http://stackoverflow.com/comment/2761331
tagged with: c#
has comment: http://stackoverflow.com/comment/2755329

http://stackoverflow.com/a/2704542
upvote count: 1
type: AcceptedAnswer
downvote count: 0
score: 1
has body: Oops.. the error was due to wrong async service definition void testMethod( AsyncCallback&lt;IField&gt; callback); I should not have used raw type here.
type: Answer
accepted answer of: http://stackoverflow.com/q/2704514
answers question: http://stackoverflow.com/q/2704514

http://stackoverflow.com/a/2671537
accepted answer of: http://stackoverflow.com/q/2671497
has comment: http://stackoverflow.com/comment/2694717
upvote count: 4
has body: You forgot a semicolon :) No seriously, use a (X)HTML parser/cleanup API which can convert tagsoup (HTML) to XHTML. Under each JTidy can do that in a single call: new Tidy().parseDOM(inputStream, outputStream); Regex is simply not well suited for this job.
has comment: http://stackoverflow.com/comment/2693424
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2695636
answers question: http://stackoverflow.com/q/2671497
score: 4
has comment: http://stackoverflow.com/comment/2691819
downvote count: 0
has comment: http://stackoverflow.com/comment/2695690
type: Answer

http://stackoverflow.com/comment/2818867
type: AnswerComment
type: Comment
score: 0
has text: I would argue this is more a test of the implementation of Bar than the method you're intending to test.
comment on: http://stackoverflow.com/a/2783284

http://stackoverflow.com/a/2777785
has comment: http://stackoverflow.com/comment/2812643
type: Answer
has comment: http://stackoverflow.com/comment/2821379
has body: void remove(String newValue) { if(setElements.length == 0) return; String [] array = new String[setElements.length-1]; int j = 0; for ( int i = 0; i &lt; setElements.length; i++) { if ( setElements[i] != newValue ) { array[j++] = setElements[i]; } } setElements = array; }
answers question: http://stackoverflow.com/q/2777762
score: 0
has comment: http://stackoverflow.com/comment/2812392
has comment: http://stackoverflow.com/comment/2812661

http://stackoverflow.com/a/2756668
score: 3
upvote count: 3
has comment: http://stackoverflow.com/comment/2788094
has body: From javadoc: If this thread is blocked in an invocation of the wait(), wait(long), or wait(long, int) methods of the Object class, or of the join(), join(long), join(long, int), sleep(long), or sleep(long, int), methods of this class, then its interrupt status will be cleared and it will receive an InterruptedException. If this thread is blocked in an I/O operation upon an interruptible channel then the channel will be closed, the thread's interrupt status will be set, and the thread will receive a ClosedByInterruptException. If this thread is blocked in a Selector then the thread's interrupt status will be set and it will return immediately from the selection operation, possibly with a non-zero value, just as if the selector's wakeup method were invoked. If none of the previous conditions hold then this thread's interrupt status will be set. This means that you have to check the interrupted status to be sure your thread knows about the interruption. This can be done with two methods: isInterrupted() and interrupted(). The last one clear the interrupted status. Something like this: while(!Thread.interrupted()) { ... try { Thread.sleep(10 * 1000); } catch (InterruptedException e) { return; } }
answers question: http://stackoverflow.com/q/2756626
downvote count: 0
has comment: http://stackoverflow.com/comment/2788145
has comment: http://stackoverflow.com/comment/2788208
type: Answer

http://stackoverflow.com/comment/2798240
comment on: http://stackoverflow.com/q/2765687
type: QuestionComment
type: Comment
has text: @Jorn: the API Docs say "... Most programmers will have no use for this method. It is designed for use by sophisticated enum-based data structures, such as EnumSet and EnumMap."
score: 3

http://stackoverflow.com/a/2643059
upvote count: 3
answers question: http://stackoverflow.com/q/2643052
downvote count: 0
has body: no library. You just print to the console System.out.print (not println!), then send backspace characters to clear the line. System.out("Progress 5"); System.out("\b\b\b\b\b\b\b\b\b\b"); System.out("Progress 10"); I haven't done this in awhile, but that should do it.
has comment: http://stackoverflow.com/comment/2657992
type: Answer
score: 3

http://stackoverflow.com/comment/2748392
has text: @CPerkins: I don't think it's a duplicate as this question seems to be only about the numeric question, while the linked one is about each part of the notation.
type: QuestionComment
comment on: http://stackoverflow.com/q/2722122
score: 1
type: Comment

http://stackoverflow.com/a/73937762
score: 0
has body: You can directly get the keys in Set<K> keySet(). val teamMember = hashMapOf( "Coach" to "manager", "Player Coach" to "editor", "Player" to "member", "Supporter" to "readonly" ) teamMember.keys.forEachIndexed { index, key -> // Here is your key in string }
type: Answer
answers question: http://stackoverflow.com/q/2686092

http://stackoverflow.com/q/2686092
favorite count: 0
tagged with: iteration
has answer: http://stackoverflow.com/a/78428121
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/65403116
has body: In java if I am looping over the keySet() of a HashMap, how do I (inside the loop), get the numerical index of that key? Basically, as I loop through the map, I want to be able to get 0,1,2...I figure this would be cleaner than declaring an int and incrementing with each iteration. Thanks.
has answer: http://stackoverflow.com/a/2686102
has comment: http://stackoverflow.com/comment/2706501
has comment: http://stackoverflow.com/comment/28000304
has answer: http://stackoverflow.com/a/2686108
upvote count: 55
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/34017290
has answer: http://stackoverflow.com/a/73937762
type: Question
tagged with: hashmap
has answer: http://stackoverflow.com/a/2686253
has title: Java - get index of key in HashMap?
has answer: http://stackoverflow.com/a/5618920
has answer: http://stackoverflow.com/a/21818771
answer count: 11
score: 55
has answer: http://stackoverflow.com/a/2686109
has comment: http://stackoverflow.com/comment/2706387
linked to: http://stackoverflow.com/q/18188739
has answer: http://stackoverflow.com/a/2686103

http://stackoverflow.com/q/2720781
score: 0
tagged with: protocol-buffers
has answer: http://stackoverflow.com/a/2720833
has title: Using Protocol Buffers in Java EE?
type: UnansweredQuestion
tagged with: jakarta-ee
tagged with: java
has body: I have coded a server that uses Protocol Buffers in Java. A client talks to it using PB. I'd like to migrate the server code to Java EE and take advantage of the containers' built-in features like clustering. How can I have a service that receives PB messages and interprets them properly, and then gets them handled? I was thinking of a dedicated type of servlet, but how can it be done? I'm a Java EE newbie. I'm not familiar enough with Java EE application servers to know if there is a way to make that happen. P.S. I'm looking for a solution that uses TLS sockets directly. No overhead-causing middleman protocols like HTTP are welcome here. P.P.S. Open source solutions only please.
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/13554023

http://stackoverflow.com/q/2770111
type: Question
answer count: 8
tagged with: performance
has body: Possible Duplicate: java String concatenation How to Improve performance of this chunk of code : public static String concatStrings(Vector strings) { String returnValue = ""; Iterator iter = strings.iterator(); while( iter.hasNext() ) { returnValue += (String)iter.next(); } return returnValue; }
has title: Improving performance of string concatenation in Java
has answer: http://stackoverflow.com/a/2770324
has answer: http://stackoverflow.com/a/7738442
has comment: http://stackoverflow.com/comment/2806651
has answer: http://stackoverflow.com/a/2770156
possible better answer: http://stackoverflow.com/a/2770253
favorite count: 0
has comment: http://stackoverflow.com/comment/15349834
has comment: http://stackoverflow.com/comment/2803582
linked to: http://stackoverflow.com/q/2770321
duplicate of: http://stackoverflow.com/q/47605
has answer: http://stackoverflow.com/a/2770146
score: 8
has answer: http://stackoverflow.com/a/2770116
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2770116
linked to: http://stackoverflow.com/q/47605
downvote count: 0
has comment: http://stackoverflow.com/comment/2803452
has answer: http://stackoverflow.com/a/2770147
tagged with: java
has answer: http://stackoverflow.com/a/2770229
has comment: http://stackoverflow.com/comment/2803464
has answer: http://stackoverflow.com/a/2770253
upvote count: 8

http://stackoverflow.com/a/2777068
accepted answer of: http://stackoverflow.com/q/2775401
type: AcceptedAnswer
downvote count: 0
type: Answer
score: 1
upvote count: 1
has body: &lt;uses-permission android:name="android.permissions.INTERNET"/&gt; &lt;uses-permission android:name="android.permissions.ACCESS_FINE_LOCATION"/&gt; should be &lt;uses-permission android:name="android.permission.INTERNET"/&gt; &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/&gt; Note the lack of an 's' on android.permission
answers question: http://stackoverflow.com/q/2775401

http://stackoverflow.com/q/2770321
linked to: http://stackoverflow.com/q/2660827
linked to: http://stackoverflow.com/q/2745193
has answer: http://stackoverflow.com/a/2770671
downvote count: 3
has answer: http://stackoverflow.com/a/55350052
has body: Questions: What are raw types in Java, and why do I often hear that they shouldn't be used in new code? What is the alternative if we can't use raw types, and how is it better?
has answer: http://stackoverflow.com/a/2770338
has comment: http://stackoverflow.com/comment/62281402
has title: What is a raw type and why shouldn't we use it?
has answer: http://stackoverflow.com/a/37211785
has answer: http://stackoverflow.com/a/3051481
tagged with: generics
answer count: 15
favorite count: 0
linked to: http://stackoverflow.com/q/2770264
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/47633979
has comment: http://stackoverflow.com/comment/22400936
score: 823
has answer: http://stackoverflow.com/a/3051504
has answer: http://stackoverflow.com/a/37415442
has answer: http://stackoverflow.com/a/2770692
has answer: http://stackoverflow.com/a/47626695
tagged with: raw-types
tagged with: java
upvote count: 826
has answer: http://stackoverflow.com/a/35835223
has answer: http://stackoverflow.com/a/18167472
has answer: http://stackoverflow.com/a/3051465
type: Question
has answer: http://stackoverflow.com/a/2770631
has answer: http://stackoverflow.com/a/2777051

http://stackoverflow.com/comment/2815992
type: QuestionComment
comment on: http://stackoverflow.com/q/2781086
has text: Where do you get the idea that floats are infinite?
score: 3
type: Comment

http://stackoverflow.com/a/2620933
answers question: http://stackoverflow.com/q/2620591
has comment: http://stackoverflow.com/comment/2635071
score: 17
upvote count: 17
has comment: http://stackoverflow.com/comment/23334018
downvote count: 0
has body: Other solutions provided here are fine, so I'll provide this one just to be a bit different: public static BigInteger lastBigInteger(String s) { int i = s.length(); while (i &gt; 0 &amp;&amp; Character.isDigit(s.charAt(i - 1))) { i--; } return new BigInteger(s.substring(i)); } It manually looks for the position of the last non-Character.isDigit(char) It still works if the input is all digit It uses BigInteger, so it can handle really large numbers at the end of really long strings. Use Integer.parseInt or Long.parseLong if either sufffice
type: Answer

http://stackoverflow.com/comment/132450502
type: AnswerComment
score: 0
has text: is that accepted?
type: Comment
comment on: http://stackoverflow.com/a/7787663

http://stackoverflow.com/a/2744929
score: 3
type: AcceptedAnswer
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/2744806
has body: So many parameters to a method is definitely a code smell. I would say a Chart object is waiting to be born. Here is a basic outline: private RenderImage getChartImage(Chart chart) { //etc. } private static class Chart { private GanttChartModel model; private String title = ""; //etc, initializing each field with its default value. private static class Builder { private Chart chart; public Builder(GanttChartModel model) { chart = new Chart(); chart.model = model; } public setTitle(String title) { if (title != null) { chart.title = title; } } } } Other options include using primitives on the methods instead of objects to indicate that null isn't allowed, although that doesn't necessarily make it better. Another option is a bunch of overloaded methods, but given the types of parameters here, that doesn't really work because I get the idea that you want to make any of the parameters optional rather than having the first ones required and subsequent ones optional.
answers question: http://stackoverflow.com/q/2744806
upvote count: 3

http://stackoverflow.com/a/2724422
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2721401
score: 0
has body: I have found the solution : SVG r = new SVG(new File(*something*).toURI().toString()); BufferedImage img = r.createBufferedImage(); this.enabledIcon = new ImageIcon(img); label.setIcon(img);
type: Answer
accepted answer of: http://stackoverflow.com/q/2721401

http://stackoverflow.com/a/2663523
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2663426
type: Answer
score: 11
upvote count: 11
has body: In my opinion the Thread object is your "handle" for the actual running context. If you allow creating many concurrent executions associated with the same java.lang.Thread, what would you expect getStackTrace() and getState() methods to return? I suppose that Thread class could have been designed to allow spawning multiple running contexts, but its API would be less simple and clean.
answers question: http://stackoverflow.com/q/2663426

http://stackoverflow.com/q/2662784
upvote count: 1
has comment: http://stackoverflow.com/comment/2680347
type: Question
has body: I have code similar to this in all my observer classes that handle events fired by an event bus class. As you can see there are a lot of instanceof checks to choose the path of action needed to appropriately handle events, and I was wondering if this could be done more cleanly, eliminating the instanceof tests? @Override public void handleEvent(Event event) { if (event instanceof DownloadStartedEvent) { DownloadStartedEvent dsEvent = (DownloadStartedEvent)event; dsEvent.getDownloadCandidateItem().setState(new BusyDownloadingState()); } else if (event instanceof DownloadCompletedEvent) { DownloadCompletedEvent dcEvent = (DownloadCompletedEvent)event; dcEvent.getDownloadCandidateItem().setState(new FinishedDownloadingState()); DownloadCandidate downloadCandidate = dcEvent.getDownloadCandidateItem(). getDownloadCandidate(); if (downloadCandidate.isComplete()) { // start extracting } } else if (event instanceof DownloadFailedEvent) { DownloadFailedEvent dfEvent = (DownloadFailedEvent)event; dfEvent.getDownloadCandidateItem().setState(new FailedDownloadingState()); } }
has answer: http://stackoverflow.com/a/2662802
answer count: 6
has comment: http://stackoverflow.com/comment/2680381
possible better answer: http://stackoverflow.com/a/2662802
has answer: http://stackoverflow.com/a/2662829
downvote count: 0
tagged with: events
has answer: http://stackoverflow.com/a/2662812
score: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/2680389
has answer: http://stackoverflow.com/a/2662902
has comment: http://stackoverflow.com/comment/2680417
has answer: http://stackoverflow.com/a/2662827
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2663370
has title: Cleanly handling events
has comment: http://stackoverflow.com/comment/2680393
accepted answer: http://stackoverflow.com/a/2662812
tagged with: java

http://stackoverflow.com/a/2760754
accepted answer of: http://stackoverflow.com/q/2757043
has body: I found a rather poor fix. I exported my code as a JAR and put it in $TOMCAT/lib and that worked. This is clearly a class loader issue. Edit: Figured out the solution Ok, I finally figured out the problem. I had made my application the default application for the server by adding a to server.xml and setting the path to "". However, when I was accessing it through the URL http://localhost/somepage.jsp for somethings, but also the URL http://localhost/appname/anotherpage.jsp for other things. Once I changed all the URLs to use http://localhost/ instead of http://localhost/appname the problem was fixed.
score: 0
type: AcceptedAnswer
type: Answer
answers question: http://stackoverflow.com/q/2757043

http://stackoverflow.com/comment/15168410
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2654107
type: Comment
has text: @ipavlic, 1 day divided by 3 would just be 0d and 8h, same as an hour divided by three would be 0h and 20m. Contracts do consider hours, some (e.g. tight SLA's) might consider minutes. It's perfectly consistent until you hit months, because they're variable.

http://stackoverflow.com/q/2632159
type: Question
has answer: http://stackoverflow.com/a/2644194
tagged with: testing
downvote count: 0
possible better answer: http://stackoverflow.com/a/3077038
favorite count: 0
tagged with: tdd
has answer: http://stackoverflow.com/a/3077038
has answer: http://stackoverflow.com/a/2632450
answer count: 3
has body: I am studying TDD using FitNesse and I am looking some tutorials and examples. I would like to know where to find a good material.
accepted answer: http://stackoverflow.com/a/2632450
tagged with: fitnesse
upvote count: 2
has title: where I can get some tutorials on Java FitNesse and Slim?
score: 2
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/comment/2815395
type: AnswerComment
has text: Dam - so why is this happening?
comment on: http://stackoverflow.com/a/2780003
type: Comment
score: 0

http://stackoverflow.com/comment/2619826
type: Comment
comment on: http://stackoverflow.com/a/2609393
has text: But I think you could use `getOffset(0L)` All that matters is the time difference back then, at the start of the epoch - and I hope, that DST transition didn't occur on Jan 1st.
score: 0
type: AnswerComment

http://stackoverflow.com/a/2619390
has comment: http://stackoverflow.com/comment/85498527
type: Answer
answers question: http://stackoverflow.com/q/2619380
score: 1
upvote count: 1
has body: You can try to use repaint() after comp2d.drawString().
downvote count: 0

http://stackoverflow.com/a/2651535
upvote count: 4
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2685151
accepted answer of: http://stackoverflow.com/q/2651499
type: Answer
has body: Some answers: Access: see LocationManager and LocationListener. Permissions: android.permission.ACCESS_FINE_LOCATION Demo: public class GPSLocationManager implements LocationObservable { private static final long INTERVAL = 10*1000; private LocationManager locationManager; public GPSLocationManager(LocationManager locationManager) { this.locationManager = locationManager; } public void requestLocationUpdates(LocationListener locationListener) { locationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, INTERVAL, 0, locationListener); } public void removeUpdates(LocationListener locationListener) { locationManager.removeUpdates(locationListener); } }
answers question: http://stackoverflow.com/q/2651499
score: 4

http://stackoverflow.com/comment/2659892
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/2644812
type: Comment
has text: You may want to clarify that your phrase "confined to a single thread" is referring to the Thread instance, not the thread itself (to which we might confine a variable using a ThreadLocal).

http://stackoverflow.com/a/2827542
answers question: http://stackoverflow.com/q/2767535
has body: Ok, passing in an UnfoldingReader yourself seems to do the trick. If you set the buffer size large enough, it will be able to restore the value correctly. Strange. reader = new UnfoldingReader(new InputStreamReader(uri.toURL().openStream()), 3000); return new CalendarBuilder().build(reader); I also set ical4j.properties to this: ical4j.unfolding.relaxed=true Not sure if that made a huge difference, but at least it works.
type: Answer
upvote count: 5
has comment: http://stackoverflow.com/comment/54367728
score: 5
accepted answer of: http://stackoverflow.com/q/2767535
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/2770811
comment on: http://stackoverflow.com/q/2741598
score: 0
has text: Intentaste el codigo modificado que puse abajo?
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2695631
downvote count: 0
favorite count: 0
tagged with: google-app-engine
has answer: http://stackoverflow.com/a/2695673
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2701070
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/14706357
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/2701070
possible better answer: http://stackoverflow.com/a/2695673
has body: I use the following method to send email in the Google App Engine servlet : void Send_Email(String From,String To,String Message_Text) { Properties props=new Properties(); Session session=Session.getDefaultInstance(props,null); try { Message msg=new MimeMessage(session); msg.setFrom(new InternetAddress(From,"nmjava.com Admin")); msg.addRecipient(Message.RecipientType.TO,new InternetAddress(To,"Ni , Min")); msg.setSubject("Servlet Message"); msg.setText(Message_Text); Transport.send(msg); } catch (Exception ex) { // ... } } But it doesn't work, have I missed anything ? Has anyone got the email function working ? Edit : I've fixed the String/Text part, but the email function still doesn't work, it says emails were sent, but I checked my mailbox, none received. I ran it on the Google server, what's wrong ?
has title: Google App Engine Email
answer count: 2
tagged with: email

http://stackoverflow.com/a/2715460
accepted answer of: http://stackoverflow.com/q/2715423
type: AcceptedAnswer
has body: If this is a serious poker application, where money can change hands, the short answer is NO. For something like this, you should really use a hardware source of true randomness. The slightly longer answer is: if you can't get hardware for doing true randomness, Collections.shuffle(List, Random) might be good enough if you supply a SecureRandom. The tricky part with this solution is finding a good seed value. UPDATE: Based on your clarification, I'd suggest you look into how you're seeding the PRNG (assuming you're already using a cryptographically secure implementation; if not, do that first). You should not be using a limited set of seeds. Other things to consider: you should probably instantiate a single PRNG for each game you should only be shuffling the deck between hands; from your question, it's not 100% clear that you aren't also shuffling the deck between the flop, turn, river, etc.
answers question: http://stackoverflow.com/q/2715423
upvote count: 9
type: Answer
downvote count: 0
has comment: http://stackoverflow.com/comment/135780929
has comment: http://stackoverflow.com/comment/2741053
has comment: http://stackoverflow.com/comment/2741113
has comment: http://stackoverflow.com/comment/135905436
score: 9

http://stackoverflow.com/q/2713454
has comment: http://stackoverflow.com/comment/2738720
type: Question
answer count: 1
downvote count: 0
favorite count: 0
tagged with: html-sanitizing
has comment: http://stackoverflow.com/comment/2738348
score: 2
tagged with: cyberneko
has title: Cleaning mixed type tags
upvote count: 2
has answer: http://stackoverflow.com/a/5134540
accepted answer: http://stackoverflow.com/a/5134540
has comment: http://stackoverflow.com/comment/2738470
type: AnsweredQuestion
has body: I'm cleaning HTML using cyberneko and xerces. However , some $#@@!@@ websites still use BOTH &lt;script&gt;...&lt;/script&gt; and &lt;script.../&gt; So what happens is this : given &lt;script..../&gt; &lt;div&gt; Some Text &lt;/div&gt; &lt;script&gt; scripting stuff &lt;/script&gt; , neko parses all the above line as a script , so I get &lt;script..../&gt; &amp;lt div &amp;gt Some Text &amp;lt/div &amp;gt &amp;lt script &amp;gt scripting stuff &lt;/script&gt; , And then I lose all the inside content :( Any advice?
tagged with: java

http://stackoverflow.com/a/2771456
has body: Invoke the "launch scp" using SwingWorker to get it of the main thread and let the GUI update again. To get actual progress you will need to investigate the characters printed by scp. I believe it maintains an ASCII progress bar, you can then replicate in Java. You may want to add "-v" to scp to let it be more talkative.
answers question: http://stackoverflow.com/q/2769730
score: 0
type: Answer

http://stackoverflow.com/q/2699354
type: Question
upvote count: 2
answer count: 2
accepted answer: http://stackoverflow.com/a/2699531
has answer: http://stackoverflow.com/a/2699523
has answer: http://stackoverflow.com/a/2699531
tagged with: jvm
favorite count: 0
has title: jvm minor version vs compiler minor version
possible better answer: http://stackoverflow.com/a/2699523
score: 2
type: AnsweredQuestion
downvote count: 0
tagged with: java
has body: Will JVM throw exception when it runs classes compiled with a JDK that has same major version but higher minor version compared to JVM ?

http://stackoverflow.com/q/2703309
type: UnansweredQuestion
type: Question
favorite count: 0
score: 0
upvote count: 1
tagged with: swing
answer count: 1
downvote count: 1
tagged with: java
has comment: http://stackoverflow.com/comment/2731068
has body: Ok, So for some reason When I add components to a JLayeredPane in its constructor: JLabel label = new JLabel(); label.setSize(100,100); label.setText("This works"); add(label); It works perfectly fine, but If a add it later in the JLayeredPane's parent EDT it doesnt let me move the objects around but they let me see the objects. Adding from EDT: JLabel label = new JLabel(); label.setToolTipText(url.getHost()); label.setIcon(icon); label.setBorder(new LineBorder(null)); label.setSize(icon.getIconWidth(), icon.getIconHeight()); dressFrame.layeredPane.add(label, JLayeredPane.DRAG_LAYER); Dragging method: Component c = findComponentAt(e.getX(), e.getY()); if (c instanceof JLayeredPane) { pieceSelected = false; return; } Point parentLocation = c.getLocation(); xAdjustment = parentLocation.x - e.getX(); yAdjustment = parentLocation.y - e.getY(); movingPiece = c; movingPiece.setLocation(e.getX() + xAdjustment, e.getY() + yAdjustment); pieceSelected = true; http://xslayer.com/upload/gui.png
has answer: http://stackoverflow.com/a/2703605
has title: Adding a JLabel to JLayeredPane from event listener not dragging

http://stackoverflow.com/comment/4559512
type: AnswerComment
comment on: http://stackoverflow.com/a/2697165
score: 0
type: Comment
has text: Hehe, I am really happy for having helped to save you some time ;-)

http://stackoverflow.com/q/2709496
has title: ListView exception for Images + Text
upvote count: 2
has comment: http://stackoverflow.com/comment/2748142
has answer: http://stackoverflow.com/a/2803989
has body: I am trying to create a simple Icon+Text ListView but it does not work. I am using 2.1 Android SDK. My main class is very small slightly modified from the tutorial: public class Stuffs extends ListActivity { static final String[] COUNTRIES = new String[] {"A", "B","C"}; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, R.id.title, COUNTRIES)); } } and my list_item.xml file is this: <?xml version="1.0" encoding="utf-8"?> <ImageView android:id = "@+id/icon" android:src="@drawable/icon" /> I have also created a "drawable" directory in my res directory and copied a "icon.png" into it. But any time I try to run this the application hangs up unexpected in my android emulator. Am I missing something?
score: 2
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2734224
tagged with: java
accepted answer: http://stackoverflow.com/a/2803989
has comment: http://stackoverflow.com/comment/2733873
type: Question
answer count: 1
downvote count: 0
favorite count: 0
tagged with: android

http://stackoverflow.com/q/2610679
has comment: http://stackoverflow.com/comment/2621243
tagged with: infinite-loop
has comment: http://stackoverflow.com/comment/2621339
has answer: http://stackoverflow.com/a/2610754
tagged with: while-loop
possible better answer: http://stackoverflow.com/a/2610685
downvote count: 1
answer count: 7
has comment: http://stackoverflow.com/comment/2621283
has answer: http://stackoverflow.com/a/2611882
has answer: http://stackoverflow.com/a/2610706
favorite count: 0
duplicate of: http://stackoverflow.com/q/14112515
has comment: http://stackoverflow.com/comment/2622335
has body: boolean r = false ; int s = 0 ; while (r == false) ; { s = getInt() ; if (!(s&gt;=0 &amp;&amp; s&lt;=2)) System.out.println ("try again not a valid response") ; else r = true ; } The text never displays itself even when a 3 or a 123 is entered and the loop never terminates. Whats wrong here?
has comment: http://stackoverflow.com/comment/2621348
has comment: http://stackoverflow.com/comment/2621477
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2610745
has answer: http://stackoverflow.com/a/2610684
has answer: http://stackoverflow.com/a/2612013
score: 7
tagged with: java
has answer: http://stackoverflow.com/a/2610685
accepted answer: http://stackoverflow.com/a/2610684
linked to: http://stackoverflow.com/q/14112515
has title: Whats wrong with this while loop?
upvote count: 8
type: Question

http://stackoverflow.com/q/2777076
accepted answer: http://stackoverflow.com/a/2790124
tagged with: apache-commons
tagged with: java
has answer: http://stackoverflow.com/a/2777091
has answer: http://stackoverflow.com/a/37231792
has title: Does Apache Commons HttpClient support GZIP?
type: Question
has answer: http://stackoverflow.com/a/44002411
answer count: 8
has answer: http://stackoverflow.com/a/2790124
has answer: http://stackoverflow.com/a/70948360
upvote count: 36
tagged with: gzip
possible better answer: http://stackoverflow.com/a/6941704
score: 36
downvote count: 0
tagged with: apache-commons-httpclient
favorite count: 0
has body: Does the library Apache Commons HttpClient support Gzip? We wanted to use enable gzip compression on our Apache server to speed up the client/server communications (we have a php page that allows our Android application to sync files with the Server).
tagged with: apache-httpclient-4.x
has answer: http://stackoverflow.com/a/6941704
has answer: http://stackoverflow.com/a/22677037
has answer: http://stackoverflow.com/a/46910651
type: AnsweredQuestion

http://stackoverflow.com/comment/52013598
score: 4
has text: This doesn't test for cycles but for duplicate values using the elements `equals` and `hashCode`. It's not the same thing. And it dereferences `null` on the last element. And the question didn't say anything about storing the nodes in a `LinkedList`.
comment on: http://stackoverflow.com/a/15586079
type: AnswerComment
type: Comment

http://stackoverflow.com/q/2688941
favorite count: 0
tagged with: resultset
type: UnansweredQuestion
tagged with: jdbc
has answer: http://stackoverflow.com/a/2698251
downvote count: 0
score: 1
tagged with: java
type: Question
has body: I want to put all the data in the resultset into a text file in the same order. Is there any method to get data in all the rows at once and write to a file or have to write it row by row?
has answer: http://stackoverflow.com/a/2688990
has title: what is the best way to put resultset data into a text file?
answer count: 3
has answer: http://stackoverflow.com/a/2688972
upvote count: 1

http://stackoverflow.com/a/11885708
downvote count: 0
type: Answer
score: 1
upvote count: 1
has body: Here is the list of data types supported natively in App Engine for Java.
answers question: http://stackoverflow.com/q/2711231

http://stackoverflow.com/q/2628947
tagged with: java
has body: We've generated some (well a lot) of classes using HyperJAXB. All of the classes implement Equals and HashCode and have the implementation style below. Appears this code is never executed.. is there any particular reason we need this code? I'm looking to simplify the classes if we can. public boolean equals(Object object) { if (!(object instanceof MyClass)) { return false; } if (this == object) { return true; } final EqualsBuilder equalsBuilder = new JAXBEqualsBuilder(); equals(object, equalsBuilder); return equalsBuilder.isEquals(); } public void hashCode(HashCodeBuilder hashCodeBuilder) { hashCodeBuilder.append(this.getValue()); hashCodeBuilder.append(this.getId()); } public int hashCode() { final HashCodeBuilder hashCodeBuilder = new JAXBHashCodeBuilder(); hashCode(hashCodeBuilder); return hashCodeBuilder.toHashCode(); }
answer count: 2
accepted answer: http://stackoverflow.com/a/2629051
downvote count: 0
has answer: http://stackoverflow.com/a/3184405
favorite count: 0
possible better answer: http://stackoverflow.com/a/3184405
type: AnsweredQuestion
tagged with: hyperjaxb
score: 1
upvote count: 1
has title: Do we need HyperJAXB generated hashCode & equals methods?
has answer: http://stackoverflow.com/a/2629051
type: Question

http://stackoverflow.com/q/2627419
score: 7
tagged with: java
upvote count: 7
type: Question
answer count: 6
has answer: http://stackoverflow.com/a/4309246
accepted answer: http://stackoverflow.com/a/2661898
has answer: http://stackoverflow.com/a/40768662
tagged with: hp-quality-center
downvote count: 0
has answer: http://stackoverflow.com/a/15989409
has answer: http://stackoverflow.com/a/37689928
favorite count: 0
possible better answer: http://stackoverflow.com/a/6098966
has answer: http://stackoverflow.com/a/6098966
has body: We have a project that uses HP Quality Center and one of the regular issues we face is people not updating comments on the defect. So I was thinkingif we could come up with a small script or tool that could be used to periodically throw up a reminder and force the user to update the comments. I came across the Open Test Architecture API and was wondering if there are any good Python or java examples for the same that I could see. Thanks Hari
has title: Automating HP Quality Center with Python or Java
tagged with: python
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2661898

http://stackoverflow.com/comment/44995423
type: Comment
has text: @weston nope. I cant find any other solutions. But ur vaviant is not an option to me
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/16883281

http://stackoverflow.com/a/2668793
downvote count: 0
has comment: http://stackoverflow.com/comment/2687395
accepted answer of: http://stackoverflow.com/q/2668759
type: Answer
score: 13
upvote count: 13
answers question: http://stackoverflow.com/q/2668759
has comment: http://stackoverflow.com/comment/2687434
has body: Since the 10001st prime number is not that big, you could start by using long instead of BigInteger. A BigInteger instance is a full-fledged Java Object and there is a lot of overhead in creating and manipulating them.
has comment: http://stackoverflow.com/comment/2687042
has comment: http://stackoverflow.com/comment/2687252
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2687051
has comment: http://stackoverflow.com/comment/2686972

http://stackoverflow.com/q/2640825
tagged with: xml-parsing
has body: I face issue parsing xhtml with DOCTYPE declaration using DOM parser. Error: java.io.IOException: Server returned HTTP response code: 503 for URL: http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd%20 Declaration: DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd Is there a way to parse the xhtml to a Document object ignoring the DOCTYPE declaration.
downvote count: 0
has answer: http://stackoverflow.com/a/3372428
favorite count: 0
answer count: 4
tagged with: http://stackoverflow.com/tag/xml
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/3345959
tagged with: java
accepted answer: http://stackoverflow.com/a/3372428
type: Question
possible better answer: http://stackoverflow.com/a/2640841
has answer: http://stackoverflow.com/a/39559554
has answer: http://stackoverflow.com/a/2640841
score: 4
upvote count: 4
has title: How to parse a xhtml ignoring the DOCTYPE declaration using DOM parser

http://stackoverflow.com/a/2612744
has comment: http://stackoverflow.com/comment/2623650
score: 1
answers question: http://stackoverflow.com/q/2612579
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2623680
has comment: http://stackoverflow.com/comment/2623631
has body: Maybe you have a flaw in understanding recursion. You don't need the "output" argument. When you compute a subtree you don't need the representation of the previous nodes. Make it like this: public String inOrderNewick(Node root) throws ItemNotFoundException { if (root.hasChild()) { String output = ""; output += "("; output += inOrderNewick(root.child1); output += ","; output += inOrderNewick(root.child2); output += ")"; return output; } else { return root.getSeq(); } }
has comment: http://stackoverflow.com/comment/2623672
accepted answer of: http://stackoverflow.com/q/2612579
type: Answer
upvote count: 1

http://stackoverflow.com/a/2824394
answers question: http://stackoverflow.com/q/2705468
downvote count: 0
type: Answer
upvote count: 1
score: 1
has body: Rather than try to manage/calculate the complexities of the desired layout, you could try Docmosis. It will let you layout a document as a template using doc or odt formats. This means if you could make a doc or odt look like you want, you can turn it into a template and get Docmosis to render it as a PDF. Text and images can be placed inside or outside tables which makes layout fairly easy to manage.

http://stackoverflow.com/comment/2767494
type: Comment
type: QuestionComment
score: 0
has text: See: http://www.javapractices.com/topic/TopicAction.do?Id=44
comment on: http://stackoverflow.com/q/2738827

http://stackoverflow.com/q/2765583
has comment: http://stackoverflow.com/comment/2850281
type: Question
tagged with: version-control
answer count: 1
downvote count: 0
linked to: http://stackoverflow.com/q/268258
tagged with: javascript
linked to: http://stackoverflow.com/q/237946
favorite count: 0
has answer: http://stackoverflow.com/a/2848600
score: 3
has body: Our code is in Java and Javascript (AJAX libraries). We have wrappers/reusable code around the existing libraries to perform mundane tasks like, db connections, session management, logging, hibernate settings, base structure, some reusable multitenancy code etc.. From the javascript end, we have page initializers, UI layout components, custom js objects, and some of our own logic. We have multiple projects where this code can be reused, but at the same time, this code is evolving along with the application. So if we find a common way to do it, we can move it to the framework code and let other projects also benefit out of it. If/when we find a bug in the base code, we can fix it in one place and commit and all the other projects will pick up the change (rather than everyone making the changes locally). If it's just java files, we can keep it as a separate project, and include it as a dependent module in eclipse/maven and have it included as a jar, as and when needed. This part is easy to handle, but now we also have reusable javascript in the code, which cannot exactly be jar(ed). We want some suggestions on how the code should be laid out, so we can reuse it via maven (deployment time) and via eclipse (development time), without going thru too many hoops. Before writing this, I did come across some articles on stackoverflow, which do talk about reusable code and methodologies which are great, but not exactly how to manage them using svn, maven, eclipse etc.. Linking them, for reference. Architecture of some reusable code How do you make code reusable? -> This is a great article from a theory stand point, but no tips on management. How do I index and make available reusable code? In some of our old projects, we maintained ant files, which would copy files from base locations to the final war, so everything is available. But over the period of time as the project grew, even for a simple check, we had to rebuild the whole war and deploy to test on the developers machi…
upvote count: 3
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/2798120
has title: Reusable architectural code management
linked to: http://stackoverflow.com/q/1082488
tagged with: java
tagged with: eclipse
tagged with: code-reuse

http://stackoverflow.com/a/4447160
answers question: http://stackoverflow.com/q/2763454
score: 0
has body: I have run into a similar issue using Oracle, and JDBC. It ended up I was consuming all of the connections that were available to the database, and I wasn't relinquishing any of them and my code would just halt or timeout. Take a look at how you are handling your connections in your code.
type: Answer

http://stackoverflow.com/comment/76168556
type: Comment
comment on: http://stackoverflow.com/a/44589817
score: 1
has text: It may help if you explain your answer some. What was the problem with the OP's code? How does this fix it?
type: AnswerComment

http://stackoverflow.com/comment/54007976
comment on: http://stackoverflow.com/a/28900749
has text: Still I'm not able to set custom font using this method in Nexus 9
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/11953441
has comment: http://stackoverflow.com/comment/81442332
has body: The available method of ObjectInputStream cannot used to terminate the loop as it returns 0 even if there are objects to be read in a file. Writing a null to a file doen't seem to be a good solution either since objects can be null which then would be interpreted as the end of file. I think catching the EOFException to terminate the loops is a better practice since if EOFException occurs(either because you reached the end of the file or some other reason), you have to terminate the loop anyway.
type: Answer
answers question: http://stackoverflow.com/q/2626163
score: 0
upvote count: 1
downvote count: 1

http://stackoverflow.com/a/2775759
answers question: http://stackoverflow.com/q/2754306
has body: First off, this happens in Windows Vista too. It seems to be the case, that the slider tries to take as little space as possible. If you want a bigger JSlider use JSlider.setPaintTicks. So you have to add the following: JSlider vertical = new JSlider( SwingConstants.VERTICAL ); vertical.setPaintTicks( true ); contentPane.add( vertical ); That should do the trick.
downvote count: 0
score: 4
type: Answer
upvote count: 4

http://stackoverflow.com/a/2611579
score: 0
answers question: http://stackoverflow.com/q/2611496
type: Answer
has body: while(true) { Scanner kb = new Scanner(System.in); Memory m = new Memory(); ... Every time you loop, you are creating a new Memory object instead of updating a reference to an existing one.

http://stackoverflow.com/a/6978694
has body: have you ever considered Random number is ${random} </project>
downvote count: 0
answers question: http://stackoverflow.com/q/2608935
score: 4
type: Answer
upvote count: 4

http://stackoverflow.com/comment/9911007
type: Comment
type: QuestionComment
has text: possible duplicate of [Detect if an outgoing call has been answered](http://stackoverflow.com/questions/2250455/detect-if-an-outgoing-call-has-been-answered)
comment on: http://stackoverflow.com/q/2635945
score: 1

http://stackoverflow.com/comment/138439637
type: AnswerComment
score: 0
type: Comment
has text: You are right @SamYC, I also have to create a new working set of type Resouces which includes pom.xml for example. In my case it represented minimal efforts, it indeed remains not perfect as you have to manually select some extra Resources
comment on: http://stackoverflow.com/a/62893462

http://stackoverflow.com/a/2764597
score: 0
answers question: http://stackoverflow.com/q/2764584
has body: Yes. You can build a java web-application which has php front end.
upvote count: 1
downvote count: 1
type: Answer

http://stackoverflow.com/comment/2756170
has text: @WizardOfOdds: I added a solution to keep track of surrogate pairs.
type: AnswerComment
score: 1
type: Comment
comment on: http://stackoverflow.com/a/2726284

http://stackoverflow.com/a/2773811
has comment: http://stackoverflow.com/comment/2807690
downvote count: 1
upvote count: 5
score: 4
accepted answer of: http://stackoverflow.com/q/2773779
has comment: http://stackoverflow.com/comment/2807723
answers question: http://stackoverflow.com/q/2773779
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2808052
has comment: http://stackoverflow.com/comment/2807607
type: Answer
has body: On second thought, I think I just came up with a solution! - use an intermediate variable. String fileName = null; try{ fileName = buildFileName(); } catch(Exception e){ ... System.exit(1); } FILE_NAME = fileName; Don't know why it took me so long to think of this...
has comment: http://stackoverflow.com/comment/2807581
has comment: http://stackoverflow.com/comment/2807622
has comment: http://stackoverflow.com/comment/2808285

http://stackoverflow.com/q/2734678
tagged with: http://stackoverflow.com/tag/jpeg
downvote count: 1
has answer: http://stackoverflow.com/a/2734762
type: AnsweredQuestion
upvote count: 14
has answer: http://stackoverflow.com/a/2734690
tagged with: java
has answer: http://stackoverflow.com/a/2734699
type: Question
has title: Jpeg calculating max size
accepted answer: http://stackoverflow.com/a/2734690
has answer: http://stackoverflow.com/a/2734686
tagged with: applet
has answer: http://stackoverflow.com/a/2765012
favorite count: 0
has comment: http://stackoverflow.com/comment/2762689
has comment: http://stackoverflow.com/comment/2762706
answer count: 5
has comment: http://stackoverflow.com/comment/2762715
possible better answer: http://stackoverflow.com/a/2765012
has body: I have to say the I don't know much about how file formats work. My question is say I have a jpeg file that is 200 px by 200 px, how can one calculate what the maximum size that file could be in terms of megabytes/bytes? I think that the reasoning that led to the question will help some one answer me. I have a Java Applet the uploads Images that people draw with it to my server. I need to know what the max size that this file can conceivably reach. It is always going to be 200x200. It sounds dumb but are there colors that take more byte size then others and if so what is the most expensive one?
score: 13

http://stackoverflow.com/a/2746895
has comment: http://stackoverflow.com/comment/55225577
has comment: http://stackoverflow.com/comment/5913437
has comment: http://stackoverflow.com/comment/2917250
has comment: http://stackoverflow.com/comment/5914736
type: Answer
has comment: http://stackoverflow.com/comment/13049209
has comment: http://stackoverflow.com/comment/13365345
score: 24
upvote count: 24
downvote count: 0
has comment: http://stackoverflow.com/comment/5097080
has comment: http://stackoverflow.com/comment/2919615
answers question: http://stackoverflow.com/q/2725233
has comment: http://stackoverflow.com/comment/5094081
has body: I'll try to answer my own question (Kyro is still very new!). We have a set of about 120 different web services implemented using the Restlet framework. These are consumed by web service clients generally built on top of a Restlet-based client library. The representations sent back and forth between server and client include XML (using the XStream serialization library), JSON (Using Jackson), XHTML, Java Object Serialization, and as of yesterday, Kryo. So we're in a position to do some solid side-by-side comparisons. Kryo 1.0.1 seems reasonably stable. Once I actually read up on how to use the API, the only real problem I found was that the default java.util.Date serializer seemed to warp dates a few months into the past. I just had to provide my own override: kryo.register(Date.class, new SimpleSerializer&lt;Date&gt;() { @Override public void write (ByteBuffer b, Date d) { b.putLong(d.getTime()); } @Override public Date read (ByteBuffer b) { return new Date(b.getLong()); } }); But that was the only possible issue I've found so far. We have a set of JavaBeans that have String, Float, Integer, Long, Date, Boolean and List fields. Here are some rough benchmarks. First, I did 100,000 serializations and deserializations of an object hierarchy that describes one TV program (ie, made 100,000 deep copies of it). The speeds were: XStream XML: 360/sec Java Object Serialization: 1,570/sec Jackson JSON: 5,000/sec Kryo: 8,100/sec Next, I also serialized a catalog of 2,000 TV program descriptions and counted bytes: XStream XML: 6,837,851 bytes Jackson JSON: 3,656,654 bytes Kryo: 1,124,048 bytes I also found that registering serializers was very important: kryo.register(List.class); kryo.register(ArrayList.class); // ... kryo.register(Program.class); kryo.register(Catalog.class); // ... If I didn't do that, the serializations were almost double the size, and the speed was maybe 40% slower. We also ran complete end-to-end tests of several web services using each of these four seri…

http://stackoverflow.com/comment/60233637
type: Comment
type: AnswerComment
has text: That memory hierarchy has anything to do with this is a myth. Google "MESI protocol".
score: 0
comment on: http://stackoverflow.com/a/21409975

http://stackoverflow.com/a/2744831
score: 1
has body: Class#isAssignableFrom(java.lang.Class) is another option.
downvote count: 0
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/2744812

http://stackoverflow.com/a/2667200
downvote count: 1
score: -1
upvote count: 0
has body: Ok, I got as far as following: public class CopyStream extends Thread { static final int BUFFERSIZE = 10 * 1024; InputStream input; OutputStream output; boolean closeInputOnExit, closeOutputOnExit, flushOutputOnWrite; public IOException ex; public CopyStream (InputStream input, boolean closeInputOnExit, OutputStream output, boolean closeOutputOnExit, boolean flushOutputOnWrite) { super("CopyStream"); this.input = input; this.closeInputOnExit = closeInputOnExit; this.output = output; this.closeOutputOnExit = closeOutputOnExit; this.flushOutputOnWrite = flushOutputOnWrite; start(); } public void run () { try { byte[] buffer = new byte[BUFFERSIZE]; for (int bytes = input.read(buffer); bytes&gt;=0; bytes = input.read(buffer)) { output.write(buffer,0,bytes); if (flushOutputOnWrite) output.flush(); } } catch (IOException ex) { this.ex = ex; } finally { if (closeInputOnExit) { try { input.close(); } catch (IOException ex) { if (this.ex==null) this.ex = ex; } } if (closeOutputOnExit) { try { output.close(); } catch (IOException ex) { if (this.ex==null) this.ex = ex; } } } } } Then the code would look as following: ZipInputStream zis = new ZipInputStream(new FileInputStream(ZIPPATH)); for (ZipEntry ze = zis.getNextEntry(); ze!=null; ze = zis.getNextEntry()) { Process decoder = new ProcessBuilder(EXTERNALPROCESSOR).start(); CopyStream cs1 = new CopyStream(is,false,decoder.getOutputStream(),true,true); CopyStream cs2 = new CopyStream(decoder.getErrorStream(),true,System.err,false,true); BufferedReader br = new BufferedReader(new InputStreamReader(decoder.getInputStream(),"us-ascii")); ArrayList&lt;String&gt; lines = new ArrayList&lt;String&gt;(); for (String line = br.readLine(); line!=null; line = br.readLine()) { lines.add(line); } if (decoder.exitValue()!=0) throw new IOException("Decoder exits with "+decoder.exitValue()); try { cs1.join(100); } catch (InterruptedException ex) { throw new IOException(ex); } if (cs1.isAlive()) throw new IOException("cs1 not terminated"); if …
type: Answer
answers question: http://stackoverflow.com/q/2659996

http://stackoverflow.com/a/2678397
type: Answer
has comment: http://stackoverflow.com/comment/2878150
has body: This looks like direct HTTP output... so just scanning for the first two consecutive line feeds (probably with carriage returns in front of them) will give you the end of the prefix you want to filter out.
upvote count: 4
downvote count: 0
answers question: http://stackoverflow.com/q/2678299
score: 4

http://stackoverflow.com/comment/2606548
comment on: http://stackoverflow.com/q/2597841
score: 0
type: Comment
type: QuestionComment
has text: So turns out there is no built in method. I ended up doing String str = kb.nextLine(); char c = str.charAt(0);

gmail
type: Tag
tags question: http://stackoverflow.com/q/2714296
tag name: gmail

http://stackoverflow.com/comment/2802526
score: 3
comment on: http://stackoverflow.com/a/2769335
type: AnswerComment
type: Comment
has text: Yeah, a few of us all responded at the same time. It's not the end of the world.

http://stackoverflow.com/q/2737027
has title: Getting absolute path of an Object
has body: how to get the absolute path of given object id using java dfc in documentum.
answer count: 1
score: 0
tagged with: java
tagged with: servlets
has answer: http://stackoverflow.com/a/2749336
accepted answer: http://stackoverflow.com/a/2749336
tagged with: documentum
type: Question
type: AnsweredQuestion

http://stackoverflow.com/a/2665594
upvote count: 8
type: Answer
has comment: http://stackoverflow.com/comment/2684228
score: 8
has comment: http://stackoverflow.com/comment/84947723
has comment: http://stackoverflow.com/comment/84947680
answers question: http://stackoverflow.com/q/2665569
has comment: http://stackoverflow.com/comment/2683617
has comment: http://stackoverflow.com/comment/2684363
has body: InterruptedException will be thrown if interrupt is called on the waiting thread before the computation has completed. ExecutionException will be thrown if the computation involved (Task in this case) throws an exception itself. How you want to handle this will entirely depend on your application. EDIT: Here's a demonstration of being interrupted: import java.util.concurrent.*; public class Test { public static void main(String[] args) throws Exception { ExecutorService executor = Executors.newFixedThreadPool(2); Future&lt;String&gt; future = executor.submit(new SlowCallable()); executor.submit(new Interruptor(Thread.currentThread())); try { System.out.println(future.get()); } catch (InterruptedException e) { System.out.println("I was interrupted"); } } private static class Interruptor implements Callable&lt;String&gt; { private final Thread threadToInterrupt; Interruptor(Thread threadToInterrupt) { this.threadToInterrupt = threadToInterrupt; } public String call() throws Exception { Thread.sleep(2000); threadToInterrupt.interrupt(); return "interrupted other thread"; } } private static class SlowCallable implements Callable&lt;String&gt; { public String call() throws Exception { Thread.sleep(5000); return "finished"; } } }
has comment: http://stackoverflow.com/comment/84947718
has comment: http://stackoverflow.com/comment/84947764
has comment: http://stackoverflow.com/comment/84947666
downvote count: 0

http://stackoverflow.com/comment/125092563
score: 1
has text: For a while, fields of ClassLoader class are not accessible via reflection. Even with `setAccessible` method. See https://stackoverflow.com/a/17805624/9710708
type: AnswerComment
comment on: http://stackoverflow.com/a/10261850
type: Comment

http://stackoverflow.com/comment/2768497
has text: ? so did you fix your problem or not?
type: AnswerComment
comment on: http://stackoverflow.com/a/2739796
score: 0
type: Comment

http://stackoverflow.com/a/2710219
upvote count: 5
has comment: http://stackoverflow.com/comment/2734810
has comment: http://stackoverflow.com/comment/2734744
answers question: http://stackoverflow.com/q/2710212
score: 5
downvote count: 0
has comment: http://stackoverflow.com/comment/2734763
has body: I think you want something like SQLite (Java bindings) (a fast flat-file general purpose embeddable database).
type: Answer

http://stackoverflow.com/comment/2685967
score: 0
type: Comment
type: QuestionComment
has text: Crowder, this is my hashmap declaration: public HashMap<String, Integer> word = new HashMap<String, Integer>();
comment on: http://stackoverflow.com/q/2667683

http://stackoverflow.com/a/2713015
upvote count: 3
type: Answer
score: 2
has body: What are your experiences? Did you have problems with one or the other approach? I never called the default constructor (explicit) and never faced any problems
answers question: http://stackoverflow.com/q/2712971
downvote count: 1

http://stackoverflow.com/comment/2631542
type: AnswerComment
comment on: http://stackoverflow.com/a/2619356
type: Comment
has text: Good idea I'll try it and post results, will choose best answer if this helps works out.
score: 0

http://stackoverflow.com/comment/104602688
type: Comment
has text: With Java 8, the first example can be simplified to `strings.replaceAll(String::toLowerCase);` You could do a similar thing with the second, using `Arrays.asList(stringsArray).replaceAll(String::toLowerCase);`
score: 2
comment on: http://stackoverflow.com/a/2644731
type: AnswerComment

http://stackoverflow.com/q/2673398
answer count: 5
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2673458
score: 6
downvote count: 0
tagged with: java
tagged with: memory
type: Question
has comment: http://stackoverflow.com/comment/2692157
has answer: http://stackoverflow.com/a/2673428
upvote count: 6
has comment: http://stackoverflow.com/comment/2692184
has answer: http://stackoverflow.com/a/2673509
has answer: http://stackoverflow.com/a/2673511
tagged with: arraylist
has title: Java: How ArrayList manages memory
has answer: http://stackoverflow.com/a/2673420
has body: In my Data Structures class we have studies the Java ArrayList class, and how it grows the underlying array when a user adds more elements. That is understood. However, I cannot figure out how exactly this class frees up memory when lots of elements are removed from the list. Looking at the source, there are three methods that remove elements: public E remove(int index) { RangeCheck(index); modCount++; E oldValue = (E) elementData[index]; int numMoved = size - index - 1; if (numMoved &gt; 0) System.arraycopy(elementData, index+1, elementData, index, numMoved); elementData[--size] = null; // Let gc do its work return oldValue; } public boolean remove(Object o) { if (o == null) { for (int index = 0; index &lt; size; index++) if (elementData[index] == null) { fastRemove(index); return true; } } else { for (int index = 0; index &lt; size; index++) if (o.equals(elementData[index])) { fastRemove(index); return true; } } return false; } private void fastRemove(int index) { modCount++; int numMoved = size - index - 1; if (numMoved &gt; 0) System.arraycopy(elementData, index+1, elementData, index, numMoved); elementData[--size] = null; // Let gc do its work } None of them reduce the datastore array. I even started questioning if memory free up ever happens, but empirical tests show that it does. So there must be some other way it is done, but where and how? I checked the parent classes as well with no success.
favorite count: 0

primitive-types
tags question: http://stackoverflow.com/q/2720738
tags question: http://stackoverflow.com/q/2639782
tags question: http://stackoverflow.com/q/2602038
tags question: http://stackoverflow.com/q/2623366
type: Tag
tag name: primitive-types

http://stackoverflow.com/q/2649145
type: Question
score: 14
tagged with: java
tagged with: hibernate
has answer: http://stackoverflow.com/a/2650898
has answer: http://stackoverflow.com/a/2675343
has comment: http://stackoverflow.com/comment/2665150
tagged with: jpa
downvote count: 0
answer count: 7
has answer: http://stackoverflow.com/a/2667817
favorite count: 0
has comment: http://stackoverflow.com/comment/2665199
has body: I have a many to may relationship CohortGroup and Employee. Any time I insert an Employee into the CohortGroup hibernate deletes the group from the resolution table and inserts all the members again, plus the new one. Why not just add the new one? The annotation in the Group: @ManyToMany(cascade = { PERSIST, MERGE, REFRESH }) @JoinTable(name="MYSITE_RES_COHORT_GROUP_STAFF", joinColumns={@JoinColumn(name="COHORT_GROUPID")}, inverseJoinColumns={@JoinColumn(name="USERID")}) public List&lt;Employee&gt; getMembers(){ return members; } The other side in the Employee @ManyToMany(mappedBy="members",cascade = { PERSIST, MERGE, REFRESH } ) public List&lt;CohortGroup&gt; getMemberGroups(){ return memberGroups; } Code snipit Employee emp = edao.findByID(cohortId); CohortGroup group = cgdao.findByID(Long.decode(groupId)); group.getMembers().add(emp); cgdao.persist(group); below is the sql reported in the log delete from swas.MYSITE_RES_COHORT_GROUP_STAFF where COHORT_GROUPID=? insert into swas.MYSITE_RES_COHORT_GROUP_STAFF (COHORT_GROUPID, USERID) values (?, ?) insert into swas.MYSITE_RES_COHORT_GROUP_STAFF (COHORT_GROUPID, USERID) values (?, ?) insert into swas.MYSITE_RES_COHORT_GROUP_STAFF (COHORT_GROUPID, USERID) values (?, ?) insert into swas.MYSITE_RES_COHORT_GROUP_STAFF (COHORT_GROUPID, USERID) values (?, ?) insert into swas.MYSITE_RES_COHORT_GROUP_STAFF (COHORT_GROUPID, USERID) values (?, ?) insert into swas.MYSITE_RES_COHORT_GROUP_STAFF (COHORT_GROUPID, USERID) values (?, ?) This seams really inefficient and is causing some issues. If sevral requests are made to add an employee to the group then some get over written. Seams like equals and hashCode might be a reason for this. Below are the implementation for these methods. Any red flags? CohortGroup @Override public int hashCode() { final int prime = 31; int result = getName().hashCode(); result = prime * result + ((emp == null) ? 0 : emp.hashCode()); return result; } @Override public boolean equals(Object obj) { if (thi…
has title: hibernate insert to a collection causes a delete then all the items in the collection to be inserted again
accepted answer: http://stackoverflow.com/a/2675343
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/55566729
has answer: http://stackoverflow.com/a/2650992
upvote count: 14
has answer: http://stackoverflow.com/a/7166917
tagged with: orm
has comment: http://stackoverflow.com/comment/2668087
has answer: http://stackoverflow.com/a/51387461
possible better answer: http://stackoverflow.com/a/2650992

http://stackoverflow.com/a/2659020
answers question: http://stackoverflow.com/q/2659000
type: Answer
score: 1
has body: Have a look at the HttpURLConnection class API documentation, especially setInstanceFollowRedirects().
upvote count: 2
downvote count: 1

http://stackoverflow.com/a/2760972
upvote count: 1
answers question: http://stackoverflow.com/q/2760811
score: 1
has body: I think you misundersand SwingWorker a little. Most of it is right, but you cannot call getImage() immediately after execute() - the execute call returns immediately, and your images are being loaded on the worker thread. So, the immediate call to getImages() has no images to fetch. To fix this, you should do your image handling in the done() override, e.g. adding the images to the UI component that will display them.
downvote count: 0
type: Answer

http://stackoverflow.com/a/2775286
answers question: http://stackoverflow.com/q/2772303
has body: How to go about this... Let's extract a couple of methods, so we can better see the logic. private void a() { entry2.setDebit(adjustment.total); entry2.setCredit(0d); } private void b() { entry2.setCredit(adjustment.total); entry2.setDebit(0d); } if (adjustment.adjustmentAccount.isIncrease) { if (adjustment.increaseVATLine) { if (adjustment.vatItem.isSalesType) { a(); } else { b(); } } else { if (adjustment.vatItem.isSalesType) { b(); } else { a(); } } } else { if (adjustment.increaseVATLine) { if (adjustment.vatItem.isSalesType) { b(); } else { a(); } } else { if (adjustment.vatItem.isSalesType) { a(); } else { b(); } } So now, looking at it, that first block if (adjustment.increaseVATLine) { if (adjustment.vatItem.isSalesType) { a(); } else { b(); } } else { if (adjustment.vatItem.isSalesType) { b(); } else { a(); } } just amounts to doing a() if adjustment.increaseVATLine has the same value as adjustment.vatItem.isSalesType, b() otherwise. So we can reduce it: if (adjustment.adjustmentAccount.isIncrease) { if (adjustment.increaseVATLine == adjustment.vatItem.isSalesType) { a(); } else { b(); } } else { if (adjustment.increaseVATLine) { if (adjustment.vatItem.isSalesType) { b(); } else { a(); } } else { if (adjustment.vatItem.isSalesType) { a(); } else { b(); } } } And the remaining block is the same, just reversing a() and b(): if (adjustment.adjustmentAccount.isIncrease) { if (adjustment.increaseVATLine == adjustment.vatItem.isSalesType) { a(); } else { b(); } } else { if (adjustment.increaseVATLine == adjustment.vatItem.isSalesType) { b(); } else { a(); } } So we begin to see the logic. If it's an increase, and the increaseVATLine matches the isSalesType, then we debit, otherwise credit, but if it's a decrease, then we credit only if they don't match. What's a good way of expressing this? Well, for one, name a() and b() smarter - now that we can see what they're doing if (adjustment.adjustmentAccount.isIncrease) { if (adjustment.increaseVATLine == adjustment.va…
downvote count: 0
score: 18
has comment: http://stackoverflow.com/comment/2811968
upvote count: 18
type: Answer

http://stackoverflow.com/a/30832901
type: Answer
has body: Update: The Joda-Time project is now in maintenance mode, with the team advising migration to the java.time classes. See Tutorial by Oracle. See the correct Answer by Ortomala Lokni, using the modern java.time classes. I am leaving this outmoded Answer intact as history. The Answer by Lokni is correct. Here is the same idea but using Joda-Time 2.8. long millisSinceEpoch = mar.getEventDate() ; DateTimeZone zone = DateTimeZone.forID( "America/Montreal" ) ; // Or DateTimeZone.UTC LocalDate localDate = new LocalDate( millisSinceEpoch , zone ) ; int dayOfMonth = localDate.getDayOfMonth() ;
downvote count: 0
score: 2
answers question: http://stackoverflow.com/q/2619691
upvote count: 2

http://stackoverflow.com/comment/2768839
comment on: http://stackoverflow.com/q/2739447
has text: thx for your help. please see my comment to BalusC's answer for more information.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/2712689
has comment: http://stackoverflow.com/comment/2738459
has comment: http://stackoverflow.com/comment/2737662
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/2737625
has body: I don't know of any libraries that will do this for you, but it is a pretty trivial programming task... Make one pass through the data and measure the maximum length of a string in each column Make a second pass through writing the data out with padding on either side of each datum to make the width the same as the maximum. Write yourself a function that pads a String on either end to a fixed length. EDIT: just seen the other answer about the Apache commons string centering utility - that'll save you having to write one, so long as you don't mind adding that dependency to you rproject.
has comment: http://stackoverflow.com/comment/2742625
answers question: http://stackoverflow.com/q/2712624
has comment: http://stackoverflow.com/comment/2737592
upvote count: 1
has comment: http://stackoverflow.com/comment/2738476
type: Answer

http://stackoverflow.com/comment/2788294
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2756795
has text: Good to know. I looked through the Arrays for that function :) I guess one could go through Arrays.asList to get the shortest solution :) ...or do it with Scala ;)
type: Comment

http://stackoverflow.com/a/2773121
answers question: http://stackoverflow.com/q/2772977
type: Answer
upvote count: 1
has body: I'm guessing this isn't what he wasn't looking for, but if you want to get technical you could also mention that Singleton is a pattern, not an implementation. Messing with the class constructor isn't the only way to have a Singleton, you could have a factory enforcing the pattern, in which case you can use inheritance in exactly the same way as with other classes.
score: 1
downvote count: 0

http://stackoverflow.com/comment/2684562
type: AnswerComment
type: Comment
has text: Presumably though the alreadyExecuted is going to be a local variable though,
comment on: http://stackoverflow.com/a/2666025
score: 2

http://stackoverflow.com/comment/2618620
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2608352
score: 0
has text: That fact that this this is a single "large" class that you wish to use as a library sounds a bit alarming. Are these static utility methods? Typically you would distribute behaviour over multiple classes.

http://stackoverflow.com/comment/2638379
comment on: http://stackoverflow.com/q/2625466
score: 0
has text: Aren't unquoted characters like > illegal in XML? There is never going to be a literal >.
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2607112
tagged with: return
possible better answer: http://stackoverflow.com/a/2607144
has answer: http://stackoverflow.com/a/2607600
tagged with: static-constructor
type: AnsweredQuestion
downvote count: 0
accepted answer: http://stackoverflow.com/a/2607294
has title: Returning in a static initializer
has answer: http://stackoverflow.com/a/2607133
tagged with: java
has body: This isn't valid code: public class MyClass { private static boolean yesNo = false; static { if (yesNo) { System.out.println("Yes"); return; // The return statement is the problem } System.exit(0); } } This is a stupid example, but in a static class constructor we can't return;. Why? Are there good reasons for this? Does someone know something more about this? So the reason why I should do return is to end constructing there. Thanks
score: 13
tagged with: class-constructors
type: Question
has answer: http://stackoverflow.com/a/2607144
has answer: http://stackoverflow.com/a/2607294
has answer: http://stackoverflow.com/a/2607215
upvote count: 13
answer count: 6
has comment: http://stackoverflow.com/comment/2617258
has answer: http://stackoverflow.com/a/2612572
favorite count: 0

http://stackoverflow.com/a/2676508
answers question: http://stackoverflow.com/q/2676451
upvote count: 1
type: Answer
downvote count: 0
has body: In fact, once the sources has been obfuscated, ProGuard generates a log file that can be used to replace class names in xml file, in a grep-like way. Otherwise, it is also possible to exclude classes extending a specific class or interface in proGuard. This way, your struts actions won't be ofbuscated (which is a lamer obfuscation strategy) but the rest of your application will be.
score: 1

http://stackoverflow.com/a/2761016
answers question: http://stackoverflow.com/q/2760995
has body: Well, in Java there's no literal syntax for lists, so you have to do .add(). If you have a lot of elements, it's a bit verbose, but you could either: use Groovy or something like that use Arrays.asList(array) 2 would look something like: String[] elements = new String[] {"Ryan", "Julie", "Bob"}; List list = new ArrayList(Arrays.asList(elements)); This results in some unnecessary object creation though.
score: 9
upvote count: 10
type: Answer
downvote count: 1

http://stackoverflow.com/a/2642910
type: Answer
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/2657831
has body: Your question really doesn't make any sense to me so I'm just making a wild guess A TableModel can be used by many tables. So you can easily create a JTable using a TableModel. Then you can use the TableColumnModel to remove TableColumns from the view. Therefore only a single column will be visible in the scrollpane. Edit: To scroll horizontally you use: table.setAutoResizeMode( JTable.AUTO_RESIZE_OFF ); Then you set the TableColumn to your preferred width and scrollbar will appear if required. Read the JTable API and follow the link to the Swing tutorial on "How to Use Tables" for more information about setting the column width.
answers question: http://stackoverflow.com/q/2642829
has comment: http://stackoverflow.com/comment/2657906
upvote count: 1
has comment: http://stackoverflow.com/comment/2657888
has comment: http://stackoverflow.com/comment/2657979

http://stackoverflow.com/comment/2792234
type: Comment
has text: Could be please tell me three things. First, what are those other ways which can be used for thread safety (I think volatile variables are one out of them). Second, in what situations the synchronization approach fails? Third, what problems you think that we encounter with synchronization?
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2760350

http://stackoverflow.com/comment/74934665
has text: **From review queue**: May I request you to please add some more context around your answer. Code-only answers are difficult to understand. It will help the asker and future readers both if you can add more information in your post.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/43950541
type: AnswerComment

http://stackoverflow.com/comment/17469769
score: 0
comment on: http://stackoverflow.com/q/2647594
type: Comment
type: QuestionComment
has text: I'am not sure what might be the actual problem, but See this link http://struts.apache.org/2.0.6/docs/client-side-validation.html, it might be helpful

http://stackoverflow.com/comment/9652400
has text: I like the post from Remi Fouilloux more and use it very often. It removes the need for a catpure object.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/7796833

http://stackoverflow.com/a/2674754
has comment: http://stackoverflow.com/comment/2693620
has comment: http://stackoverflow.com/comment/2693706
answers question: http://stackoverflow.com/q/2674707
has comment: http://stackoverflow.com/comment/2693824
has comment: http://stackoverflow.com/comment/2693599
score: 36
upvote count: 36
downvote count: 0
type: Answer
has body: Michael Borgwardt's solution is the best for 5 digits, but if you have variable number of digits, you can use something like this: public static String concatenateDigits(int... digits) { StringBuilder sb = new StringBuilder(digits.length); for (int digit : digits) { sb.append(digit); } return sb.toString(); }

http://stackoverflow.com/comment/2619838
has text: @Dave Jarvis: Well, if you haven't been in school for 15 years, no wonder you don't understand the homework questions! Maybe if you showed up for class you'd know this stuff!
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2609236
score: 0

http://stackoverflow.com/a/2633869
upvote count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/2647821
score: 0
has comment: http://stackoverflow.com/comment/2656860
has body: The second method will generate a compiler error that reader may not have been initialized. You can get around that by initializing it to null, but that just means you could get an NPE, and there's no advantage to that.
answers question: http://stackoverflow.com/q/2633834
type: Answer

size
tags question: http://stackoverflow.com/q/2758966
type: Tag
tags question: http://stackoverflow.com/q/2715118
tags question: http://stackoverflow.com/q/2606424
tag name: size

http://stackoverflow.com/comment/2803199
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2769693
has text: Ah, I suppose more information about how the threads are aggregating their results would be needed to provide more intelligent advice. If joining them from the main application thread is the method specified for the assignment, no merit in over-thinking it!
score: 0

http://stackoverflow.com/q/2624165
has title: How to copy an object by value, not by reference
linked to: http://stackoverflow.com/q/64036
has answer: http://stackoverflow.com/a/2624206
score: 50
has answer: http://stackoverflow.com/a/2624185
linked to: http://stackoverflow.com/q/2427883
duplicate of: http://stackoverflow.com/q/64036
downvote count: 0
answer count: 7
upvote count: 50
favorite count: 0
has answer: http://stackoverflow.com/a/2624278
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2624240
has answer: http://stackoverflow.com/a/36498082
has body: I want to make a copy of an object, then after some logic, re-assign the original object the value of the copy. example: User userCopy = //make a copy foreach(...) { user.Age = 1; user.ID = -1; UserDao.Update(user) user = userCopy; } I don't want a copy by reference, it has to be a copy by value. The above is just a sample, not how I really want to use it but I need to learn how to copy by value.
tagged with: java
has answer: http://stackoverflow.com/a/2624190
has answer: http://stackoverflow.com/a/2624375
type: Question
linked to: http://stackoverflow.com/q/2326758

http://stackoverflow.com/comment/2616703
has text: You don't appear to be asking about classes at all. Please edit the question's subject.
score: 2
comment on: http://stackoverflow.com/q/2606624
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2635272
tagged with: c++
has comment: http://stackoverflow.com/comment/22011811
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/1125534
has comment: http://stackoverflow.com/comment/2657769
possible better answer: http://stackoverflow.com/a/11490043
tagged with: java
has comment: http://stackoverflow.com/comment/2649325
has answer: http://stackoverflow.com/a/6412333
has body: I have a Java app, connecting through TCP socket to a "server" developed in C/C++. both app &amp; server are running on the same machine, a Solaris box (but we're considering migrating to Linux eventually). type of data exchanged is simple messages (login, login ACK, then client asks for something, server replies). each message is around 300 bytes long. Currently we're using Sockets, and all is OK, however I'm looking for a faster way to exchange data (lower latency), using IPC methods. I've been researching the net and came up with references to the following technologies: shared memory pipes queues as well as what's referred as DMA (Direct Memory Access) but I couldn't find proper analysis of their respective performances, neither how to implement them in both JAVA and C/C++ (so that they can talk to each other), except maybe pipes that I could imagine how to do. can anyone comment about performances &amp; feasibility of each method in this context ? any pointer / link to useful implementation information ? EDIT / UPDATE following the comment &amp; answers I got here, I found info about Unix Domain Sockets, which seem to be built just over pipes, and would save me the whole TCP stack. it's platform specific, so I plan on testing it with JNI or either juds or junixsocket. next possible steps would be direct implementation of pipes, then shared memory, although I've been warned of the extra level of complexity... thanks for your help
has answer: http://stackoverflow.com/a/2635319
has answer: http://stackoverflow.com/a/11490043
has answer: http://stackoverflow.com/a/4311771
has answer: http://stackoverflow.com/a/2635409
has title: fastest (low latency) method for Inter Process Communication between Java and C/C++
has answer: http://stackoverflow.com/a/17450249
has answer: http://stackoverflow.com/a/2642814
type: Question
has comment: http://stackoverflow.com/comment/2651361
has comment: http://stackoverflow.com/comment/78442939
has comment: http://stackoverflow.com/comment/2658058
tagged with: performance
has comment: http://stackoverflow.com/comment/2649702
accepted answer: http://stackoverflow.com/a/6412333
tagged with: ipc
has comment: http://stackoverflow.com/comment/78410432
has answer: http://stackoverflow.com/a/2635496
has answer: http://stackoverflow.com/a/2636082
score: 113
upvote count: 113
downvote count: 0
favorite count: 0
tagged with: latency
has answer: http://stackoverflow.com/a/2642913
answer count: 10
has comment: http://stackoverflow.com/comment/78410203

http://stackoverflow.com/comment/5787385
has text: first anwer is usefull, brings me on a idea :D
score: 0
comment on: http://stackoverflow.com/a/2682602
type: Comment
type: AnswerComment

http://stackoverflow.com/a/2715512
score: 0
type: Answer
has body: Your problem description isn't fully clear to me, but I'll try to answer what I understand. First of all, you can select a random item from a weighted distribution by doing the following: Find the sum of the weights of all potential objects which we'll call wsum. Pick a random number, a. Initialize a cumulative variable, total to 0.0. Starting with the first possible object (weight > 0.0), add the weight to total. If a &lt; total/wsum, this number is chosen and we remove it from the list of possible objects as well as subtracting its weight from wsum. If we have chosen enough objects, continue, otherwise go to step 2. It helps to have the objects sorted by the weights in descending order to improve the speed of the operation a little bit. That is just to find which object we're choosing from the current distribution. It sounds like your distribution is changing with time so you would just need to change the list of possible objects to be chosen with time.
answers question: http://stackoverflow.com/q/2702519

http://stackoverflow.com/a/2735906
has comment: http://stackoverflow.com/comment/42432701
has comment: http://stackoverflow.com/comment/94708498
has comment: http://stackoverflow.com/comment/60164119
has comment: http://stackoverflow.com/comment/91519803
score: 158
downvote count: 1
has comment: http://stackoverflow.com/comment/65384386
answers question: http://stackoverflow.com/q/2735736
accepted answer of: http://stackoverflow.com/q/2735736
upvote count: 159
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/37603385
has body: Every time I go from heavy C++ coding to Java, it takes me a little while to adapt to the lack of const-correctness in Java. This usage of const in C++ is much different than just declaring constant variables, if you didn't know. Essentially, it ensures that an object is immutable when accessed through a special kind of pointer called a const-pointer When in Java, in places where I'd normally want to return a const-pointer, I instead return a reference with an interface type containing only methods that shouldn't have side effects. Unfortunately, this isn't enforced by the langauge. Wikipedia offers the following information on the subject: Interestingly, the Java language specification regards const as a reserved keyword — i.e., one that cannot be used as variable identifier — but assigns no semantics to it. It is thought that the reservation of the keyword occurred to allow for an extension of the Java language to include C++-style const methods and pointer to const type. The enhancement request ticket in the Java Community Process for implementing const correctness in Java was closed in 2005, implying that const correctness will probably never find its way into the official Java specification.
type: Answer

http://stackoverflow.com/comment/2706339
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2685206
has text: What are you talking about? These events are there and they are triggered by Hibernate on your back. So there is nothing to add apart from the listener to leverage them. Maybe you should read the documentation.
type: AnswerComment

http://stackoverflow.com/comment/2729525
score: 2
has text: The question was how to accomplish an process invocation using **commons-exec**, which wraps most of the stuff displayed in this answer.
type: AnswerComment
comment on: http://stackoverflow.com/a/2705763
type: Comment

http://stackoverflow.com/q/2724725
accepted answer: http://stackoverflow.com/a/2724939
downvote count: 0
answer count: 7
has comment: http://stackoverflow.com/comment/66115348
favorite count: 0
tagged with: linux
has answer: http://stackoverflow.com/a/2727154
has answer: http://stackoverflow.com/a/8523149
tagged with: daemon
has answer: http://stackoverflow.com/a/2725137
has title: Best way to daemonize Java application on Linux
has answer: http://stackoverflow.com/a/2724868
has answer: http://stackoverflow.com/a/2724939
upvote count: 7
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2724796
score: 7
tagged with: java
possible better answer: http://stackoverflow.com/a/2724931
type: Question
has comment: http://stackoverflow.com/comment/28925080
has answer: http://stackoverflow.com/a/2724931
has body: While I found this question being answered here on SW several times, I didn't find a concluding answer what is the best approach. I'm not looking to use any external wrapper, as I found them launching the java process under a nice level lower then themselves which potentially lowers the performance, so it seems only the shell methods are left. I so far found 3 different shell methods: start-stop-daemon RedHat daemon init.d function nohup on start / disown after start What you people are using, and can recommend as the most reliable method? Thanks.

http://stackoverflow.com/comment/2724196
comment on: http://stackoverflow.com/a/2701098
score: 0
type: AnswerComment
has text: @Green Hyena: that is why I included the link, but I see that I linked to the wrong URL. This is now corrected. Thanks for hinting.
type: Comment

http://stackoverflow.com/comment/2734985
type: Comment
comment on: http://stackoverflow.com/a/2710402
score: 2
type: AnswerComment
has text: @Tom: Or simple as do re mi...

http://stackoverflow.com/q/2612668
score: 5
has answer: http://stackoverflow.com/a/3340263
linked to: http://stackoverflow.com/q/2658554
has answer: http://stackoverflow.com/a/2612904
answer count: 2
accepted answer: http://stackoverflow.com/a/2612904
favorite count: 0
tagged with: java-2d
upvote count: 5
possible better answer: http://stackoverflow.com/a/3340263
type: AnsweredQuestion
downvote count: 0
tagged with: java
has body: Are there any nice libraries to render text in an image for Java? Java has a 2d text library, http://java.sun.com/docs/books/tutorial/2d/text/index.html but not sure if theres a better library to use.
has title: Rendering text in an image in Java
tagged with: image-processing
type: Question

http://stackoverflow.com/comment/2814481
type: AnswerComment
comment on: http://stackoverflow.com/a/2779471
has text: That's too bad but I already thought so. Thanks for clearing that up! I gave further details about how I use the SCM plugin beneath your comment to the initial question.
type: Comment
score: 0

http://stackoverflow.com/q/2686511
score: 2
tagged with: java
has answer: http://stackoverflow.com/a/2686655
type: Question
tagged with: network-programming
downvote count: 0
tagged with: nic
answer count: 1
has body: Is there any way in Java to receive event notifications whenever link state changes on a computer (connected, disconnected, up, down, etc)? Thanks!
favorite count: 0
upvote count: 2
type: UnansweredQuestion
has title: link state notification in Java

http://stackoverflow.com/a/2666018
answers question: http://stackoverflow.com/q/2665655
has comment: http://stackoverflow.com/comment/2684385
type: Answer
has comment: http://stackoverflow.com/comment/2684348
score: 0
has body: A map does indeed seem to be a good solution :) I am new to java / jsp (and most programming in general!) so I was not aware of how simple this is :) The following code: // Financial year runs from Sept-Aug so earlyMonths are those where year = FY-1 and lateMonths are those where year = FY HashMap hm = new HashMap(); int[] earlyMonths = {8, 9, 10, 11}; // Sept to Dec int earlyYear = year -1; for (int i : earlyMonths) { month = i; Calendar cal = Calendar.getInstance(); cal.clear(); cal.set(earlyYear,month,1,0,0,0); Long start = cal.getTimeInMillis(); hm.put(month + "_start", new Long(start)); cal.clear(); cal.set(earlyYear,month,1); lastDayofMonth = cal.getActualMaximum(GregorianCalendar.DAY_OF_MONTH); cal.set(earlyYear,month,lastDayofMonth,23,59,59); Long end = cal.getTimeInMillis(); hm.put(month + "_end", new Long(end)); } int[] lateMonths = {0, 1, 2, 3, 4, 5, 6, 7}; // Jan to Aug for (int i : lateMonths) { month = i; Calendar cal = Calendar.getInstance(); cal.clear(); cal.set(year,month,1,0,0,0); Long start = cal.getTimeInMillis(); hm.put(month + "_start", new Long(start)); cal.clear(); cal.set(year,month,1); lastDayofMonth = cal.getActualMaximum(GregorianCalendar.DAY_OF_MONTH); cal.set(year,month,lastDayofMonth,23,59,59); Long end = cal.getTimeInMillis(); hm.put(month + "_end", new Long(end)); } Set set = hm.entrySet(); Iterator hmi = set.iterator(); while(hmi.hasNext()){ Map.Entry me = (Map.Entry)hmi.next(); out.println(me.getKey() + " : " + me.getValue() + "&lt;br&gt;"); } Gives me the following output: 4_end : 1275350399000 3_start : 1270080000000 8_end : 1254355199000 10_start : 1257033600000 1_start : 1264982400000 2_start : 1267401600000 8_start : 1251763200000 10_end : 1259625599000 0_start : 1262304000000 7_start : 1280620800000 0_end : 1264982399000 4_start : 1272672000000 5_start : 1275350400000 11_end : 1262303999000 5_end : 1277942399000 6_start : 1277942400000 9_start : 1254355200000 3_end : 1272671999000 2_end : 1270079999000 9_end : 1257033599000 1…

http://stackoverflow.com/comment/124486563
type: Comment
has text: Doesn't work if you use javaw (background process)
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/46276980

http://stackoverflow.com/a/2683872
score: 4
has body: Although it is legal Java, and in the case you describe (where it is the last line of the constructor) it is a pretty safe thing to do (with certain edge cases exempted), as a practice it is a bad thing to do, and like using goto (in languages that support the keyword) it should be something you think long and hard about. For your case, a better practice would be to make the constructor private, remove the call to addManager and expose a static factory method: public static Manager createManager(String userName) { Manager manager = new Manager(userName); manager.game.addManager(manager); return manager; } I should also point out that that kind of interdependency among classes (the manager knows about the game and the game knows about the manager) is definitely a code smell, and I would be as concerned about the need for that as I would be about passing this from the constructor.
type: Answer
upvote count: 4
downvote count: 0
answers question: http://stackoverflow.com/q/2683735

http://stackoverflow.com/a/2619180
answers question: http://stackoverflow.com/q/2617898
score: 0
has body: I couldn't reproduce the issue with the version of Hibernate I'm using but my guess is that Hibernate does not recognize your enum property as an @Enumerated property (MyEnum is an enum, right?) and treat it like a Serializable. I know the JPA spec says it's ok to use @Basic with enums but you try without?
type: Answer

http://stackoverflow.com/comment/2770020
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2741151
score: 1
has text: your naming convention is disgraceful

http://stackoverflow.com/comment/2647289
type: QuestionComment
has text: @Igor: I'm not sure whether the demo in that video was from an embedded container or from a separate (remote) one, but I was referring to the latter. In any case, you're correct, and it turns out that it is doable with the -noserver flag with the DevMode runner.
comment on: http://stackoverflow.com/q/2629297
score: 0
type: Comment

http://stackoverflow.com/comment/2827204
has text: Finally, I extended the FlowLayout to make it work as I want and it's kinda cool now: only expand the width :D Thank you very much
type: AnswerComment
comment on: http://stackoverflow.com/a/2745870
score: 0
type: Comment

http://stackoverflow.com/a/2703556
upvote count: 1
has body: Yes, from linux via the ps command. Example: ps x -o command,rss | grep java | grep latest | cut -b 17- The output will be in KB. You may be interested in a question I had a while back regarding Java, RSS and NIO buffers: Why does the Sun JVM continue to consume ever more RSS memory even when the heap, etc sizes are stable?
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/2689914
type: Answer

http://stackoverflow.com/q/2762922
type: Question
tagged with: debugging
possible better answer: http://stackoverflow.com/a/2763077
tagged with: java
tagged with: concurrency
answer count: 2
score: 4
accepted answer: http://stackoverflow.com/a/2808809
tagged with: jvm
has answer: http://stackoverflow.com/a/2763077
upvote count: 4
has answer: http://stackoverflow.com/a/2808809
favorite count: 0
has title: Is there a JVM aimed at debugging concurrent software?
type: AnsweredQuestion
has body: I've used Concurrent Pascal, a tool which helps debug concurrent algorithms because when it runs your code, it randomizes which thread to swap to at every possible step, trying out as many paths as possible. Is there a JVM that can do this?
downvote count: 0
tagged with: multithreading

http://stackoverflow.com/a/2635826
downvote count: 0
score: 5
type: Answer
has body: Straight foward solution: int count = 20; StringBuilder sb = new StringBuilder(count); for (int i=0; i &lt; count; i++){ sb.append(" "); } String s = sb.toString(); StringBuilder is efficient in terms of speed.
has comment: http://stackoverflow.com/comment/2649795
answers question: http://stackoverflow.com/q/2635076
upvote count: 5

http://stackoverflow.com/comment/2743197
type: Comment
comment on: http://stackoverflow.com/a/2717431
score: 14
has text: Might be best to just go for `"\\D"`. It speaks the original intention more directly. "Remove anything that's not a digit."
type: AnswerComment

http://stackoverflow.com/comment/2650401
score: 1
has text: Thanks Jim, I've got it working by moving it into the insert logic to the array. Coming from WPF/XAML, I'm using to being able to sort on the UI markup itself. It's a poor excuse, I know.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2635792

http://stackoverflow.com/comment/15246044
type: Comment
has text: Also I wrote "on most Map implementations". I did not restrict my self to only the "Hashmap". And yes I observe collision lists even with Hashmap, and real slowdowns with fill factors above 85%. yes keySet is returned in constant time, but not when you traverse it. It also has an implementation behind this interface.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2600756

http://stackoverflow.com/a/2759299
answers question: http://stackoverflow.com/q/2759077
has comment: http://stackoverflow.com/comment/2791157
score: 0
has body: Assuming DATE is actually a timestamp that you're not worried about colliding, it seems like your query could be as simple as select mpd from MyProfileData mpd where mpd.profile.name = :name and mpd.date = (select max(mpd1.date) from MyProfileData mpd1 where mpd1.profile.name = :name) Are you using a DBMS like an older MySQL that hates subselects? I am also thinking that perhaps your problem is you haven't mapped the object relationship from MyProfileData to ProfileData, and all you have is the actual integer value of the field. This will make writing JPQL queries quite hard in general. Edit: Continuing on the assumption that the dates don't collide for any given profile + profile data type combo, (so date uniquely identifies a row within the subset of a particular profile + profile type combination) you can just grab all the dates: select mpd from MyProfileData where mpd.profile.name = :name and mpd.date in (select max(mpd1.date) from MyProfileData mpd1 where mpd1.profile = mpd.profile group by mpd.profileDataType) Your original SQL example isn't actually legal, so it's tough to come up with a way to reproduce what it looks like it's trying to do without having a way to uniquely identify the rows while excluding the value.
type: Answer

http://stackoverflow.com/q/2642853
type: Question
has title: Create a mirrored linked list in Java
tagged with: data-structures
score: 0
has answer: http://stackoverflow.com/a/2642886
has answer: http://stackoverflow.com/a/2642870
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/2657771
has answer: http://stackoverflow.com/a/2643107
has comment: http://stackoverflow.com/comment/2657773
answer count: 4
has body: Linked-List: Mirror Consider the following private class for a node of a singly-linked list of integers: private class Node{ public int value; public Node next; } A wrapper-class, called, ListImpl, contains a pointer, called start to the first node of a linked list of Node. Write an instance-method for ListImpl with the signature: public void mirror(); That makes a reversed copy of the linked-list pointed to by start and appends that copy to the end of the list. So, for example the list: start 1 2 3 after a call to mirror, becomes: start 1 2 3 3 2 1 Note: in your answer you do not need to dene the rest of the class for ListImpl just the mirror method.
tagged with: linked-list
tagged with: java
has answer: http://stackoverflow.com/a/2643072

http://stackoverflow.com/comment/127970183
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2622044
type: AnswerComment
has text: I am the one-billionth person to look up how to set the logging level in slf4j, and like everyone else, so far unable to find a clear and simple answer.

http://stackoverflow.com/a/2604294
type: AcceptedAnswer
downvote count: 16
has comment: http://stackoverflow.com/comment/10290012
type: Answer
accepted answer of: http://stackoverflow.com/q/2604169
answers question: http://stackoverflow.com/q/2604169
has comment: http://stackoverflow.com/comment/30832304
has body: Once upon a time... class MusicLibrary { private Set&lt;Music&gt; collection ... public Set&lt;Music&gt; getPopMusic() { ... } public Set&lt;Music&gt; getRockMusic() { ... } public Set&lt;Music&gt; getElectronicaMusic() { ... } } Then you realize you'd like to be able to filter the library's collection by other genres. You could keep adding new getter methods. Or you could use Visitors. interface Visitor&lt;T&gt; { visit(Set&lt;T&gt; items); } interface MusicVisitor extends Visitor&lt;Music&gt;; class MusicLibrary { private Set&lt;Music&gt; collection ... public void accept(MusicVisitor visitor) { visitor.visit( this.collection ); } } class RockMusicVisitor implements MusicVisitor { private final Set&lt;Music&gt; picks = ... public visit(Set&lt;Music&gt; items) { ... } public Set&lt;Music&gt; getRockMusic() { return this.picks; } } class AmbientMusicVisitor implements MusicVisitor { private final Set&lt;Music&gt; picks = ... public visit(Set&lt;Music&gt; items) { ... } public Set&lt;Music&gt; getAmbientMusic() { return this.picks; } } You separate the data from the algorithm. You offload the algorithm to visitor implementations. You add functionality by creating more visitors, instead of constantly modifying (and bloating) the class that holds the data.
has comment: http://stackoverflow.com/comment/11209316
has comment: http://stackoverflow.com/comment/84336209
has comment: http://stackoverflow.com/comment/2628798
has comment: http://stackoverflow.com/comment/6812099
upvote count: 96
score: 80
has comment: http://stackoverflow.com/comment/64630709

soa
type: Tag
tags question: http://stackoverflow.com/q/2629366
tag name: soa

http://stackoverflow.com/a/2713676
type: Answer
has comment: http://stackoverflow.com/comment/2738848
has comment: http://stackoverflow.com/comment/39739722
has comment: http://stackoverflow.com/comment/45369108
score: 24
upvote count: 24
has body: String[] words = sentence.split(" "); String[] reversedWords = ArrayUtils.reverse(words); String reversedSentence = StringUtils.join(reversedWords, " "); (using ArrayUtils and StringUtils from commons-lang, but these are easy methods to write - just a few loops)
has comment: http://stackoverflow.com/comment/2738892
answers question: http://stackoverflow.com/q/2713655
has comment: http://stackoverflow.com/comment/2739058
has comment: http://stackoverflow.com/comment/2738804
has comment: http://stackoverflow.com/comment/12981745
downvote count: 0
has comment: http://stackoverflow.com/comment/45260465
has comment: http://stackoverflow.com/comment/2738893

http://stackoverflow.com/a/2613981
answers question: http://stackoverflow.com/q/2613952
downvote count: 0
score: 2
upvote count: 2
type: Answer
has body: Just initialize it in the static block(the variable is final). You can't catch exceptions on declaring a variable.

http://stackoverflow.com/comment/2730338
comment on: http://stackoverflow.com/q/2706529
has text: That doesn't look like any 2D matrix that I've encountered.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2633956
tagged with: jar
upvote count: 3
answer count: 1
has title: add images into jar ,into specipic locate using ANT
tagged with: insert
favorite count: 0
type: AnsweredQuestion
score: 3
has answer: http://stackoverflow.com/a/2634117
accepted answer: http://stackoverflow.com/a/2634117
downvote count: 0
tagged with: java
has body: i am successfully inserting images into my jar file but all images go to the root directory inside the jar how can i place image in a specific location inside the jar this is what i have so far ,thank you <include name="**/*.png" />
type: Question
tagged with: ant

http://stackoverflow.com/a/41254603
type: Answer
answers question: http://stackoverflow.com/q/2652028
has body: i solved my problem to centralize label names using Simon's answers. Thx setLayoutManager(new BorderLayout()); labelName.setTextAlignment(PositionConstants.CENTER); add(labelName, BorderLayout.CENTER); setBackgroundColor(ColorConstants.lightBlue);
score: 0

http://stackoverflow.com/comment/12504720
comment on: http://stackoverflow.com/a/2600756
type: AnswerComment
score: 0
type: Comment
has text: Note that the builtin hash() functions for native types (byte, short, int, long, float, double) are extremely basic and do **not** create really randomized distribution of bits in the 32-bit patterns returned as hash ! This means that HashMap<int,...> does not warranty at all a constant time, and not even a O(1) access time for many easily reproducible worst cases (in that case the HashMap behaves like an unordered list with O(n) access time!, only mitigated by the HashMap fill factor, which is too large in my opinion and should be reduced to 50% instead of the default 85%....)

http://stackoverflow.com/comment/65384386
type: Comment
score: 11
has text: `final` in Java seems to work like C++ `const` for value types, but more like a C++ non-const `T&` for reference types
type: AnswerComment
comment on: http://stackoverflow.com/a/2735906

http://stackoverflow.com/a/2685931
has comment: http://stackoverflow.com/comment/35880019
has comment: http://stackoverflow.com/comment/2714601
downvote count: 0
has comment: http://stackoverflow.com/comment/2714560
has comment: http://stackoverflow.com/comment/2723131
upvote count: 51
has comment: http://stackoverflow.com/comment/2708635
has comment: http://stackoverflow.com/comment/127213879
has comment: http://stackoverflow.com/comment/2714272
has body: Why are you using OpenSSL to generate the keypair? Why not just use keytool? The genrsa tool just generates a private key. How are you creating a corresponding certificate? How are you importing the private key into your Java keystore? (I ask, because keytool can only import a private key from an existing key store, and only from Java 6 onward.) I suspect that your problem is that your key store doesn't contain a key entry (private key and corresponding certificate). When you list the keystore contents with keytool, how many entries are there? Are they key entries or trusted entries? The server needs access to the private key in order to authenticate itself. To import a private key, use Java 6's enhanced keytool. After creating the key and the certificate with OpenSSL, use OpenSSL to create a PKCS #12 key store: openssl pkcs12 -export -in cert.pem -inkey key.pem &gt; server.p12 Then convert this store into a Java key store: keytool -importkeystore -srckeystore server.p12 -destkeystore server.jks -srcstoretype pkcs12 Now use server.jks in your SSL-enable server, which contains the certificate and the private key.
has comment: http://stackoverflow.com/comment/2726796
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2720076
has comment: http://stackoverflow.com/comment/2708661
score: 51
has comment: http://stackoverflow.com/comment/2715607
accepted answer of: http://stackoverflow.com/q/2685512
type: Answer
answers question: http://stackoverflow.com/q/2685512

http://stackoverflow.com/comment/94003849
type: QuestionComment
type: Comment
score: 1
comment on: http://stackoverflow.com/q/2739392
has text: I coded [this implementation](http://keithschwarz.com/interesting/code/?dir=topological-sort) up a few weeks ago. It's in Java and uses a custom directed graph class. Hopefully the comments are useful!

http://stackoverflow.com/comment/2657992
type: AnswerComment
comment on: http://stackoverflow.com/a/2643059
type: Comment
score: 5
has text: +1 I did something like this the other day when fooling around with Mono/C# on the Mac, except I used a single `\r` to get straight back to the start of the line in one jump.

http://stackoverflow.com/comment/2770883
score: 0
has text: I think this probably applies to most cases outside the Collection Framework as well. In fact, are you aware of any use case that copes with a dynamically changing hash code?
type: Comment
comment on: http://stackoverflow.com/a/2735153
type: AnswerComment

permissions
tag name: permissions
type: Tag
tags question: http://stackoverflow.com/q/2668796
tags question: http://stackoverflow.com/q/2691433

http://stackoverflow.com/comment/2776489
comment on: http://stackoverflow.com/a/2746938
score: 1
type: AnswerComment
type: Comment
has text: But then it should throw a java.lang.UnsupportedOperationException

http://stackoverflow.com/a/21079417
downvote count: 0
type: Answer
has body: Pay attention to method name,It is case sensitive! In my case,it could not recognize getter very well; my property name was uId and I used getUId name for getter name and when I changed it to getuId problem solved!
score: 3
answers question: http://stackoverflow.com/q/2669724
has comment: http://stackoverflow.com/comment/48104648
upvote count: 3

sensors
type: Tag
tags question: http://stackoverflow.com/q/2694818
tag name: sensors

http://stackoverflow.com/comment/2667050
has text: excuse me, you right, it was a mistake, the true size is 49000 * 34300 pix and 105MB, i want to develop a web base mapviewer(AVL Project) so i need to tiling this image(and larger image too) at different zoom level, we tiled it by ImageMagic to 250*230 tiles,we do that, but the created small tile size was to 49000 * 230 instead of 250 * 230 (?)
type: QuestionComment
comment on: http://stackoverflow.com/q/2649048
score: 0
type: Comment

http://stackoverflow.com/comment/2737873
comment on: http://stackoverflow.com/a/2699568
type: AnswerComment
type: Comment
has text: I wrote a https simulator in java. I was able to simulate 12000 - 15000 requests in 15 secs using self-signed certificates. But it takes 3 mins using CA certificates? I really do not understand why this happens.Is there any subtle difference in the handling of self signed versus CA certificates?
score: 0

http://stackoverflow.com/comment/2688932
score: 0
type: AnswerComment
type: Comment
has text: @james: it does that to report exceptions that resulted in the abortion of the task - that's what I meant with "handling a very serious error condition". And it doesn't have multiple threads accessing the exception simultaneously (the FutureTask's own thread is finished by the time the calling thread gets to see it).
comment on: http://stackoverflow.com/a/2668702

http://stackoverflow.com/a/2611902
has body: Firstly, in the ParentObject, "fix" the mappedBy attribute that should be set to "parent". Also (but this is maybe a typo) add an @Id annotation: @Entity public class ParentObject { @Id @GeneratedValue private String id; @OneToMany(mappedBy="parent", fetch=FetchType.EAGER) @IndexColumn(name = "pos", base=0) private List&lt;ObjectChild&gt; attrs; // getters/setters } Then, in ObjectChild, add a name attribute to the objectId in the composite key: @Entity public class ObjectChild { @Embeddable public static class Pk implements Serializable { @Column(name = "parentId", nullable = false, updatable = false) private String objectId; @Column(nullable = false, updatable = false) private String name; @Column(nullable = false, updatable = false) private int pos; } @EmbeddedId private Pk pk; @ManyToOne @JoinColumn(name = "parentId", insertable = false, updatable = false) private ParentObject parent; // getters/setters } AND also add insertable = false, updatable = false to the @JoinColumn because we are repeating the parentId column in the mapping of this entity. With these changes, persisting and reading the entities is working fine for me (tested with Derby).
score: 4
answers question: http://stackoverflow.com/q/2611619
type: Answer
upvote count: 4
downvote count: 0
has comment: http://stackoverflow.com/comment/70481873

http://stackoverflow.com/comment/2833588
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/2718013
type: Comment
has text: +1 for the "more portable skills" thing. That is, historically, the main benefit of any standard since nobody ever actually adheres to standards.

http://stackoverflow.com/q/2758389
has answer: http://stackoverflow.com/a/2758428
score: 0
answer count: 1
accepted answer: http://stackoverflow.com/a/2758428
tagged with: parameters
type: AnsweredQuestion
has title: Java: prebuild flag to check pars not NULLs?
tagged with: java
type: Question
has body: Currently, I use a very conservative way to stop malfunctioing code. It is annoying at the time of a change when I have to change the checker parts as well. if(ds==null||s==null||maxDs==null) { System.out.println("NULL in getDirs(ds[],s,maxDs)"); System.exit(9); } So is there some prebuild-ready Null checker for pars in the API? Does Java build some ready table for Parameters? Perhaps similar to Stdin argv[]. If so, where can I find all automatically build tables like argv[]? Wanna-check-for-parameters for(Object p:pars) { if(p.isNull()) { System.out.println("Lollipop arg your pars are in Lava!"); System.exit(9); } }
tagged with: null

http://stackoverflow.com/q/2738743
has answer: http://stackoverflow.com/a/2738791
has body: While looking in the code of the method: Integer.toHexString I found the following code : public static String toHexString(int i) { return toUnsignedString(i, 4); } private static String toUnsignedString(int i, int shift) { char[] buf = new char[32]; int charPos = 32; int radix = 1 &lt;&lt; shift; int mask = radix - 1; do { buf[--charPos] = digits[i &amp; mask]; i &gt;&gt;&gt;= shift; } while (i != 0); return new String(buf, charPos, (32 - charPos)); } The question is, in toUnsignedString, why we create a char arr of 32 chars?
possible better answer: http://stackoverflow.com/a/2738782
has answer: http://stackoverflow.com/a/2738782
type: AnsweredQuestion
has title: A question in java.lang.Integer internal code
tagged with: java
tagged with: bit-manipulation
type: Question
upvote count: 4
score: 4
answer count: 3
has answer: http://stackoverflow.com/a/2738769
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/2738769

http://stackoverflow.com/a/2648604
score: 0
has body: I think that in web containers that support hot deployment, changing a jar in web-inf/lib or the web.xml triggers a reload of the webapp.
type: Answer
answers question: http://stackoverflow.com/q/2648537

http://stackoverflow.com/comment/33156100
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/3067319
has text: Web Framework Manifesto was reposted and can be found at: http://lift.la/blog/web-framework-manifesto-republished-from-2006
score: 0

http://stackoverflow.com/a/2616131
type: Answer
has comment: http://stackoverflow.com/comment/2627786
accepted answer of: http://stackoverflow.com/q/2616118
score: 1
upvote count: 1
type: AcceptedAnswer
downvote count: 0
has body: You need to use an HTML-parsing library to build a data structure representing the HTML text on this webpage. My recommendation is to use this library: http://htmlparser.sourceforge.net.
answers question: http://stackoverflow.com/q/2616118

http://stackoverflow.com/q/2739282
has answer: http://stackoverflow.com/a/2739526
tagged with: java
type: Question
answer count: 2
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/2739526
has answer: http://stackoverflow.com/a/2739295
tagged with: android
possible better answer: http://stackoverflow.com/a/2739295
has body: My app works on 1.5 emulator and 1.5 device. When i try to start it on 1.6 emulator, it produces strange exceptions (doesn't even start). I don't have any 1.6 device to try this app if it works on a real device. I get some warnings in Eclipse ( warning: Ignoring InnerClasses attribute for an anonymous inner class that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a broken compiler.) and get cant rid of them (i think they come from some apache jars that i need to make http multipart posts). Is it possible that this jars are cause for my exceptions in 1.6 or is it something else? My logacat: 04-29 16:14:55.874: ERROR/AndroidRuntime(392): Uncaught handler: thread main exiting due to uncaught exception 04-29 16:14:55.894: ERROR/AndroidRuntime(392): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.poslji.gor/com.poslji.gor.FormFiller}: java.lang.NumberFormatException: unable to parse 'null' as integer 04-29 16:14:55.894: ERROR/AndroidRuntime(392): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401) 04-29 16:14:55.894: ERROR/AndroidRuntime(392): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417) 04-29 16:14:55.894: ERROR/AndroidRuntime(392): at android.app.ActivityThread.access$2100(ActivityThread.java:116) 04-29 16:14:55.894: ERROR/AndroidRuntime(392): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 04-29 16:14:55.894: ERROR/AndroidRuntime(392): at android.os.Handler.dispatchMessage(Handler.java:99) 04-29 16:14:55.894: ERROR/AndroidRuntime(392): at android.os.Looper.loop(Looper.java:123) 04-29 16:14:55.894: ERROR/AndroidRuntime(392): at android.app.ActivityThread.main(ActivityThread.java:4203) 04-29 16:14:55.894: ERROR/AndroidRuntime(392): at java.lang.reflect.Method.invokeNative(Native Method) 04-29 16:14:55.894: ERROR/AndroidRuntime(392): at java.lang.reflect.Method.invoke(Method.java:521) 04-29 16:14:55.894: ERROR/AndroidRu…
upvote count: 1
has title: App starts in 1.5 emulator but doesn't in 1.6
type: AnsweredQuestion
score: 1

http://stackoverflow.com/q/2635058
favorite count: 0
has answer: http://stackoverflow.com/a/8554622
has answer: http://stackoverflow.com/a/6873863
tagged with: sql
has answer: http://stackoverflow.com/a/3046502
has body: Is there any way where I can get the executed query of iBatis? I want to reuse the query for an UNION query. For example: &lt;sqlMap namespace="userSQLMap"&gt; &lt;select id="getUser" resultClass="UserPackage.User"&gt; SELECT username, password FROM table WHERE id=#value# &lt;/select&gt; &lt;/sqlMap&gt; And when I execute the query through int id = 1 List&lt;User&gt; userList = queryDAO.executeForObjectList("userSQLMap.getUser",id) I want to get SELECT username, password FROM table WHERE id=1 Is there any way I could get the query? Thanks.
tagged with: ibatis
has title: iBatis get executed sql
score: 20
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/21398192
tagged with: java
has answer: http://stackoverflow.com/a/2635986
type: Question
upvote count: 20
has answer: http://stackoverflow.com/a/2635067
downvote count: 0
answer count: 6

http://stackoverflow.com/a/2653151
upvote count: 1
has body: This is the wrong way of streaming from input to output. The right way is: byte[] buffer = new byte[10000]; int bytesRead = 0; while ((bytesRead = responseData.read(buffer)) &gt; 0) { baos.write(buffer, 0, bytesRead); } or byte[] buffer = new byte[10000]; for (int bytesRead = 0; (bytesRead = responseData.read(buffer)) &gt; 0;) { baos.write(buffer, 0, bytesRead); } Also see the Sun tutorial on the subject. A buffer of 1~2K (1024~2048) is by the way often more than enough.
score: 1
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2653111
type: Answer
accepted answer of: http://stackoverflow.com/q/2653111

http://stackoverflow.com/q/2785614
answer count: 2
has body: I'm writing an application in Android that consumes some REST services I've created. These web services aren't issuing a standard Apache Basic challenge / response. Instead in the server-side code I'm wanting to interrogate the username and password from the HTTP(S) request and compare it against a database user to make sure they can run that service. I'm using HttpClient to do this and I have the credentials stored on the client after the initial login (at least that's how I see this working). So here is where I'm stuck. Preemptive authenticate under HttpClient requires you to setup an interceptor as a static member. This is the example Apache Components uses. HttpRequestInterceptor preemptiveAuth = new HttpRequestInterceptor() { @Override public void process( final HttpRequest request, final HttpContext context) throws HttpException, IOException { AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE); CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute( ClientContext.CREDS_PROVIDER); HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST); if (authState.getAuthScheme() == null) { AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort()); Credentials creds = credsProvider.getCredentials(authScope); if (creds != null) { authState.setAuthScheme(new BasicScheme()); authState.setCredentials(creds); } } } }; So the question would be this. What would the proper use of this be? Would I spin this up as part of the application when the application starts? Pulling the username and password out of memory and then using them to create this CredentialsProvider which is then utilized by the HttpRequestInterceptor? Or is there a way to do this more dynamically?
has title: Proper use of HttpRequestInterceptor and CredentialsProvider in doing preemptive authentication with HttpClient
tagged with: java
upvote count: 4
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/2788396
favorite count: 0
tagged with: restful-authentication
has answer: http://stackoverflow.com/a/2788282
tagged with: rest
type: Question
tagged with: android
possible better answer: http://stackoverflow.com/a/2788396
accepted answer: http://stackoverflow.com/a/2788282
score: 4

http://stackoverflow.com/comment/2799584
score: 3
has text: `╔` is what you get when you take `É` in CP1252 and interpret it as CP850.
comment on: http://stackoverflow.com/q/2766780
type: QuestionComment
type: Comment

http://stackoverflow.com/a/2622584
has comment: http://stackoverflow.com/comment/2635285
score: 12
answers question: http://stackoverflow.com/q/2622240
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2622240
type: Answer
upvote count: 12
has body: p is just variable, it doesn't change the type of the Object that's in it. You can think of a cup: You can put any fluid in it, but the cup won't change the type fluid. abstract class Fluid{ public String getTemp(){ return "unknown"; } } class Coffee extends Fluid{ public String getTemp(){ return "hot"; } } class Cola extends Fluid{ public String getTemp(){ return "ice-cold" } } Fluid cup = new Coffee(); System.out.println(cup.getTemp()); //It's coffe in there, so it's hot!
downvote count: 0

http://stackoverflow.com/q/2622680
has body: I'm evaluating GUI builder tools for Swing. In the Eclipse Visual Editor 1.4 the list of the (natively) supported layout managers seems a bit short to me. Still no support for FormsLayout or TableLayout? The official documentation is a bit vague on the issue.
score: 0
answer count: 1
tagged with: user-interface
has answer: http://stackoverflow.com/a/2632081
type: UnansweredQuestion
tagged with: swing
tagged with: java
tagged with: eclipse
has title: Supported Layout Managers in Eclipse Visual Editor
type: Question

http://stackoverflow.com/comment/41687401
has text: what if we want to go through and add to the collection?
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2723538

http://stackoverflow.com/comment/2792370
has text: @Oscar You have indicated a good point but an application can be a single-threaded app or a multi-threaded app. So if I am coding a single-threaded app, then why would I need to synchronize anything at all. And if I am coding a multi-threaded app, then why I shouldn't go with the synchronization of the whole instance methods or the part of those instance methods, instead of synchronizing the `someObject.click()` at every place.
type: AnswerComment
comment on: http://stackoverflow.com/a/2760447
score: 0
type: Comment

http://stackoverflow.com/q/2768054
has comment: http://stackoverflow.com/comment/2819903
type: Question
has answer: http://stackoverflow.com/a/49937215
has answer: http://stackoverflow.com/a/2768198
score: 218
tagged with: coalesce
upvote count: 218
has answer: http://stackoverflow.com/a/70389797
has answer: http://stackoverflow.com/a/41177303
answer count: 14
has answer: http://stackoverflow.com/a/48192967
accepted answer: http://stackoverflow.com/a/2768076
has answer: http://stackoverflow.com/a/18741740
has body: Is there a Java equivalent of SQL's COALESCE function? That is, is there any way to return the first non-null value of several variables? e.g. Double a = null; Double b = 4.4; Double c = null; I want to somehow have a statement that will return the first non-null value of a, b, and c - in this case, it would return b, or 4.4. (Something like the sql method - return COALESCE(a,b,c)). I know that I can do it explicitly with something like: return a != null ? a : (b != null ? b : c) But I wondered if there was any built-in, accepted function to accomplish this.
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/17851702
possible better answer: http://stackoverflow.com/a/18741740
has answer: http://stackoverflow.com/a/9352051
linked to: http://stackoverflow.com/q/978324
has answer: http://stackoverflow.com/a/2768080
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/77764610
has comment: http://stackoverflow.com/comment/13396530
has answer: http://stackoverflow.com/a/6738545
tagged with: java
has answer: http://stackoverflow.com/a/2768076
has answer: http://stackoverflow.com/a/28306286
has title: How to get the first non-null value in Java?
has answer: http://stackoverflow.com/a/29127853

casting
tags question: http://stackoverflow.com/q/2745899
tags question: http://stackoverflow.com/q/2628685
tags question: http://stackoverflow.com/q/2648398
tags question: http://stackoverflow.com/q/2639782
tags question: http://stackoverflow.com/q/2761172
tags question: http://stackoverflow.com/q/2655280
tags question: http://stackoverflow.com/q/2622748
tags question: http://stackoverflow.com/q/2619549
tag name: casting
type: Tag
tags question: http://stackoverflow.com/q/2693180
tags question: http://stackoverflow.com/q/2648758
tags question: http://stackoverflow.com/q/2672645
tags question: http://stackoverflow.com/q/2637851
tags question: http://stackoverflow.com/q/2767212
tags question: http://stackoverflow.com/q/2720738

http://stackoverflow.com/a/2707470
accepted answer of: http://stackoverflow.com/q/2707440
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2707440
type: Answer
has body: There is a Java MSN Messanger Library: This is the link to the download: http://sourceforge.net/projects/java-jml/files/java-jml/jml-1.0b4/jml-1.0b4.jar/download And this is the link to their homepage: http://sourceforge.net/apps/trac/java-jml
score: 0

http://stackoverflow.com/q/2689217
has body: We have a bunch of tests in a maven2 project and build with cruisecontrol. However the build regularly hangs, because the annotation of the test with a timeout @Test(timeout = 5000) is ignored. I tried and run maven locally, reproducing the fact that the timeout is ignored. Is there a way to activate the timeout for the tests again? I currently use a workaround in setting a timeout in cruisecontrol. However this simply means that the whole build is canceled, and not just the tests that should fail. Remark: It seems in maven 1 there was a property to activate the junit timeout which is missing in maven 2.
type: AnsweredQuestion
tagged with: java
type: Question
score: 5
has answer: http://stackoverflow.com/a/2691425
upvote count: 5
has title: Maven2 junit timeout annotation doesn't work
tagged with: junit
answer count: 1
downvote count: 0
tagged with: maven-2
favorite count: 0
accepted answer: http://stackoverflow.com/a/2691425

http://stackoverflow.com/comment/61729369
score: 0
comment on: http://stackoverflow.com/a/2623987
type: Comment
has text: How can I create and name the columns for the created table??
type: AnswerComment

http://stackoverflow.com/a/77147993
answers question: http://stackoverflow.com/q/2615749
has body: I have created a function which is very easy to understand for find word's location in a string, check it :- public static void indexOfWordByYash() { String str = "01yash898989yashyashyashgggggg"; String find = "yash"; int sizeOfFind = find.length(); System.out.println("length of string ="+str.length()); System.out.println("size of find ="+sizeOfFind); //In here we are checking if find_word available from index 0, becouse //in loop we are not checking from 0 index. int index = str.indexOf("yash", 0); for(int loop=0; loop < str.length(); loop++) { //Only if index greater then 0 will print the index. if(index >= 0) { System.out.println("Index of yash ="+index); index = str.indexOf("yash", index+sizeOfFind); } //Break the loop if no any more find_word in string. if(index == -1) { System.out.println("index ="+index); break; } } }
downvote count: 0
type: Answer
upvote count: 1
score: 1

http://stackoverflow.com/a/2645334
has body: I think, EntityManagerFactory can't find data source, specified in your persistence unit. As for Glassfish, this information is stored in sun-resources.xml file. Is it j2ee application? If so, it is better to use dependency injection with @PersistenceContext annotation (as Pascal said). Also, you can try to use method createEntityManagerFactory(String persistenceUnitName, Map properties) and specify "ConnectionDriverName" propety in properties map: private EntityManager em; private EntityManagerFactory emf; public void myFunction() { HashMap&lt;String, String&gt; properties = new HashMap&lt;String, String&gt;(); properties.put("ConnectionDriverName", "org.postgresql.Driver"); //as for Postgres emf = Persistence.createEntityManagerFactory("ScheduleUnit", properties); em = emf.createEntityManager(); }
has comment: http://stackoverflow.com/comment/2660452
score: 0
has comment: http://stackoverflow.com/comment/2671739
accepted answer of: http://stackoverflow.com/q/2639669
has comment: http://stackoverflow.com/comment/2696813
answers question: http://stackoverflow.com/q/2639669
type: AcceptedAnswer
type: Answer

http://stackoverflow.com/a/2701187
has comment: http://stackoverflow.com/comment/2724258
answers question: http://stackoverflow.com/q/2701100
type: Answer
has comment: http://stackoverflow.com/comment/2724030
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/2724166
has comment: http://stackoverflow.com/comment/2725038
has comment: http://stackoverflow.com/comment/2724885
has comment: http://stackoverflow.com/comment/2724222
downvote count: 0
has body: Updated with more explanations Check which java executable is really running, e.g. $ type java If this shows something other than /usr/bin/java, then you've likely got a specific JRE/JDK hardcoded in your path. This is fine, but you won't be able to use change Java versions using RH alternatives for any account that hardcodes a specific JRE/JDK in its PATH in this way. However, other packages/accounts (e.g. system processes) that don't hardcode a specific JDK version into its path will use the alternatives-specified JRE. Check your JAVA_HOME environment variable, e.g. $ echo $JAVA_HOME If this is set, this will sometimes point the java executable at a different JRE/JDK, regardless of where the java executable itself lives. Again, its not unusual to set this, but you won't be able to use change Java versions using RH alternatives for any account that hardcodes a different JAVA_HOME. All that said, for development in my account, I normally set a specific JDK in my path and set JAVA_HOME to point to a specific JDK, rather than rely on the system settings. RH alternatives is fine to control what Java version other packages use, but for my own development, I like to explicitly target the Java I want to use.

http://stackoverflow.com/q/2633524
has title: Does a HashMap retain the order of its elements on the next read if it is constructed and "filled" as a LinkedHashMap?
tagged with: hashmap
downvote count: 0
answer count: 1
tagged with: data-structures
has body: Suppose I have a Java method that returns a HashMap object. Because a LinkedHashMap is a subclass of HashMap, I can return a LinkedHashMap from this method just fine. On the next "read" action (no adding/removing/modifying of K/V pairs), would iterating over the keys of the resulting method (which returns a HashMap) go in the same order as the originating LinkedHashMap, even though the HashMap lacks the key links?
accepted answer: http://stackoverflow.com/a/2633542
favorite count: 0
upvote count: 2
tagged with: linkedhashmap
score: 2
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/2633542
type: Question

http://stackoverflow.com/a/2681927
has comment: http://stackoverflow.com/comment/2701633
score: 12
type: Answer
upvote count: 12
has comment: http://stackoverflow.com/comment/2701571
downvote count: 0
has body: It was once considered (and probably still be by some) that functions should have one entry point (easy but was relevant when you consider assembly language) and one exit point. One exit point is nice from a debugging standpoint (as in you can put one watch/break on one line and know you'll go through it) but can lead to some horrific nesting so more often than not readability tends to win out. Which produces the least nesting, the least lines of code and the most readable end result? Ultimately that tends to be far more important than anything else. For what it's worth the last can be better expressed as: return condition ? foo : bar; assuming condition isn't terribly long. Don't get overly concerned with supposed code "purity". It's an irrelevant distraction. Make things readable and generally be consistent.
answers question: http://stackoverflow.com/q/2681883

http://stackoverflow.com/q/2621701
has answer: http://stackoverflow.com/a/10353716
tagged with: logging
type: Question
has comment: http://stackoverflow.com/comment/2634400
score: 138
has comment: http://stackoverflow.com/comment/131715550
has body: When using log4j, the Logger.log(Priority p, Object message) method is available and can be used to log a message at a log level determined at runtime. We're using this fact and this tip to redirect stderr to a logger at a specific log level. slf4j doesn't have a generic log() method that I can find. Does that mean there's no way to implement the above? Update: As of SLF4J version 2.0, it is possible to use the Logger.atLevel() method. For example: import org.slf4j.event.Level; import org.slf4j.Logger; ... Logger logger = ... // some slf4j logger of choice logger.atLevel(Level.Info).log("hello world");
tagged with: slf4j
upvote count: 138
possible better answer: http://stackoverflow.com/a/7829534
has answer: http://stackoverflow.com/a/35602473
has comment: http://stackoverflow.com/comment/99154062
has answer: http://stackoverflow.com/a/7829534
has answer: http://stackoverflow.com/a/68185612
tagged with: log4j
has answer: http://stackoverflow.com/a/56235230
has comment: http://stackoverflow.com/comment/27542176
favorite count: 0
has comment: http://stackoverflow.com/comment/27421335
has answer: http://stackoverflow.com/a/2622044
accepted answer: http://stackoverflow.com/a/2622044
has answer: http://stackoverflow.com/a/2621718
has answer: http://stackoverflow.com/a/57542934
has answer: http://stackoverflow.com/a/55847315
answer count: 18
has answer: http://stackoverflow.com/a/38655293
has title: Setting log level of message at runtime in slf4j
has answer: http://stackoverflow.com/a/54718800
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/35922732
has answer: http://stackoverflow.com/a/22713932
downvote count: 0
has answer: http://stackoverflow.com/a/6131369
has answer: http://stackoverflow.com/a/24154212
tagged with: java
has answer: http://stackoverflow.com/a/14399850
has answer: http://stackoverflow.com/a/61795855
has answer: http://stackoverflow.com/a/44665169
has comment: http://stackoverflow.com/comment/25708730

http://stackoverflow.com/comment/84768165
score: 0
type: Comment
comment on: http://stackoverflow.com/a/32201073
has text: how i can check this behaivor , because i'm not the person who developp the service...
type: AnswerComment

http://stackoverflow.com/comment/2634614
has text: I can't see why do you need an interface in order to declare String constants in a class. Can you elaborate please?
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2612859

http://stackoverflow.com/q/2671520
has answer: http://stackoverflow.com/a/2671567
has answer: http://stackoverflow.com/a/2671550
has answer: http://stackoverflow.com/a/2671846
tagged with: nio
has title: Java programs using NIO framework
has answer: http://stackoverflow.com/a/2671922
upvote count: 7
downvote count: 1
answer count: 7
has body: I am doing some research related to Java NIO. I need to find some representative applications that are based on this framework. Please feel free to suggest! The more, the merrier! Thanks
has answer: http://stackoverflow.com/a/2673889
favorite count: 0
possible better answer: http://stackoverflow.com/a/2671846
score: 6
has answer: http://stackoverflow.com/a/2671839
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/2671560
accepted answer: http://stackoverflow.com/a/2671560
type: Question

http://stackoverflow.com/a/5059255
answers question: http://stackoverflow.com/q/2697541
score: 0
has body: If you're interested in generating your DTOs, can I suggest jsonschema2pojo? You can define your objects using JSON Schema and have your DTOs automatically generated. Once you've written the schema, you can also give it to your consumers so that they understand exactly how requests should be formatted.
type: Answer

http://stackoverflow.com/a/2782630
answers question: http://stackoverflow.com/q/2782524
type: Answer
accepted answer of: http://stackoverflow.com/q/2782524
score: 3
downvote count: 0
has body: Is this valid ? Yes and no.... Yes, because the compiler will happily compile and execute the code above, but no, because it really doesn't make any sense to type something as def and also assign it as an explicit type. Basically what you're saying is "this can have any type, but it must be a CallableStatement". In my opinion, the definition above should generate a compiler error. In practice this definition: def CallableStatement st Appears to be identical to: CallableStatement st As the following illustrates: class Foo { def List l; } new Foo().l = new ArrayList() // this works new Foo().l = "ddd" // this throws a GroovyCastException
upvote count: 3
type: AcceptedAnswer

http://stackoverflow.com/comment/2806667
comment on: http://stackoverflow.com/a/2773033
has text: "Other singletons" is an oxymoron. If they're all extending the same (singleton) base class, there should only ever be one of them.
score: 3
type: AnswerComment
type: Comment

http://stackoverflow.com/a/2725566
has comment: http://stackoverflow.com/comment/2757120
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2701565
answers question: http://stackoverflow.com/q/2701565
type: Answer
has comment: http://stackoverflow.com/comment/2757150
has body: Explanation: classes in the default package are not visible/importable by classes inside a package. Try the following examples: public class Entity {} (thus without package!) and package persistence; public class EntityManager { public static void main(String... args) { Entity entity = new Entity(); } } Does it work? No? How would you ever import it? That's the problem which happens behind the scenes!
score: 0

http://stackoverflow.com/q/2696285
tagged with: jcomponent
tagged with: swing
tagged with: javax.swing.timer
type: Question
score: 3
tagged with: performance
possible better answer: http://stackoverflow.com/a/2696332
tagged with: java
accepted answer: http://stackoverflow.com/a/2696334
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2696334
answer count: 3
has answer: http://stackoverflow.com/a/2696332
has answer: http://stackoverflow.com/a/2696394
has title: JFrame that has multiple layers
type: AnsweredQuestion
has body: I have a window that has two layers: a static background and a foreground that contains moving objects. My idea is to draw the background just once (because it's not going to change), so I make the changing panel transparent and add it on top of the static background. Here is the code for this: public static void main(String[] args) { JPanel changingPanel = new JPanel() { @Override public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.RED); g.fillRect(100, 100, 100, 100); } }; changingPanel.setOpaque(false); JPanel staticPanel = new JPanel(); staticPanel.setBackground(Color.BLUE); staticPanel.setLayout(new BorderLayout()); staticPanel.add(changingPanel); JFrame frame = new JFrame(); frame.add(staticPanel); frame.setSize(800, 600); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } This piece of code gives me the correct image I want, but every time I repaint changingPanel, staticPanel gets repainted as well (which is obviously against the whole idea of painting the static panel just once). Can somebody show me what's wrong? FYI I am using the javax.swing.Timer to recalculate and repaint the changing panel 24 times every second.
upvote count: 3

http://stackoverflow.com/a/2707330
upvote count: 10
score: 10
has body: No it's not the instance of anything, instanceof will always be false.
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2707322

http://stackoverflow.com/q/2610033
tagged with: file-io
has title: What is the maximum file size 32 bit java can access?
downvote count: 0
accepted answer: http://stackoverflow.com/a/2610041
possible better answer: http://stackoverflow.com/a/2611520
favorite count: 0
has answer: http://stackoverflow.com/a/2611520
upvote count: 2
type: AnsweredQuestion
score: 2
has body: What is the maximum file size 32 bit java can access? Is this architecture dependent?
tagged with: java
tagged with: file
has answer: http://stackoverflow.com/a/2610041
type: Question
answer count: 2

http://stackoverflow.com/a/2761340
score: 0
answers question: http://stackoverflow.com/q/2761068
type: Answer
has body: PrintStream realOut = System.out; try { out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); System.out.println("bla"); } finally { System.setOut(realOut); } System.out.println(out);

http://stackoverflow.com/a/41993437
has comment: http://stackoverflow.com/comment/73103049
type: Answer
downvote count: 3
has comment: http://stackoverflow.com/comment/73104406
upvote count: 17
has body: To do this on regexp level you have to use \U to switch on uppercase mode and \E to switch it off. Here is an example how to use this feature in IntelliJ IDEA find-and-replace dialog which transforms set of class fields to JUnit assertions (at IDE tooltip is a result of find-and-replace transformation):
has comment: http://stackoverflow.com/comment/73102991
score: 14
answers question: http://stackoverflow.com/q/2770967

mysql
tags question: http://stackoverflow.com/q/2608068
tags question: http://stackoverflow.com/q/2608376
tags question: http://stackoverflow.com/q/2627777
tags question: http://stackoverflow.com/q/2636144
tags question: http://stackoverflow.com/q/2753387
tags question: http://stackoverflow.com/q/2694151
tags question: http://stackoverflow.com/q/2600077
tag name: mysql
tags question: http://stackoverflow.com/q/2641561
tags question: http://stackoverflow.com/q/2619644
tags question: http://stackoverflow.com/q/2731443
tags question: http://stackoverflow.com/q/2621135
tags question: http://stackoverflow.com/q/2747203
tags question: http://stackoverflow.com/q/2733392
tags question: http://stackoverflow.com/q/2720716
tags question: http://stackoverflow.com/q/2736830
tags question: http://stackoverflow.com/q/2773826
tags question: http://stackoverflow.com/q/2738880
tags question: http://stackoverflow.com/q/2621785
tags question: http://stackoverflow.com/q/2658414
type: Tag
tags question: http://stackoverflow.com/q/2754452
tags question: http://stackoverflow.com/q/2604588
tags question: http://stackoverflow.com/q/2616168
tags question: http://stackoverflow.com/q/2762329
tags question: http://stackoverflow.com/q/2743383
tags question: http://stackoverflow.com/q/2605594
tags question: http://stackoverflow.com/q/2762416
tags question: http://stackoverflow.com/q/2719153
tags question: http://stackoverflow.com/q/2605477
tags question: http://stackoverflow.com/q/2628356
tags question: http://stackoverflow.com/q/2607472
tags question: http://stackoverflow.com/q/2732715

http://stackoverflow.com/a/2767920
has body: Here is a tiny C program for you that will consume the number of bytes specified on the command line: #include &lt;stdlib.h&gt; int main(int argc, char *argv[]) { int bytes = atoi(argv[1]); char *buf = malloc(bytes); while (1) { int i; for (i = 0; i &lt; bytes; i++) buf[i] += 1; } }
type: Answer
answers question: http://stackoverflow.com/q/2766538
downvote count: 1
score: -1
upvote count: 0

http://stackoverflow.com/a/2689206
type: Answer
answers question: http://stackoverflow.com/q/2689125
accepted answer of: http://stackoverflow.com/q/2689125
score: 0
has body: Is your Eclipse perhaps configured to use Java 1.4 libraries for that project? Those packages weren't added to Java SE until 1.5. Look at Window->Preferences->Java->Installed JREs to see which versions your Eclipse installation has available (and to add new ones). You can set a default, and also choose for each project which version to use (in the project properties->Build Path->Libraries)
type: AcceptedAnswer

http://stackoverflow.com/a/2737428
answers question: http://stackoverflow.com/q/2737401
has body: First things first - are you calling printResults on the Event Dispatch Thread using SwingUtilities.invokeLater(Runnable runnable); or SwingUtilities.invokeAndWait(Runnable runnable);? Remember that you need to do all GUI work on the EDT. If so, try this: JFrame window = new JFrame(); // CHANGES HERE window.getContentPane().setLayout(new BorderLayout(); window.getContentPane().add(name, BorderLayout.NORTH); window.getContentPane().add(outarea, BorderLayout.CENTER); // END CHANGES
score: 1
upvote count: 1
type: Answer
downvote count: 0

http://stackoverflow.com/a/2668702
has comment: http://stackoverflow.com/comment/2696520
score: 7
upvote count: 7
has comment: http://stackoverflow.com/comment/2687920
has comment: http://stackoverflow.com/comment/2686952
has comment: http://stackoverflow.com/comment/2688932
answers question: http://stackoverflow.com/q/2668639
has body: Note that initCause() is synchronized and setStackTrace() copies its parameter and then does a single assignment. So Exception actually does seem to be implemented with thread-safety in mind. Still, I'd be wary of any design where exceptions are routinely passed around between threads (i.e. for any reason other than handling a very serious error condition). It just feels wrong.
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2687072
has comment: http://stackoverflow.com/comment/2688588
type: Answer
has comment: http://stackoverflow.com/comment/2689044
has comment: http://stackoverflow.com/comment/2689237
accepted answer of: http://stackoverflow.com/q/2668639

http://stackoverflow.com/comment/2703338
has text: @Ali G: 4 distinct times: At position 0, 1, 2, and 3 as you can easily verify by calling `.substring(0,0)` up to `.substring(3,3)` on `"FOO"`.
comment on: http://stackoverflow.com/a/2683476
type: AnswerComment
type: Comment
score: 3

http://stackoverflow.com/comment/40222109
type: AnswerComment
has text: Otto has pro of being able to run it externally in just a a plain old Java app. So, good for dev and testing without having to mess with Android. Otto has con of big learning curve and most of what it solves is already solved in Android ways (local broadcast etc) or in normal app dev approaches ( you can write a much simpler global lookup than the global lookup of Otto, normal approaches are much more approachable for vectoring/F3 through code and for stepping through debugging).
type: Comment
comment on: http://stackoverflow.com/a/25693086
score: 0

http://stackoverflow.com/comment/62321270
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2766814
has text: Your code can lead to `NullPointerException`. The `public final void setTime(Date date)` method of the `Calendar` class of the Java framework does not check for null parameters and does this : `setTimeInMillis(date.getTime());` (checked in Java 1.8). Before calling `setTime`, you should check for null `date` param and reset `calendar` member.
type: Comment

http://stackoverflow.com/comment/2793206
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2761181
has text: Unfortunately, I don't have that option. I'm using a Java subset for a robotics platform (LeJOS NXJ).

http://stackoverflow.com/q/2767274
tagged with: java
type: Question
upvote count: 2
has comment: http://stackoverflow.com/comment/2799932
has answer: http://stackoverflow.com/a/2767299
has answer: http://stackoverflow.com/a/2767292
has comment: http://stackoverflow.com/comment/2799938
has answer: http://stackoverflow.com/a/2767330
has title: Java: How do I implement a method that takes 2 arrays and returns 2 arrays?
answer count: 10
linked to: http://stackoverflow.com/q/333151
has answer: http://stackoverflow.com/a/2767326
has body: Okay, here is what I want to do: I want to implement a crossover method for arrays. It is supposed to take 2 arrays of same size and return two new arrays that are a kind of mix of the two input arrays. as in [a,a,a,a] [b,b,b,b] ------> [a,a,b,b] [b,b,a,a]. Now I wonder what would be the suggested way to do that in Java, since I cannot return more than one value. My ideas are: - returning a Collection(or array) containing both new arrays. I dont really like that one because it think would result in a harder to understand code. - avoiding the need to return two results by calling the method for each case but only getting one of the results each time. I dont like that one either, because there would be no natural order about which solution should be returned. This would need to be specified, though resulting in harder to understand code. Plus, this will work only for this basic case, but I will want to shuffle the array before the crossover and reverse that afterwards. I cannot do the shuffling isolated from the crossover since I wont want to actually do the operation, instead I want to use the information about the permutation while doing the crossover, which will be a more efficient way I think. My question is not about the algorithm itself, but about the way to put in in a method(concerning input and output) in Java
favorite count: 0
downvote count: 0
has answer: http://stackoverflow.com/a/2767351
has answer: http://stackoverflow.com/a/2767590
has answer: http://stackoverflow.com/a/2767357
has answer: http://stackoverflow.com/a/2767321
accepted answer: http://stackoverflow.com/a/2767321
type: AnsweredQuestion
score: 2
has comment: http://stackoverflow.com/comment/2799996
possible better answer: http://stackoverflow.com/a/2767299
has answer: http://stackoverflow.com/a/2767293
has answer: http://stackoverflow.com/a/2767398

http://stackoverflow.com/a/2706493
accepted answer of: http://stackoverflow.com/q/2706421
answers question: http://stackoverflow.com/q/2706421
type: Answer
has body: Lazy loading is only beneficial if you aren't going to use the data in question at all (e.g. showing only a list of customers, hereby ignoring the nested set of orders), or if it's not to be decided yet whether the user would like to view the data in question (e.g. having a list of customers in memory and the request for list of orders depends on future actions). If you'll for sure show all the data at once, then lazy loading is not needed, it would only cost an extra query.
score: 5
has comment: http://stackoverflow.com/comment/2732003
has comment: http://stackoverflow.com/comment/2732362
type: AcceptedAnswer
upvote count: 5
downvote count: 0

http://stackoverflow.com/a/2663437
has comment: http://stackoverflow.com/comment/2681191
downvote count: 0
has comment: http://stackoverflow.com/comment/2707255
has comment: http://stackoverflow.com/comment/2681440
has body: In case of a controller (servlet) which takes care about the model, the jsp:useBean is only useful if the default instance (constructed with the no-arg constructor) exposes different behavior/state than a non-existing instance. E.g. if you would like to have a default user name "Unknown User", you would do: public User { this.id = "Unknown User"; } Else the enduser may face a "Welcome" instead of "Welcome Unknown User" display. In your particular case, you can safely remove it. It's superfluous. However, I've also seen the argument that it's useful for pure documentation. You could declare "useless" jsp:useBean instances in top of JSP page so that you have an overview which models exactly are been used in the particular JSP page. Although I find it pretty smart, I myself have never had the need for this way of documenting the model in JSP. As per the comments, another argument is indeed that this way IDE's like IDEA and Eclipse are able to autocomplete bean properties in EL. Update: as to the locating, it uses PageContext#findAttribute() for that and then uses reflection/javabean introspection to invoke getter methods on it. E.g. ${user.name} roughly resolves to out.print(pageContext.findAttribute("user").getName()) Also see the JSP specification and the JSP EL specification. Update 2: the &lt;jsp:useBean&gt; certainly doesn't use an internal name or so as session attribute prefix. Loop over all session attributes yourself to see the actual keys and values: &lt;c:forEach items="${sessionScope}" var="entry"&gt; ${entry.key} = ${entry.value}&lt;br&gt; &lt;/c:forEach&gt; or in a servlet for (String name : Collections.list(session.getAttributeNames())) { System.out.println(name + " = " + session.getAttribute(name)); }
type: AcceptedAnswer
upvote count: 6
has comment: http://stackoverflow.com/comment/2681282
has comment: http://stackoverflow.com/comment/2681307
has comment: http://stackoverflow.com/comment/2681202
type: Answer
has comment: http://stackoverflow.com/comment/2681184
has comment: http://stackoverflow.com/comment/2681724
has comment: http://stackoverflow.com/comment/2681816
score: 6
has comment: http://stackoverflow.com/comment/2706368
has comment: http://stackoverflow.com/comment/2712163
accepted answer of: http://stackoverflow.com/q/2663079
answers question: http://stackoverflow.com/q/2663079

http://stackoverflow.com/q/2623542
score: 4
answer count: 3
downvote count: 0
tagged with: jms
has answer: http://stackoverflow.com/a/2623814
favorite count: 0
has answer: http://stackoverflow.com/a/49066253
type: UnansweredQuestion
tagged with: spring
has answer: http://stackoverflow.com/a/2657307
has body: We've a Spring JMS message listener container for receiving messages asynchronously. Using DefaultMessageListenerContainer and in sessionTransacted mode. I understand being in sessionTransacted mode means in case of an exception the message will be put back into the queue. But how can I make sure the message won't be deleted from the queue even if the receiver (which is picked the message) crashes or just the machine running it looses power? At first I thought CLIENT_ACKNOWLEDGE acknowledge mode should save me, but apparently it's not the case, Spring calls .acknowledge() no matter what. So here's my question, how can I guarantee the delivery? Using a custom MessageListenerContainer? Using a transaction manager?
tagged with: java
has title: Keeping messages in queue in case of receiver crash
type: Question
upvote count: 4

http://stackoverflow.com/comment/3801912
comment on: http://stackoverflow.com/a/3538022
type: Comment
score: 1
has text: Isn't it relatively prime to the current size of the hashtable? I think that hashtable sizes are in general chosen to make this more likely. Your comment might lead someone to believe that they should find a prime to write their hashcode, which would be pretty inefficient. I think that as long as you generate fairly well distributed numbers you don't need to worry about it too much.
type: AnswerComment

http://stackoverflow.com/a/2694103
has body: TreeSet is a sorted set. Set means no duplicates though. add() adds an item, which is inserted in the correct sorted place. pollLast() removes and returns the last item, pollFirst() removes and returns the first item.
has comment: http://stackoverflow.com/comment/2715974
downvote count: 0
type: Answer
score: 4
upvote count: 4
answers question: http://stackoverflow.com/q/2693860

http://stackoverflow.com/a/2608919
has body: Yes, you can easily do it using Integer.parseInt(String s, int radix). In your case the radix is 2 so you just have to split your whole binary string in substrings of 8 chars each and use Integer.parseInt(substring, 2). Then you convert them to characters and you concatenate them..
type: Answer
has comment: http://stackoverflow.com/comment/2619301
upvote count: 1
accepted answer of: http://stackoverflow.com/q/2608888
answers question: http://stackoverflow.com/q/2608888
type: AcceptedAnswer
downvote count: 0
score: 1

http://stackoverflow.com/a/2721289
accepted answer of: http://stackoverflow.com/q/2710555
downvote count: 0
has comment: http://stackoverflow.com/comment/25916258
has comment: http://stackoverflow.com/comment/96408474
type: Answer
score: 21
upvote count: 21
has body: You should use SimpleTrigger that fires at specific time and without repeating. TriggerUtils has many handy methods for creating these kind of things.
has comment: http://stackoverflow.com/comment/96529243
answers question: http://stackoverflow.com/q/2710555
has comment: http://stackoverflow.com/comment/6404582
type: AcceptedAnswer

http://stackoverflow.com/q/2691177
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/2042813
has title: Getting .jar file onto a mobile phone error
has answer: http://stackoverflow.com/a/11608217
score: 1
tagged with: midp
tagged with: java
upvote count: 1
type: Question
has body: I am trying to get a .jar file onto my mobile device. I have written a j2me application and I want to get it onto my phone. I have developed it in eclipse galileo and I export my project folder to a jar. When I try to download the jar file from the internet onto my phone I get an "incorrect description" error. Does anyone know how to get a j2me application onto a mobile device or why I may be getting this error? Thanks in advance.
has comment: http://stackoverflow.com/comment/2712417
answer count: 2
downvote count: 0
tagged with: executable-jar
tagged with: jar
tagged with: java-me
favorite count: 0
has answer: http://stackoverflow.com/a/2691451

http://stackoverflow.com/q/2716063
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2741648
has title: Parse Exception: At line 1, column 0: no element found
possible better answer: http://stackoverflow.com/a/2723609
type: Question
has body: I have a weird issue. I receive the following error that causes a force-close: org.apache.harmony.xml.ExpatParser$ParseException: At line 1, column 0: no element found at org.apache.harmony.xml.ExpatParser.parseFragment(ExpatParser.java:508) at org.apache.harmony.xml.ExpatParser.parseDocument(ExpatParser.java:467) at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:329) at org.apache.harmony.xml.ExpatReader.parse(ExpatReader.java:286) After clicking the Force Close button, the Activity is recreated and the parsing completes without a hitch. I'm using the following code snippet inside doInBackground of an AsyncTask: URL serverAddress = new URL(url[0]); HttpURLConnection connection = (HttpURLConnection) serverAddress.openConnection(); connection.setRequestMethod("GET"); connection.setDoOutput(true); connection.setReadTimeout(10000); connection.connect(); InputStream stream = connection.getInputStream(); SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); xr.parse(new InputSource(stream)); // The line that throws the exception Why would the Activity force-close and then run without any problems immediately after? Would a BufferedInputStream be any different? I'm baffled. :( Thanks for your time everyone. Update: It turns out HttpURLConnection.getResponseCode() returns -1 every so often, so the InputStream probably isn't being correctly set.
has answer: http://stackoverflow.com/a/2716493
upvote count: 5
tagged with: java
has answer: http://stackoverflow.com/a/41032770
answer count: 6
has answer: http://stackoverflow.com/a/3737847
score: 5
has comment: http://stackoverflow.com/comment/2741770
has answer: http://stackoverflow.com/a/2716150
accepted answer: http://stackoverflow.com/a/2716150
downvote count: 0
has answer: http://stackoverflow.com/a/2723609
favorite count: 0
tagged with: android
has comment: http://stackoverflow.com/comment/2741644
has answer: http://stackoverflow.com/a/2716113
tagged with: httpurlconnection
tagged with: parsing
tagged with: http://stackoverflow.com/tag/xml

http://stackoverflow.com/q/2735183
has body: Cany one please give me what are the different ways of creating the jar files. Through programmatically we can create using java.util.jar Other than these method, please share your knowledge
has answer: http://stackoverflow.com/a/2735208
answer count: 4
downvote count: 0
has answer: http://stackoverflow.com/a/2735213
type: Question
tagged with: jakarta-ee
type: AnsweredQuestion
score: 1
tagged with: java
upvote count: 1
has answer: http://stackoverflow.com/a/2735229
accepted answer: http://stackoverflow.com/a/2735229
has title: Different ways of Creating jar files?
tagged with: executable-jar
tagged with: jar
possible better answer: http://stackoverflow.com/a/2735213
favorite count: 0
has answer: http://stackoverflow.com/a/2735210

http://stackoverflow.com/q/2756243
has comment: http://stackoverflow.com/comment/2787725
tagged with: network-programming
score: 1
tagged with: java
has title: Network programming and Packets interactions
has answer: http://stackoverflow.com/a/2756277
accepted answer: http://stackoverflow.com/a/2756277
upvote count: 1
possible better answer: http://stackoverflow.com/a/2756279
favorite count: 0
has answer: http://stackoverflow.com/a/2756898
answer count: 5
has body: Greeting, This month I will start working on my master thesis. My thesis's subject is about network security. I need to deal with network interfaces and packets. I've used shappcap before to interact with packets but I'm not sure if C# is the most powerful language to deal with network programing and packets. I worked a bit with wireshark and I saw how powerful it is and as you know winsharp is open source developed using C++. I'm not sure if I should use C# or C++ for network security programming and I want your through about the best language might be for network programming and packets interaction. should I use C#, C++, or java or some thing else? please give me your advice. Thank you, UPDATE .......................... I'm going to do different packet mining by taking each packet and read each field on it then use these values and in same stages I would modify some of the packets value then resend them back. I want to control the packet since it received by the network interface until it passes to the application layer. also
has answer: http://stackoverflow.com/a/2768759
tagged with: c++
has comment: http://stackoverflow.com/comment/2787798
downvote count: 0
tagged with: packet
has answer: http://stackoverflow.com/a/2756677
has answer: http://stackoverflow.com/a/2756279
type: Question
tagged with: c#
type: AnsweredQuestion

http://stackoverflow.com/a/2602156
type: AcceptedAnswer
type: Answer
downvote count: 0
score: 7
accepted answer of: http://stackoverflow.com/q/2602133
answers question: http://stackoverflow.com/q/2602133
has body: My hunch is that it is blowing up as $ is a special character. From the documentation Note that backslashes () and dollar signs ($) in the replacement string may cause the results to be different than if it were being treated as a literal replacement string. Dollar signs may be treated as references to captured subsequences as described above, and backslashes are used to escape literal characters in the replacement string. So I believe you would need something like "\\${pageContext.request.contextPath}/"
upvote count: 7

http://stackoverflow.com/comment/2699545
type: Comment
comment on: http://stackoverflow.com/a/2670853
has text: So the regex, in this case, is faster than the simple alternative of using `split()`
type: AnswerComment
score: 0

http://stackoverflow.com/comment/5357991
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2752608
has text: Is the maxPostSize value SPECIFICALLY applied to POST requests only? Does it also apply to PUT requests? I need to limit the amount of data submitted to the server, but users may issue POSTs or PUTs. Does this limit apply to any request body, or does it stick strictly to POST requests?
score: 1

http://stackoverflow.com/q/2614774
tagged with: java
has answer: http://stackoverflow.com/a/3696919
type: Question
has title: What can cause Java to keep running after System.exit()?
has answer: http://stackoverflow.com/a/2616023
downvote count: 0
has answer: http://stackoverflow.com/a/37963331
accepted answer: http://stackoverflow.com/a/3696919
favorite count: 0
has answer: http://stackoverflow.com/a/14569694
has answer: http://stackoverflow.com/a/2615090
has answer: http://stackoverflow.com/a/2615108
answer count: 9
tagged with: processbuilder
has answer: http://stackoverflow.com/a/2614800
has answer: http://stackoverflow.com/a/57519080
possible better answer: http://stackoverflow.com/a/43890391
score: 31
type: AnsweredQuestion
has body: I have a Java program which is being started via ProcessBuilder from another Java program. System.exit(0) is called from the child program, but for some of our users (on Windows) the java.exe process associated with the child doesn't terminate. The child program has no shutdown hooks, nor does it have a SecurityManager which might stop System.exit() from terminating the VM. I can't reproduce the problem myself on Linux or Windows Vista. So far, the only reports of the problem come from two Windows XP users and one Vista user, using two different JREs (1.6.0_15 and 1.6.0_18), but they're able to reproduce the problem every time. Can anyone suggest reasons why the JVM would fail to terminate after System.exit(), and then only on some machines? Edit 1: I got the user to install the JDK so we could get a thread dump from the offending VM. What the user told me is that the VM process disappears from VisualVM as soon as he clicks on the 'Quit' item in my menu---but, according to Windows Task Manager, the process hasn't terminated, and no matter how long the user waits (minutes, hours), it never terminates. Edit 2: I have confirmed now that Process.waitFor() in the parent program never returns for at least one of the users having the problem. So, to summarize: The child VM seems to be dead (VisualVM doesn't even see it) but the parent still sees the process as live and so does Windows.
tagged with: exit
has answer: http://stackoverflow.com/a/43890391
upvote count: 31

http://stackoverflow.com/q/2610351
downvote count: 0
has body: I'm planning to make a webapp and just wonder if someone ever tried to use remote EJBs with a RAD framework like Grails, Play... was it easy?
tagged with: jakarta-ee
has comment: http://stackoverflow.com/comment/2620863
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2629969
score: 1
tagged with: java
has title: Can i easily use EJB3 Remote with a RAD framework?
tagged with: grails
type: Question
answer count: 1
accepted answer: http://stackoverflow.com/a/2618048
tagged with: groovy
upvote count: 1
has answer: http://stackoverflow.com/a/2618048
favorite count: 0
tagged with: ejb-3.0

http://stackoverflow.com/a/2679617
upvote count: 35
has comment: http://stackoverflow.com/comment/13143202
has comment: http://stackoverflow.com/comment/2699246
has comment: http://stackoverflow.com/comment/81588279
has body: You can recover from it: package com.stackoverflow.q2679330; public class Test { public static void main(String... args) { int size = Integer.MAX_VALUE; int factor = 10; while (true) { try { System.out.println("Trying to allocate " + size + " bytes"); byte[] bytes = new byte[size]; System.out.println("Succeed!"); break; } catch (OutOfMemoryError e) { System.out.println("OOME .. Trying again with 10x less"); size /= factor; } } } } But does it make sense? What else would you like to do? Why would you initially allocate that much of memory? Is less memory also OK? Why don't you already make use of it anyway? Or if that's not possible, why not just giving the JVM more memory from the beginning on? Back to your questions: 1: is there any real word scenarios when catching java.lang.OutOfMemoryError may be a good idea? None comes to mind. 2: if we catching java.lang.OutOfMemoryError how can we sure that catch handler doesn't allocate any memory by itself (any tools or best practicies)? Depends on what has caused the OOME. If it's declared outside the try block and it happened step-by-step, then your chances are little. You may want to reserve some memory space beforehand: private static byte[] reserve = new byte[1024 * 1024]; // Reserves 1MB. and then set it to zero during OOME: } catch (OutOfMemoryException e) { reserve = new byte[0]; // Ha! 1MB free! } Of course this makes all with all no sense ;) Just give JVM sufficient memory as your applictation require. Run a profiler if necessary.
has comment: http://stackoverflow.com/comment/76218717
has comment: http://stackoverflow.com/comment/2699226
has comment: http://stackoverflow.com/comment/8879116
answers question: http://stackoverflow.com/q/2679330
has comment: http://stackoverflow.com/comment/85948137
has comment: http://stackoverflow.com/comment/51318152
has comment: http://stackoverflow.com/comment/10326085
type: Answer
has comment: http://stackoverflow.com/comment/2699259
downvote count: 4
score: 31
has comment: http://stackoverflow.com/comment/38538625

http://stackoverflow.com/a/2700410
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/2700363
type: Answer
has body: It saves me a lot of duplicated code when the hardware changes. void measureCPD (void) { char setting; switch (DrawerType) { case 1: setting = SV1 | SV7; break; case 0: case 2: setting = SV1; break; case 5: PORTA |= SVx; case 3: case 4: setting = SV1 | SV7; break; default: // Illegal drawer type setting = SV1; } SetValves (setting); }
upvote count: 1

http://stackoverflow.com/a/2719282
has comment: http://stackoverflow.com/comment/2759246
has comment: http://stackoverflow.com/comment/2753997
accepted answer of: http://stackoverflow.com/q/2719253
has body: Theoretically; yes. There is no way of giving 100 % theoretical guarantee that what is sent on the hardware layer, is received the same way on the receiving end. Practically however, if you use TCP (Transmission Control Protocol) this stuff has already been taken care of; you won't loose any packets. (If you're using UDP on the other hand (User Datagram Protocol) it's another story, and it may very well be the case that you're loosing packets, or receiving them out of order). Just looked briefly at your code, and it seems you're using multiple threads. If so you must be utterly careful with synchronization. It could very well be the case that it looks like a packet has been dropped, although, it is simply not handled due to a race condition in the program. (Keep in mind that the gui for instance, runs in its own thread.) The best way to solve the synchronization, I think, is to put the network loop in a very small read/put-on-synchronized-queue loop, and pick up the received packets from the queue whenever you're sure no other thread will intervene.
has comment: http://stackoverflow.com/comment/2754379
has comment: http://stackoverflow.com/comment/2759847
has comment: http://stackoverflow.com/comment/2746418
score: 4
upvote count: 4
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2719253
has comment: http://stackoverflow.com/comment/2746467
type: Answer
has comment: http://stackoverflow.com/comment/2759514

http://stackoverflow.com/comment/74863570
comment on: http://stackoverflow.com/q/2703161
has text: If you don't want it secure why are you using SSL at all?
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/a/2651385
downvote count: 0
answers question: http://stackoverflow.com/q/2651210
upvote count: 11
type: Answer
has body: In general, calling System.exit(...) anywhere but the "main" method of an application can be problematic for (at least) the following reasons. It is an impediment to reusing your code. It makes unit testing hard. For example, if your code calls System.exit when your JUnit tests exercise some error handling, that it the end of your test sequence! The specific case of calling System.exit(...) in the button listener for the "exit" button is not so bad. You are unlikely to want reuse the button listener somewhere that doesn't also require this behaviour. Also, you can probably figure out a work-around for the unit testing conundrum; e.g. don't unit test that particular method! However, I think I'd still try to get the exit happen a different way. For example, have the main method launch everything and then block on a CountDownLatch, then have the button listener decrement the latch. When the main method unblocks, it executes the relevant shutdown code and returns or exits as appropriate.
score: 11

http://stackoverflow.com/q/2778045
has body: My task is necessary and shouldn't be canceled, how do I ask ProgressMonitor not to display the "Cancel" button, so when it finishes, it will auto close the panel. Frank
has answer: http://stackoverflow.com/a/2778073
has comment: http://stackoverflow.com/comment/2814398
upvote count: 3
accepted answer: http://stackoverflow.com/a/2778311
tagged with: swing
type: AnsweredQuestion
score: 3
tagged with: java
type: Question
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/2778311
has title: How to omit the "Cancel" button in Java ProgressMonitor?
favorite count: 0
possible better answer: http://stackoverflow.com/a/2778073

http://stackoverflow.com/comment/8398533
type: QuestionComment
comment on: http://stackoverflow.com/q/2599919
has text: check my answer at http://stackoverflow.com/questions/3665554/about-saxparseexception-content-is-not-allowed-in-prolog/7023984 or just check this link http://mark.koli.ch/2009/02/resolving-orgxmlsaxsaxparseexception-content-is-not-allowed-in-prolog.html
score: 0
type: Comment

http://stackoverflow.com/a/69448560
upvote count: 3
has body: Lazy loading works for me if I use Blob type instead of byte[]. @Column(name = "BlobField", nullable = false) @Lob @Basic(fetch = FetchType.LAZY) private Blob blobField; This one gets lazily loaded and if you need to retrieve its value access this field: String value = IOUtils.toByteArray(entity.getBlobField().getBinaryStream());
score: 3
has comment: http://stackoverflow.com/comment/125069595
downvote count: 0
answers question: http://stackoverflow.com/q/2605477
type: Answer

http://stackoverflow.com/comment/2771237
score: 0
type: AnswerComment
type: Comment
has text: actually query.setParameter(value with space); is not working do I need to do some special thing with query.setparameter()
comment on: http://stackoverflow.com/a/2742045

http://stackoverflow.com/a/2752203
answers question: http://stackoverflow.com/q/2752192
type: Answer
score: 2
has body: Java does not have pointers (only references), nor does it have functions (only methods), so it's doubly impossible for it to have pointers to functions. What you can do is define an interface with a single method in it, have your classes that offer such a method declare they implement said interface, and make a vector with references to such an interface, to be populated with references to the specific objects on which you want to call that method. The only constraint, of course, is that all the methods must have the same signature (number and type of arguments and returned values). Otherwise, you can use reflection/introspection (e.g. the Method class), but that's not normally the simplest, most natural approach.
upvote count: 2
downvote count: 0

http://stackoverflow.com/comment/2815618
type: Comment
score: 0
has text: Yes, this is completely independent from the programming language in use. Just don't even try (there are ways --> root kits) but it is a bad way for so many reasons
comment on: http://stackoverflow.com/a/2780468
type: AnswerComment

http://stackoverflow.com/q/2659000
tagged with: java
has answer: http://stackoverflow.com/a/2659083
type: Question
has answer: http://stackoverflow.com/a/43890968
upvote count: 69
has answer: http://stackoverflow.com/a/2659020
tagged with: http-headers
answer count: 6
score: 69
has answer: http://stackoverflow.com/a/2659022
linked to: http://stackoverflow.com/q/1884230
downvote count: 0
has answer: http://stackoverflow.com/a/32524119
tagged with: url
possible better answer: http://stackoverflow.com/a/5270162
favorite count: 0
has answer: http://stackoverflow.com/a/5270162
accepted answer: http://stackoverflow.com/a/2659022
has title: Java - How to find the redirected url of a url?
type: AnsweredQuestion
has body: I am accessing web pages through java as follows: URLConnection con = url.openConnection(); But in some cases, a url redirects to another url. So I want to know the url to which the previous url redirected. Below are the header fields that I got as a response: null--&gt;[HTTP/1.1 200 OK] Cache-control--&gt;[public,max-age=3600] last-modified--&gt;[Sat, 17 Apr 2010 13:45:35 GMT] Transfer-Encoding--&gt;[chunked] Date--&gt;[Sat, 17 Apr 2010 13:45:35 GMT] Vary--&gt;[Accept-Encoding] Expires--&gt;[Sat, 17 Apr 2010 14:45:35 GMT] Set-Cookie--&gt;[cl_def_hp=copenhagen; domain=.craigslist.org; path=/; expires=Sun, 17 Apr 2011 13:45:35 GMT, cl_def_lang=en; domain=.craigslist.org; path=/; expires=Sun, 17 Apr 2011 13:45:35 GMT] Connection--&gt;[close] Content-Type--&gt;[text/html; charset=iso-8859-1;] Server--&gt;[Apache] So at present, I am constructing the redirected url from the value of the Set-Cookie header field. In the above case, the redirected url is copenhagen.craigslist.org Is there any standard way through which I can determine which url the particular url is going to redirect. I know that when a url redirects to other url, the server sends an intermediate response containing a Location header field that tells the redirected url but I am not receiving that intermediate response through the url.openConnection(); method.

http://stackoverflow.com/comment/2671381
has text: If the "src/myapp/resources" folder actually exists in your deployed applet jar (why not just "resources"?) you can just prepend a leading "/" onto the directory - that will make it start at the base of the file system inside the JAR. `kit.getImage("/src/myapp/resources/logo.png");` should work.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2654827

http://stackoverflow.com/comment/2663300
comment on: http://stackoverflow.com/a/2647709
type: Comment
has text: In my example, just call `x = x.successor();` Yours would probably look more like `rate = rate.nextRating();` (depending, of course, on how you name the function). If you want to change the value of the enum itself - not a variable which holds the enum - no, that's not possible.
type: AnswerComment
score: 2

http://stackoverflow.com/comment/6816548
score: 0
has text: I got the pretty much the same problem here Tom, did you ever find a nice solution tho this?
type: QuestionComment
comment on: http://stackoverflow.com/q/2777535
type: Comment

http://stackoverflow.com/q/2668725
type: Question
has title: Use of mouselisteners in a jTable
answer count: 2
upvote count: 1
possible better answer: http://stackoverflow.com/a/2668847
favorite count: 0
has answer: http://stackoverflow.com/a/2668847
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/2668866
accepted answer: http://stackoverflow.com/a/2668866
has body: I have a jTable with columns 'Job_no' and 'Status'with values such as: Job_no Status 1 Active 2 Pending 3 Pending I would like it so that if a user clicks on a Status say in this case the first 'Pending'(where Job_no = 2) an inputDialog pops up allowing the user to change the status of the cell clicked-how can I do this? Bear in mind you will also have to retrieve the Job_no(that corresponds to that status) somehow, and that, though I'm OK with JOptionPane's, I'm new to JTables. I'm using JDBC(mySQL) and have a table 'Jobs' which amongst other things, has column Job_no and status. Thanks for your help.

http://stackoverflow.com/a/52169935
has body: From here : SOAP over JMS offers an alternative messaging mechanism to SOAP over HTTP. While it is not yet standardized and hence may not be interoperable across platforms, SOAP over JMS offers more reliable and scalable messaging support than SOAP over HTTP. As JAX-RPC and JSR-109 become integral parts of the J2EE standard, enterprise messaging in Web services using SOAP over JMS will become well-established.
answers question: http://stackoverflow.com/q/2629366
score: 0
type: Answer

http://stackoverflow.com/a/2616850
upvote count: 6
score: 6
has body: The Maven Enforcer Plugin which allows to control that all plugins have a specified version or certain environmental constraints such as Maven version, JDK version and OS family along with many more standard rules and user created rules.
answers question: http://stackoverflow.com/q/2616397
downvote count: 0
type: Answer

http://stackoverflow.com/comment/2797347
type: Comment
has text: No, you are mixing things here (precisely composition and inheritance). Inheritance and decorator (implemented by composition) and two alternative ways you can "touch" a class (i.e. adding behaviour-state to it). If you read about it, you'll find that inheritance is frequently overrated by those new to OOP.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/2761289

http://stackoverflow.com/q/2656590
type: Question
tagged with: network-programming
has answer: http://stackoverflow.com/a/2656603
has body: I made a little chat applet using multicast. It works fine between computers on the same network, but fails if the computers are on different networks. Why is this? import java.io.*; import java.net.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class ClientA extends JApplet implements ActionListener, Runnable { JTextField tf; JTextArea ta; MulticastSocket socket; InetAddress group; String name=""; public void start() { try { socket = new MulticastSocket(7777); group = InetAddress.getByName("233.0.0.1"); socket.joinGroup(group); socket.setTimeToLive(255); Thread th = new Thread(this); th.start(); name =JOptionPane.showInputDialog(null,"Please enter your name.","What is your name?",JOptionPane.PLAIN_MESSAGE); tf.grabFocus(); }catch(Exception e) {e.printStackTrace();} } public void init() { JPanel p = new JPanel(new BorderLayout()); ta = new JTextArea(); ta.setEditable(false); ta.setLineWrap(true); JScrollPane sp = new JScrollPane(ta); p.add(sp,BorderLayout.CENTER); JPanel p2 = new JPanel(); tf = new JTextField(30); tf.addActionListener(this); p2.add(tf); JButton b = new JButton("Send"); b.addActionListener(this); p2.add(b); p.add(p2,BorderLayout.SOUTH); add(p); } public void actionPerformed(ActionEvent ae) { String message = name+":"+tf.getText(); tf.setText(""); tf.grabFocus(); byte[] buf = message.getBytes(); DatagramPacket packet = new DatagramPacket(buf,buf.length, group,7777); try { socket.send(packet); } catch(Exception e) {} } public void run() { while(true) { byte[] buf = new byte[256]; String received = ""; DatagramPacket packet = new DatagramPacket(buf, buf.length); try { socket.receive(packet); received = new String(packet.getData()).trim(); } catch(Exception e) {} ta.append(received +"\n"); ta.setCaretPosition(ta.getDocument().getLength()); } } }
accepted answer: http://stackoverflow.com/a/2656603
answer count: 1
downvote count: 0
favorite count: 0
tagged with: multicast
has title: How do I make my multicast program work between computers on different networks?
type: AnsweredQuestion
score: 1
tagged with: java
upvote count: 1

http://stackoverflow.com/a/2639584
accepted answer of: http://stackoverflow.com/q/2639283
has comment: http://stackoverflow.com/comment/2654515
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2639283
downvote count: 0
has body: The problem here is that binding works in both ways: from model to ui, and from ui to model. In your case, how would you deal with someone entering information for the first time in a textfield that's binded to parent.name? Would you create a parent on the fly? Would you give an error? If you know what to do in that situation (e.g. create a parent with that name), you could use a com.jgoodies.binding.value.AbstractConverter to convert a Bean1 to a String: public class ParentNameConverter extends AbstractConverter { /** * Converts a value from the subject to the type or format used * by this converter. * * @param subjectValue the subject's value * @return the converted value in the type or format used by this converter */ public Object convertFromSubject(Object subjectValue) { ... } /** * Sets a new value on the subject, after converting to appropriate type * or format * * @param newValue the ui component's value */ public void setValue(Object newValue) { ... } } You can use this converter the same way you use a normal ValueModel: Bindings.bind(uifield,"value", new ParentNameConverter(beanAdapter.getValueModel("parent")));
type: Answer
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/2659017

http://stackoverflow.com/a/2631835
accepted answer of: http://stackoverflow.com/q/2631791
score: 4
answers question: http://stackoverflow.com/q/2631791
has body: Catch it at the outer level of your run() method then place the Exception in a variable in your Runnable and have your Runnable indicate that it completed. The code that started your runnable has to then examine the Runnable to see that the "Exception" object is set and either rethrow it or deal with it. If you rethrow it, you may want to wrap it in a new exception: throw new Exception(oldException); This will give you both stack traces. (Thanks Taylor L)
downvote count: 1
has comment: http://stackoverflow.com/comment/2645168
upvote count: 5
type: AcceptedAnswer
type: Answer

http://stackoverflow.com/comment/2781741
type: Comment
has text: @Bill K Vim (not vi) can notice compile errors with plugins like syntastic http://www.vim.org/scripts/script.php?script_id=2736 It detects the errors only during file open/save, which is a deliberate design decision but it probably could be altered to show the errors while typing. I also like to check for errors only after a save since the constant visual cues tend to be annoying. By the way, vim doesn't really increase typing speed but mainly the modifying speed and the rapidness of moving around the code. The only thing that makes me sometimes use IDE are the refactoring tools.
type: QuestionComment
comment on: http://stackoverflow.com/q/2748232
score: 7

http://stackoverflow.com/comment/2641885
score: 0
has text: I am using windows 7.I have the jar file in the D:\my.jar I write the following code in my batch file @echo off java -jar my.jar and also i tried @echo off java -jar D:\my.jar what can i do?
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2622084

http://stackoverflow.com/comment/2618038
type: AnswerComment
score: 0
type: Comment
has text: proteced provides visibility to child classes (even across the package boundaries) where as with package private visibility is only to the types inside the same package.
comment on: http://stackoverflow.com/a/2607703

http://stackoverflow.com/a/2689074
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/2715852
score: 4
has body: Have you checked the OpenCV library? It's C, C++, Python and Octave. For Java try ImageJ stuff. BTW: the different file format is not a problem, different light intensity is still quite ok, but "might be captured from a comparatively different view" sounds a bit problematic. How accurate this algorithm should be? Is it gonna be used to compare the eye's image before you point the laser into someone's head or just comparing photos from Christmas?
accepted answer of: http://stackoverflow.com/q/2689014
has comment: http://stackoverflow.com/comment/2712858
answers question: http://stackoverflow.com/q/2689014
upvote count: 4
type: AcceptedAnswer

http://stackoverflow.com/comment/2793360
has text: @Bob Terracotta is known for many years for their JVM clustering solution (and now have a larger offer based on several products).
type: Comment
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/2761177

http://stackoverflow.com/q/2696439
has answer: http://stackoverflow.com/a/2696497
accepted answer: http://stackoverflow.com/a/2696497
tagged with: dom
score: 0
has title: Eclipse hangs when rebuilding after the addition of an external JAR file
answer count: 1
tagged with: jar
tagged with: soap
tagged with: http://stackoverflow.com/tag/xml
tagged with: java
type: Question
type: AnsweredQuestion
has body: I'm fairly new to Eclipse so if this is something simple I apologize, however when I attempt to add an external JAR file to my build path (specifically the "rt.jar" file which contains certain tools that I require) and then rebuild my project, Eclipse will hang at the end of the Build process. It'll get to 100% then just hang there using 100% of one of my CPU cores. At first I thought it may have been due to the relatively large size of the rt.jar file, but I tried using smaller JAR files and it still hung at 100%. Any help would be greatly appreciated! If there is something wrong with using the rt.jar file does anyone know of another JAR file that contains both tools for dealing with SOAP requests as well as XML/DOM manipulation? Thanks again!

http://stackoverflow.com/q/2689379
has answer: http://stackoverflow.com/a/17548042
has answer: http://stackoverflow.com/a/16081225
has answer: http://stackoverflow.com/a/58025958
tagged with: java
has answer: http://stackoverflow.com/a/16646552
has comment: http://stackoverflow.com/comment/106137492
has answer: http://stackoverflow.com/a/42414312
has answer: http://stackoverflow.com/a/45131087
has answer: http://stackoverflow.com/a/23932946
type: Question
has answer: http://stackoverflow.com/a/17857698
has answer: http://stackoverflow.com/a/47413441
has comment: http://stackoverflow.com/comment/122706012
has answer: http://stackoverflow.com/a/2689485
has answer: http://stackoverflow.com/a/3578208
has answer: http://stackoverflow.com/a/2689414
has answer: http://stackoverflow.com/a/28296545
has answer: http://stackoverflow.com/a/24151643
has answer: http://stackoverflow.com/a/74435505
has answer: http://stackoverflow.com/a/77437511
tagged with: date
has answer: http://stackoverflow.com/a/40798605
has title: how to get a list of dates between two dates in java
has body: I want a list of dates between start date and end date. The result should be a list of all dates including the start and end date.
has answer: http://stackoverflow.com/a/26549627
has answer: http://stackoverflow.com/a/35892853
upvote count: 88
score: 87
downvote count: 1
has answer: http://stackoverflow.com/a/41004733
answer count: 24
favorite count: 0
has answer: http://stackoverflow.com/a/2689479
has answer: http://stackoverflow.com/a/42344215
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/31398582
has answer: http://stackoverflow.com/a/2893790

http://stackoverflow.com/a/30424339
answers question: http://stackoverflow.com/q/2745471
downvote count: 0
score: 4
has body: If you still want to stick to PathVariable approach and if you are getting 400 syntactically incorrect error then follow this approach- @RequestMapping(method=RequestMethod.GET, value={"campaigns/{id}","campaigns"}) public String getCampaignDetails(Model model, @PathVariable Map&lt;String, String&gt; pathVariables) { System.out.println(pathVariables.get("id")); }
type: Answer
upvote count: 4

http://stackoverflow.com/q/2768569
type: Question
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/2779436
tagged with: maven-2
favorite count: 0
upvote count: 2
has title: Is there a way to make Maven build 1.5 and 1.6 bytecode jars simultaneously?
has body: Is there a way to make maven build 1.5 and 1.6 bytecode jars simultaneously. I know I can use classifiers to name them, but this forces to me to build them separately. I would ultimately like to do the following: mvn clean install And in my target directory see something like: fooSource.jar foo-1.6.jar foo-1.5.jar
possible better answer: http://stackoverflow.com/a/2768609
type: AnsweredQuestion
score: 2
has answer: http://stackoverflow.com/a/2768609
accepted answer: http://stackoverflow.com/a/2779436
tagged with: java

http://stackoverflow.com/a/2654779
has comment: http://stackoverflow.com/comment/2672839
upvote count: 2
answers question: http://stackoverflow.com/q/2654712
type: Answer
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/2671403
has body: A good set of practices noted by Joel Coehoorn and couple of others by answering a similar question here: It's a lot to digest but the OWASP development guide covers Web Site security from top to bottom Know about SQL injection and how to prevent it Never trust user input (cookies count as user input too!) Encrypt Hash and salt passwords rather than storing them plain-text. Don't try to come up with your own fancy authentication system: it's such an easy thing to get - wrong in subtle and untestable ways and you wouldn't even know it until after you're hacked. Know the rules for processing credit cards. See this question as well: Payment Processors - What do I need to know if I want to accept credit cards on my website? Use SSL/HTTPS for login and any pages where sensitive data is entered (like credit card info) How to resist session hijacking Avoid cross site scripting (XSS) Avoid cross site request forgeries (XSRF) Keep your system(s) up to date with the latest patches Make sure your database connection information is secured. Keep yourself informed about the latest attack techniques and vulnerabilities affecting your platform. Read The Google Browser Security Handbook

http://stackoverflow.com/a/2702782
downvote count: 0
upvote count: 28
answers question: http://stackoverflow.com/q/2702661
has body: I think that you missed the point of JPA. With JPA, you're not supposed to write queries to insert, update or delete persistent objects, JPA will generate them for you. So, what you need to do is to create domain objects and to annotate them to make them "persistable" (such annotated objects are called entities) and tell the JPA engine how to "map" them to your database. Let me try to show you the right path... First, create a Voter domain object and add JPA annotations (an entity class must be annotated with the Entity annotation, must have a no-arg constructor, must implement Serializable, must have a primary key identified by the Id annotation): @Entity public class Voter implements Serializable { private Long id; private String firstName; private String lastName; private String password; // other attributes // No-arg constructor public Voter() {} @Id @GeneratedValue // property access is used public Long getId() { return this.id; } protected void setId(Long id) { this.id = id; } // other getters, setters, equals, hashCode } I'm using JPA's defaults here (default table name, column name, etc). But this can be customized using the Table or Column annotations if you need to map your entity to an existing model. Then, create a new instance and set the various attributes: Voter voter = new Voter(); voter.setFirstName(firstName); voter.setLastName(lastName); ... And persist it: em.getTransaction().begin(); em.persist(voter); em.getTransaction().commit(); This is just a short introduction, JPA can't be covered in one answer. To go further, I suggest to check the Introduction to the Java Persistence API from the Java EE 5 Tutorial. Update: In a managed component, for example an EJB, the EntityManager is typically injected and transactions are managed by the container (i.e. you don't explicitly call begin/commit). In your case, my bet is that the EntityManager isn't successfully injected and calling any method on it results in a NPE. But that's just a guess, you need to …
has comment: http://stackoverflow.com/comment/64316720
score: 28
type: Answer

http://stackoverflow.com/comment/2664807
type: QuestionComment
comment on: http://stackoverflow.com/q/2648758
has text: You're looking for *Reified Generics*. This is not supported in Java. C# supports it. In Java generics are only compiletime. Lookup the factory pattern, see the above link to duplicate question for the correct answers.
type: Comment
score: 1

http://stackoverflow.com/a/2697792
upvote count: 3
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/2697657
score: 3
has body: There are papers Patterns of Aspect-Oriented Design (PDF) and Aspect-Oriented Design Principles: Lessons from Object-Oriented Design (PDF) which describe some patterns for AOP/bytecode manipulation. Personally I have used bytecode manipulation with ASM in one framework to generate some boilerplate code for classes which use that framework. The framework requires custom equals() and hashCode() methods for client code, so I generate those by hooking in a Java Agent which modifies the bytecode as the ClassLoader loads the classes. I have also many times used CGLIB to produce dynamic proxies (if that counts as AOP).

http://stackoverflow.com/comment/2634034
type: AnswerComment
comment on: http://stackoverflow.com/a/2620199
type: Comment
has text: Even that is not working. I guess it has to do something with the proxy setting of browsers because I am accessing internet throgh proxy server. Do I need to mention that proxy server setting somewhere in Selenium RC.
score: 0

http://stackoverflow.com/q/2719642
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/52739465
tagged with: java
tagged with: hibernate
upvote count: 8
type: Question
has title: hibernate restrictions.in with and, how to use?
answer count: 2
tagged with: sql
favorite count: 0
possible better answer: http://stackoverflow.com/a/52739465
score: 8
has body: I have table like below id, employee_no, survey_no, name 1 test 1 test_name 2 test2 1 test_name2 3 test3 1 test_name3 4 test4 2 test_name4 how to query with Restriction.in by combining below AND into one IN statement? IN[ (if(survey_no==1) &amp;&amp; employee_no== 'test') , (if(survey_no==1) &amp;&amp; employee_no== 'test2') , ... ]
downvote count: 0
has answer: http://stackoverflow.com/a/2719773
accepted answer: http://stackoverflow.com/a/2719773

http://stackoverflow.com/a/2654884
score: -1
downvote count: 2
upvote count: 1
answers question: http://stackoverflow.com/q/2654839
type: Answer
has comment: http://stackoverflow.com/comment/72320908
has body: You really need to post a more complete example, so we can see what you're trying to do. From what you have posted, here's what I can see. First, there is no built-in round() method. You need to either call Math.round(n), or statically import Math.round, and then call it like you have.

http://stackoverflow.com/q/2763416
downvote count: 0
has comment: http://stackoverflow.com/comment/2795765
has comment: http://stackoverflow.com/comment/13499764
has answer: http://stackoverflow.com/a/42001838
has comment: http://stackoverflow.com/comment/13499787
tagged with: log4j
favorite count: 0
has body: If I set the log level to DEBUG, All messages with log level >= DEBUG will be logged/printed. But can I set log level to only DEBUG, such that messages with log level only with DEBUG will be printed. Or can give a range like print all messages whose log level is >=DEBUG but &lt; ERROR?
type: UnansweredQuestion
tagged with: logging
has answer: http://stackoverflow.com/a/2763489
tagged with: java
score: 10
upvote count: 10
type: Question
answer count: 2
has title: Is it possible to log only one level messages with Log4J

http://stackoverflow.com/a/2688893
has comment: http://stackoverflow.com/comment/2711688
answers question: http://stackoverflow.com/q/2688792
has comment: http://stackoverflow.com/comment/2713741
score: 0
has body: I hate regex, I would have done it this way.. str = str.substring(str.indexOf("href=")); str = str.substring(0, str.indexOf("\"", 5); //'href=' is 5 chars //str = str.substring(0, str.indexOf(" "); //this is more readable I think Do the same for src= Note, you will get href= as part of the string as well, how to prevent that is left as an exercise. lol. (HINT: change 0 in the second line to ...)
type: Answer

http://stackoverflow.com/q/2672172
answer count: 4
type: AnsweredQuestion
score: 3
tagged with: oop
upvote count: 3
tagged with: java
has comment: http://stackoverflow.com/comment/2690866
type: Question
downvote count: 0
has answer: http://stackoverflow.com/a/2674040
possible better answer: http://stackoverflow.com/a/2672465
has comment: http://stackoverflow.com/comment/2690865
has comment: http://stackoverflow.com/comment/2690879
has answer: http://stackoverflow.com/a/2672194
has answer: http://stackoverflow.com/a/2672465
has answer: http://stackoverflow.com/a/2672196
accepted answer: http://stackoverflow.com/a/2672194
has title: Object oriented design of game in Java: How to handle a party of NPCs?
favorite count: 0
has comment: http://stackoverflow.com/comment/2690965
has body: I'm making a very simple 2D RPG in Java. My goal is to do this in as simple code as possible. Stripped down to basics, my class structure at the moment is like this: Physical objects have an x and y dimension. Roaming objects are physical objects that can move(). Humanoid objects are roaming objects that have inventories of GameItems. The Player is a singleton humanoid object that can hire up to 4 NPC Humanoids to join his or her party, and do other actions, such as fight non-humanoid objects. NPC Humanoids can be hired by the Player object to join his or her party, and once hired can fight for the Player. So far I have given the Player class a "party" ArrayList of NPC Humanoids, and the NPC Humanoids class a "hired" Boolean. However, my fight method is clunky, using an if to check the party size before implementing combat, e.g. public class Player extends Humanoids { private ArrayList&lt;Humanoids&gt; party; // GETTERS AND SETTERS for party here //... public void fightEnemy(Enemy eneObj) { if (this.getParty().size() == 0) // Do combat without party issues else if (this.getParty().size() == 1) // Do combat with party of 1 else if (this.getParty().size() == 2) // Do combat with party of 2 // etc. My question is, thinking in object oriented design, am I on the right track to do this in as simple code as possible? Is there a better way?
has comment: http://stackoverflow.com/comment/2690849

http://stackoverflow.com/comment/2730086
has text: I believe the `IllegalArgumentException` was supposed to be an example only.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2702902

http://stackoverflow.com/q/2722742
tagged with: java
has answer: http://stackoverflow.com/a/2722815
type: Question
answer count: 8
tagged with: split
has body: I have an array: int test[]={10212,10202,11000,11000,11010}; I want to split the inetger values to individual digits and place them in a new array as individual elements such that my array now is: int test2[]={1,0,2,1,2,1,0,2,0,2,1,1,0,0,0,1,1,0,0,0,1,1,0,1,0}; How would i go about doing that? I'm doing this in java. Thank you.
tagged with: arrays
downvote count: 0
has answer: http://stackoverflow.com/a/2722976
has answer: http://stackoverflow.com/a/2722775
has answer: http://stackoverflow.com/a/2723195
has answer: http://stackoverflow.com/a/2722913
favorite count: 0
tagged with: integer
has answer: http://stackoverflow.com/a/2722762
accepted answer: http://stackoverflow.com/a/2722976
upvote count: 1
has answer: http://stackoverflow.com/a/2722967
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/69050340
has comment: http://stackoverflow.com/comment/2749115
has title: Splitting integers in arrays to individual digits
possible better answer: http://stackoverflow.com/a/2722815
score: 1

http://stackoverflow.com/q/2745972
score: 3
downvote count: 0
has answer: http://stackoverflow.com/a/2746050
tagged with: java
type: Question
tagged with: websphere
answer count: 2
has answer: http://stackoverflow.com/a/2746219
accepted answer: http://stackoverflow.com/a/2746219
tagged with: servlets
upvote count: 3
favorite count: 0
has title: @Resource annotated member not injected - bad code or bug?
has body: I am using an @Resource annotation in a class instantiated in a ServletContextListener's contextInitialized(...) method, but the member is always null. Here's my sample code. Listener: public void contextInitialized(ServletContextEvent sce) { System.err.println("In contextInitialised"); new ResourceListenerTargetTest().executeMe(); } ResourceListenerTargetTest: @Resource(name="MyJDBCResource") private DataSource source; public void executeMe() { /*try { InitialContext ictx = new InitialContext(); source = (DataSource)ictx.lookup("java:comp/env/MyJDBCResource"); } catch (NamingException e) { e.printStackTrace(); }*/ System.err.println("source is " + source); } If I switch the comments and run the manual resource lookup, it works fine. Should the @Resource annotation work like this, when used in a contextInitalized method? Appserver is WAS 7.0.0.5, if it should work then I guess it's a bug? Can anyone confirm?
possible better answer: http://stackoverflow.com/a/2746050
tagged with: annotations
type: AnsweredQuestion

http://stackoverflow.com/q/2702980
type: Question
has answer: http://stackoverflow.com/a/2703006
accepted answer: http://stackoverflow.com/a/2702999
has body: I want to write a loop in Java that firs starts up and goes like this: while (!x){ //wait one minute or two //execute code } I want to do this so that it does not use up system resources. What is actually going on in the code is that it goes to a website and checks to see if something is done, if it is not done, it should wait another minute until it checks again, and when its done it just moves on. Is their anyway to do this in java?
favorite count: 0
has title: Java Loop every minute
score: 36
answer count: 5
has answer: http://stackoverflow.com/a/66398623
tagged with: time
has answer: http://stackoverflow.com/a/41338438
has answer: http://stackoverflow.com/a/2702999
downvote count: 1
type: AnsweredQuestion
upvote count: 37
tagged with: java
possible better answer: http://stackoverflow.com/a/2703011
tagged with: loops
has answer: http://stackoverflow.com/a/2703011

http://stackoverflow.com/comment/96489108
type: AnswerComment
score: 0
type: Comment
has text: go is not fast enough for any decent project and/or software engineer. it is slow, redundant and the so called easy multi-threaded (go routines) are muddy and generally error prone and cans of worms for any serious project. you do not have to take my words on faith, just write a simple program to generate the very first 200,000 prime numbers in c, c++, java and go, run it and see for yourself. also search on youtube for go presentations, you will see how complicated it is to do real life multi-threading correctly. so, if you budget to waste, "go with it" :-)
comment on: http://stackoverflow.com/a/6867046

http://stackoverflow.com/a/2762852
type: Answer
has comment: http://stackoverflow.com/comment/2801014
has comment: http://stackoverflow.com/comment/2801051
upvote count: 1
has body: No. Even getters have to be synchronized, except when they access only final fields. The reason is, that, for example, when accessing a long value, there is a tiny change that another thread currently writes it, and you read it while just the first 4 bytes have been written while the other 4 bytes remain the old value.
score: 1
answers question: http://stackoverflow.com/q/2760294
downvote count: 0

http://stackoverflow.com/a/2743508
score: 0
type: AcceptedAnswer
has body: It looks like, assuming your select has the name "secondSelect[]" as per the demo page, the two generated selects will have the names "secondSelectms2side__sx" and "secondSelectms2side__dx" So it is these names you should be looking for in the request object
answers question: http://stackoverflow.com/q/2743359
accepted answer of: http://stackoverflow.com/q/2743359
type: Answer

http://stackoverflow.com/comment/2798438
comment on: http://stackoverflow.com/a/2765578
type: AnswerComment
has text: Initialize your `PrintWriter` outside the `while` loop and do the `out.Close()` after the loop finishes. What is the result?
type: Comment
score: 0

http://stackoverflow.com/q/2601883
answer count: 6
score: 0
has answer: http://stackoverflow.com/a/2602009
upvote count: 1
downvote count: 1
tagged with: java
has answer: http://stackoverflow.com/a/42053667
has answer: http://stackoverflow.com/a/2601898
has title: What does static and IOException mean?
type: AnsweredQuestion
favorite count: 0
has body: I just had a test on java and we had to give the definition of 1) Static: 2) IOExcepion: What I said for static was...a static method is used to define a method as a class method. And I got it wrong so I asked my teacher and he said he wants the actually definition of static not a static method, class or variable just static. Can someone tell me the definition of this and for IOException please Thanks.
possible better answer: http://stackoverflow.com/a/2601934
type: Question
has answer: http://stackoverflow.com/a/2601938
has answer: http://stackoverflow.com/a/2601937
accepted answer: http://stackoverflow.com/a/2601898
has answer: http://stackoverflow.com/a/2601934

http://stackoverflow.com/a/4555549
type: Answer
has body: I think that writing tests is better alternative than adding DEBUG code. My point is that when you write test for some component/method/class you don't pollute your original source code with some redundant debug code.
answers question: http://stackoverflow.com/q/2718565
score: 1
downvote count: 2
upvote count: 3

http://stackoverflow.com/comment/2770646
comment on: http://stackoverflow.com/q/2741677
type: Comment
type: QuestionComment
score: 2
has text: Register yourself :) Then you'll keep your question history and reputation.

http://stackoverflow.com/a/2716006
has body: you can use List l = Collections.synchronizedList(new ArrayList()); if you want thread safe version of arrayList.
has comment: http://stackoverflow.com/comment/136348322
upvote count: 6
score: 6
type: Answer
answers question: http://stackoverflow.com/q/2715983
downvote count: 0

http://stackoverflow.com/q/2743106
has body: I am running an application server on Linux 64bit with 8 core CPUs and 6 GB memory. The server must be highly responsive. After some inspection I found that the application running on the server creates rather a huge amount of short-lived objects, and has only about 200~400 MB long-lived objects(as long as there is no memory leak) After reading http://java.sun.com/javase/technologies/hotspot/gc/gc_tuning_6.html I use these JVM options -server -Xms2g -Xmx2g -XX:MaxPermSize=256m -XX:NewRatio=1 -XX:+UseConcMarkSweepGC Result: the minor GC takes 0.01 ~ 0.02 sec, the major GC takes 1 ~ 3 sec the minor GC happens constantly. How can I further improve or tune the JVM? larger heap size? but will it take more time for GC? larger NewSize and MaxNewSize (for young generation)? other collector? parallel GC? is it a good idea to let major GC take place more often? and how?
answer count: 7
tagged with: jvm
favorite count: 0
upvote count: 8
has answer: http://stackoverflow.com/a/12938465
has answer: http://stackoverflow.com/a/2743401
tagged with: garbage-collection
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/17688055
tagged with: performance
possible better answer: http://stackoverflow.com/a/9822045
has answer: http://stackoverflow.com/a/2743346
has answer: http://stackoverflow.com/a/5780364
has answer: http://stackoverflow.com/a/9822045
tagged with: java
type: Question
linked to: http://stackoverflow.com/q/986974
accepted answer: http://stackoverflow.com/a/2743346
has answer: http://stackoverflow.com/a/2743171
score: 8
has title: Tuning JVM (GC) for high responsive server application
downvote count: 0

http://stackoverflow.com/comment/2812288
comment on: http://stackoverflow.com/a/2777526
type: AnswerComment
score: 0
type: Comment
has text: @mmr & David: I posted some code... it's building a table of the primes needed for quickly checking primes afterward (up to the square of the largest target number). The only hardcoded prime required is 2 - the table is then built incrementally in a loop, using the previously-computed values to compute the new ones. Just including a precomputed table however would be lame/unacceptable IMHO, because it doesn't really make the algorithm "better" but rather "dumb but quick".

http://stackoverflow.com/comment/4134298
comment on: http://stackoverflow.com/q/2597965
has text: Remember me when I was telling one of co-worker to NOT add clone method everywhere. But it was difficult to me to explain why :)
type: Comment
type: QuestionComment
score: 3

manifest
tags question: http://stackoverflow.com/q/2690143
tags question: http://stackoverflow.com/q/2636078
tags question: http://stackoverflow.com/q/2678027
tag name: manifest
type: Tag

http://stackoverflow.com/a/2705071
has body: ActiveMQ is a message broker which implements the JMS API and supports a number of cross language clients and network protocols. It lets you implement queues or topics and write listeners or subscribers to respond to queue events. Mule and ServiceMix are open source ESB (enterprise service bus). An ESB has capabilities beyond JMS: queuing is key, but so are transformation, routing, logging, security, etc. Apache Camel is an implementation of the patterns in Enterprise Integration Patterns. It can use JMS and other components to put the ideas from that book into place. JMS is fundamental to the other technologies, like JDBC is the foundation for Hibernate, iBatis, etc. JMS is a Java API and a specification and TCK (part of Java EE). ActiveMQ is a particular implementation of it. Camel can use ActiveMQ (and Camel is bundled inside the ActiveMQ broker so you can easily route to and from JMS to the other components Camel supports). Camel doesn't use Mule or ServiceMix directly; though ServiceMix uses Camel as its preferred routing engine and EIP implementation. Camel does have a ton of different components though that use various different technologies.
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2705043
upvote count: 81
has comment: http://stackoverflow.com/comment/3008541
accepted answer of: http://stackoverflow.com/q/2705043
type: Answer
score: 81
has comment: http://stackoverflow.com/comment/2728615

network-programming
tags question: http://stackoverflow.com/q/2713371
tags question: http://stackoverflow.com/q/2607515
tags question: http://stackoverflow.com/q/2686511
tags question: http://stackoverflow.com/q/2658843
tags question: http://stackoverflow.com/q/2671526
tags question: http://stackoverflow.com/q/2656590
tags question: http://stackoverflow.com/q/2675362
tags question: http://stackoverflow.com/q/2642487
tags question: http://stackoverflow.com/q/2784696
tags question: http://stackoverflow.com/q/2619082
tags question: http://stackoverflow.com/q/2719482
tags question: http://stackoverflow.com/q/2772284
type: Tag
tags question: http://stackoverflow.com/q/2714795
tags question: http://stackoverflow.com/q/2638705
tags question: http://stackoverflow.com/q/2745843
tag name: network-programming
tags question: http://stackoverflow.com/q/2776724
tags question: http://stackoverflow.com/q/2761823
tags question: http://stackoverflow.com/q/2601124
tags question: http://stackoverflow.com/q/2676890
tags question: http://stackoverflow.com/q/2719545
tags question: http://stackoverflow.com/q/2783795
tags question: http://stackoverflow.com/q/2722324
tags question: http://stackoverflow.com/q/2718936
tags question: http://stackoverflow.com/q/2719253
tags question: http://stackoverflow.com/q/2733078
tags question: http://stackoverflow.com/q/2745990
tags question: http://stackoverflow.com/q/2619025
tags question: http://stackoverflow.com/q/2756243

search-engine
type: Tag
tag name: search-engine
tags question: http://stackoverflow.com/q/2730200

http://stackoverflow.com/a/2792303
has body: If you want to rotate a portion of a BufferedImage you might find these classes/methods useful: AffineTransform.getRotateInstance or AffineTransform.getQuadrantRotateInstance AffineTransformOp BufferedImage.getSubImage() BufferedImage.setData Example: import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.geom.AffineTransform; import java.awt.image.AffineTransformOp; import java.awt.image.BufferedImage; import java.awt.image.BufferedImageOp; import java.io.IOException; import java.net.URL; import javax.imageio.ImageIO; import javax.swing.AbstractAction; import javax.swing.BoxLayout; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.WindowConstants; public class TileTest extends JFrame { public static void main(String[] args) throws IOException { URL logo = new URL("http://sstatic.net/so/img/logo.png"); TileTest tileTest = new TileTest(ImageIO.read(logo)); tileTest.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); tileTest.setVisible(true); } private TileTest(BufferedImage image) throws IOException { this.image = image; setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); JLabel label = new JLabel(new ImageIcon(image)); add(label); BufferedImage tile = image.getSubimage(0, 0, 61, 61); add(new JButton(new RotateAction(tile, label))); pack(); } private BufferedImage image; } class RotateAction extends AbstractAction { public void actionPerformed(ActionEvent e) { BufferedImage tmpImage = op.filter(image, null); image.setData(tmpImage.getRaster()); component.repaint(); } RotateAction(BufferedImage image, Component component) { super("Rotate"); this.component = component; this.image = image; double x = 0.5 * image.getWidth(); double y = 0.5 * image.getHeight(); AffineTransform xfrm = AffineTransform.getQuadrantRotateInstance(1, x, y); op = new AffineTransformOp( xfrm, AffineTransformOp.TYPE_NEAREST_NEIGHBOR); } private final Component component; priva…
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2782068
score: 1
upvote count: 1

http://stackoverflow.com/comment/2702964
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2683148
has text: I haven't had the error yet. But I predict it will. At some point the program should work with larger and larger datasets and I doubt the machine's memory will always be able to hold it all.
score: 0

http://stackoverflow.com/a/2705531
downvote count: 0
has comment: http://stackoverflow.com/comment/2729147
accepted answer of: http://stackoverflow.com/q/2705504
has comment: http://stackoverflow.com/comment/2729098
has body: No, but you can get a wordlist from various places. From there, you could read the wordlist file into a list: List&lt;String&gt; lines = new ArrayList&lt;String&gt;(); BufferedReader in = new BufferedReader(new FileReader("wordlist.txt")); String line = null; while (null!=(line=in.readLine())) { lines.add(line); } in.close(); And finally binary search use lines.contains() for your candidate word.
answers question: http://stackoverflow.com/q/2705504
score: 5
type: AcceptedAnswer
upvote count: 5
type: Answer

http://stackoverflow.com/comment/8553687
type: Comment
has text: where is the documented? (the limit on the size)
comment on: http://stackoverflow.com/a/2678158
score: 0
type: AnswerComment

http://stackoverflow.com/comment/2788161
score: 2
has text: davit-datuashvili, could you clean up your post a bit? Fix some of the spelling errors and indent your code so that it shows up nicely formatted. See: http://stackoverflow.com/editing-help
comment on: http://stackoverflow.com/q/2756714
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/2647618
score: 0
type: AnswerComment
has text: @stdnoit, yes, you've lost me. Please provide sample code, or at least pseudo code of what you have, and what you expect.
type: Comment
comment on: http://stackoverflow.com/a/2633781

http://stackoverflow.com/comment/2618752
comment on: http://stackoverflow.com/a/2602503
score: 0
type: AnswerComment
type: Comment
has text: I wasn't actually proposing a solution for you, I just shared our experience that WPS is quite special, so there are not ready tools for that.

http://stackoverflow.com/q/2765888
score: 11
has title: Is it possible to execute binary files in java?
has body: I have a list of binaries written in Java, Ada, C, and Python and I want to execute them. How can I do that? Are there any JVM binding to those languages?
has answer: http://stackoverflow.com/a/2765923
upvote count: 11
type: AnsweredQuestion
tagged with: binaries
tagged with: java
possible better answer: http://stackoverflow.com/a/2765928
has answer: http://stackoverflow.com/a/2766565
type: Question
downvote count: 0
answer count: 3
has answer: http://stackoverflow.com/a/2765928
accepted answer: http://stackoverflow.com/a/2765923
favorite count: 0

http://stackoverflow.com/comment/2833409
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2795773
has text: What a mess, thanks for your feedback. I guess using the standard library just isn't the way to do what I need. I later noticed that using your own TTF file produces different renderings even between Mac and Windows.
type: Comment

http://stackoverflow.com/comment/2671309
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2654764
has text: wouldn't the result of a left outer join(a -> b) be the same as left outer join(a -> b -> c)?

http://stackoverflow.com/q/2755289
has body: While this is by no means really important, I was just wondering if the community knows how to put icons for my custom GUI components that show up in the NetBeans GUI designer. What I did was make several Swing components. Then I use the menu options to add them to the GUI palette, but they show up with "?" icons. It would be nice if they showed up with icons similar to swing components such as JButton, especially for components which are subclassed from Swing components.
type: Question
score: 3
tagged with: java
tagged with: designer
tagged with: user-interface
accepted answer: http://stackoverflow.com/a/2755941
downvote count: 0
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/2755941
type: AnsweredQuestion
tagged with: netbeans
upvote count: 3
has title: In NetBeans IDE 6.1 how can I get icons for my custom GUI components in the GUI editor?

http://stackoverflow.com/q/2775550
downvote count: 0
has body: I am building a swing application. At some point, I have to start an "animation": ... jpanel1.setBackground(Color.Black); Delay(milli) jpanel1.setBackground(Color.White); ... and so on. The gui itself and all the logic behind it work.It is just this time depended color-changing that does not. I have read, that swing is not thread safe, but all the examples I found showed me how to start another thread (for example in the background) but never how to stop the current swing-gui thread. Edit: The application should work as following: configuration files are read, jframe is set up. some simple questions are beeing asked a dialogue is opened, which explains the animation. after the user clicked "ok" the animation - some color flashing - is started. the color and the delay between the color-changing is depended on the configuration another dialogue is opened and the programm continues -> new jpanel inside the jframe, buttons and so on. the online thing that does not work are the delays between the color-changing. I understand now why it does not work and I am trying to build a timer, which activates a actionlister, which then changes the color and stops the timer... it just seems so much work for a simple delay... and I have to reorganize the entire animation in the application.
tagged with: java
tagged with: multithreading
tagged with: swing
has answer: http://stackoverflow.com/a/2776675
type: Question
has answer: http://stackoverflow.com/a/2776773
accepted answer: http://stackoverflow.com/a/2776773
upvote count: 2
possible better answer: http://stackoverflow.com/a/2775570
has answer: http://stackoverflow.com/a/2775739
favorite count: 0
has answer: http://stackoverflow.com/a/2775570
has title: How to use a delay in a swing application
answer count: 4
has comment: http://stackoverflow.com/comment/2811062
type: AnsweredQuestion
score: 2

http://stackoverflow.com/comment/53321768
has text: could you please check my question http://stackoverflow.com/questions/32699420/url-parameters-are-not-being-passed-by-curl-post i need help and thank u very mcuh
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/9613252

http://stackoverflow.com/comment/64805267
has text: You can use the simple html attribute "autofocus". You can directly add it to the html's first input tag or dinamically add like "component.add(new AttributeAppender("autofocus", ""));" Check my brief answer.
comment on: http://stackoverflow.com/a/4448660
type: AnswerComment
score: 1
type: Comment

http://stackoverflow.com/a/4591900
score: 56
answers question: http://stackoverflow.com/q/2618272
type: Answer
downvote count: 1
has body: Try with match_parent on the layout_height property of the list view. It will prevent getView() to be called so often.
has comment: http://stackoverflow.com/comment/28596690
has comment: http://stackoverflow.com/comment/22749231
upvote count: 57
has comment: http://stackoverflow.com/comment/93977456

http://stackoverflow.com/comment/2761953
type: QuestionComment
comment on: http://stackoverflow.com/q/2733735
score: 0
has text: This is indeed BlackBerry development. The hanging has usually been on the simulator, however it has not hanged on the simulator since upgrading the JDK eclipse plugin from 1.0 to 1.1. Just today, however, a hang occurred on the device itself. BalusC - thanks for the tip on the close() statement.
type: Comment

http://stackoverflow.com/comment/5660808
score: 0
type: Comment
type: QuestionComment
has text: I am also reading the same example , and tried few examples to prove it, but failed. Have you got any way to prove it. Would be helpful if you say.
comment on: http://stackoverflow.com/q/2624638

http://stackoverflow.com/q/2603325
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2612997
tagged with: java
has title: Assigning a default value to a final variable in case of an exception in Java
accepted answer: http://stackoverflow.com/a/2603451
type: Question
tagged with: try-catch
downvote count: 0
has answer: http://stackoverflow.com/a/2603341
has comment: http://stackoverflow.com/comment/2612894
upvote count: 8
answer count: 3
has comment: http://stackoverflow.com/comment/2612910
score: 8
favorite count: 0
has answer: http://stackoverflow.com/a/2603451
possible better answer: http://stackoverflow.com/a/2603824
has body: Why won't Java let me assign a value to a final variable in a catch block after setting the value in the try block, even if it is not possible for the final value to be written in case of an exception. Here is an example that demonstrates the problem: public class FooBar { private final int foo; private FooBar() { try { int x = bla(); foo = x; // In case of an exception this line is never reached } catch (Exception ex) { foo = 0; // But the compiler complains // that foo might have been initialized } } private int bla() { // You can use any of the lines below, neither works // throw new RuntimeException(); return 0; } } The problem is not hard to work around, but I would like to understand why the compiler does not accept this. Thanks in advance for any inputs!
tagged with: final
has answer: http://stackoverflow.com/a/2603824
has comment: http://stackoverflow.com/comment/2612932

http://stackoverflow.com/comment/2719434
type: Comment
has text: Nope it continued to work fine. But before it calls other class/method I copied another xx.jar deployed same as the deleted xx.jar one.
type: AnswerComment
comment on: http://stackoverflow.com/a/2697093
score: 0

http://stackoverflow.com/q/2650409
has answer: http://stackoverflow.com/a/2651580
has answer: http://stackoverflow.com/a/2650574
tagged with: jta
answer count: 2
downvote count: 0
has title: Implement custom JTA XAResource for using with hibernate
favorite count: 0
type: UnansweredQuestion
tagged with: transactions
score: 1
tagged with: java
upvote count: 1
type: Question
has body: I have two level access to database: the first with Hibernate, the second with JDBC. The JDBC level work with nontransactional tables (I use MyISAM for speed). I want make both levels works within transaction. I read about JTA which can manage distributed transactions. But there is lack information in the internet about how to implement and use custom resource. Does any one have experience with using custom XAResources?

http://stackoverflow.com/q/2613432
type: AnsweredQuestion
tagged with: java
upvote count: 49
has answer: http://stackoverflow.com/a/2613945
has comment: http://stackoverflow.com/comment/2629500
type: Question
has title: Remove source file comments using IntelliJ?
tagged with: intellij-idea
score: 49
accepted answer: http://stackoverflow.com/a/2613945
answer count: 6
tagged with: comments
has body: Is there a plugin or tool in IntelliJ that will strip all comments out of your source .java files? I've read about an ANT task that can do this.. was looking to do the same from within the IDE. Alternatively a TextPad plugin would work as well..
has answer: http://stackoverflow.com/a/64009632
has answer: http://stackoverflow.com/a/54275061
linked to: http://stackoverflow.com/q/834584
has answer: http://stackoverflow.com/a/44074706
has comment: http://stackoverflow.com/comment/2624619
has comment: http://stackoverflow.com/comment/2624383
downvote count: 0
has answer: http://stackoverflow.com/a/14071306
has comment: http://stackoverflow.com/comment/64620360
favorite count: 0
possible better answer: http://stackoverflow.com/a/44074706
has answer: http://stackoverflow.com/a/25419985

http://stackoverflow.com/a/2766548
score: 0
answers question: http://stackoverflow.com/q/2766465
has body: Looks fine to start. I'm going just to suggest a couple of things: 1.- Import the out attribute from System: import static java.lang.System.out; 2.- In the for loop remove the break ... for(int i=0; i&lt;50; i++){ Person pers = new Person(); out.print("name: "); pers.name=diskScanner.nextLine(); out.print("stuff: "); pers.stuff=diskScanner.nextLine(); thing.add(pers); break; //&lt;-- Remove this to continue with the remaining 49 persons } 3.- Finally you could print the values like this: // Display people for (int i=0; i&lt;50; i++) { //out.println(??);{ //} // could be: out.println("name: "+ thing.get(i).name +" stuff:"+thing.get(i).stuff ); } ... edit Alternatives for the print: // introduce a variable p for (int i=0; i&lt;50; i++) { Person p = thing.get(i); out.println("name: "+ p.name +" stuff:"+p.stuff ); } Or // using the size of the array and printf.. for (int i=0; i&lt;thig.size(); i++) { Person p = thing.get(i); out.printf("name: %s stuff: %s %n", p.name ,p.stuff ); } Or even better ( my preferred ) // using the for-each syntax for( Person p : thing ) { out.printf("name: %s stuff: %s %n", p.name ,p.stuff ); }
accepted answer of: http://stackoverflow.com/q/2766465
type: AcceptedAnswer
type: Answer

http://stackoverflow.com/comment/107676224
type: AnswerComment
score: 0
type: Comment
has text: I come from ruby and wanted to test: Integer.parseInt("12").getClass().getName() which evidently does not work. No idea if anyone reads this, but a universal type query method would be great. (I was trying to determine the difference between .valueOf() and .parse* related methods.)
comment on: http://stackoverflow.com/a/2674558

http://stackoverflow.com/a/2658204
answers question: http://stackoverflow.com/q/2658133
downvote count: 0
type: Answer
upvote count: 6
has body: By far the most important tools are your ears, your tongue and your larynx. Ask the people who are familiar with the code - they'll be able to help you understand its general architecture much better than any software tools. Automatically reverse-engineered complete UML models are generally nearly useless because they cannot distinguish between important abstractions and implementation details - which is the whole point of such models. Software tools are more useful to answer very specific questions when you are investigating details, such as "where is this method called from?" or "what classes implement this interface" - any good IDE will be able to do that. Debuggers can help too - placing breakpoints at keypoints of the code and looking at the call stack when they're hit is often very enlightening.
score: 6

http://stackoverflow.com/a/18378681
score: 22
upvote count: 22
answers question: http://stackoverflow.com/q/2721614
type: Answer
has body: Use the parse(String) method. LocalDate date = LocalDate.parse("2009-04-17");
downvote count: 0

http://stackoverflow.com/a/3526872
upvote count: 1
type: Answer
has body: You could try to use this regular expression: (?:(?&lt;protocol&gt;http(?:s?)|ftp)(?:\:\/\/)) (?:(?&lt;usrpwd&gt;\w+\:\w+)(?:\@))? (?&lt;domain&gt;[^/\r\n\:]+)? (?&lt;port&gt;\:\d+)? (?&lt;path&gt;(?:\/.*)*\/)? (?&lt;filename&gt;.*?\.(?&lt;ext&gt;\w{2,4}))? (?&lt;qrystr&gt;\??(?:\w+\=[^\#]+)(?:\&amp;?\w+\=\w+)*)* (?&lt;bkmrk&gt;\#.*)? This will tell you if an URL is valid and it will give you the protocol value. I don't know Java, so I don't know what class you need to use to validate Regular Expressions.
answers question: http://stackoverflow.com/q/2597653
score: -1
downvote count: 2

http://stackoverflow.com/a/2711123
type: AcceptedAnswer
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/2711092
has comment: http://stackoverflow.com/comment/2740143
score: 3
upvote count: 3
has body: For storing: SQLite seems like a good solution for things such as searching and cross platform support. Android and many other devices support SQLite.
answers question: http://stackoverflow.com/q/2711092

http://stackoverflow.com/a/54582965
upvote count: 2
type: Answer
score: 2
has body: Use below code to convert String Date to Epoc Timestamp. Note : - Your input Date format should match with SimpleDateFormat. String inputDateInString= "8/15/2017 12:00:00 AM"; SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyy hh:mm:ss"); Date parsedDate = dateFormat.parse("inputDateInString"); Timestamp timestamp = new java.sql.Timestamp(parsedDate.getTime()); System.out.println("Timestamp "+ timestamp.getTime());
downvote count: 0
answers question: http://stackoverflow.com/q/2742380

http://stackoverflow.com/a/2664886
type: Answer
has body: Why would you need this? If you are calling business logic in setter it's not very good approach. If you just need dynamic model updating, go for (Compound)PropertyModel.
score: 0
answers question: http://stackoverflow.com/q/2605180

http://stackoverflow.com/q/2783530
tagged with: object
has title: Why should I implement toString method for my Object?
upvote count: 3
answer count: 3
favorite count: 0
has answer: http://stackoverflow.com/a/2783550
has comment: http://stackoverflow.com/comment/2818741
accepted answer: http://stackoverflow.com/a/2783546
linked to: http://stackoverflow.com/q/2653268
tagged with: tostring
type: AnsweredQuestion
score: 3
downvote count: 0
possible better answer: http://stackoverflow.com/a/2783642
tagged with: java
has body: Besides printing stuffs for the console what other use have you found for toString() method for your objects?
has answer: http://stackoverflow.com/a/2783642
has answer: http://stackoverflow.com/a/2783546
type: Question

http://stackoverflow.com/comment/46761957
type: Comment
score: 0
type: AnswerComment
has text: @gravidThoughts: Nobody spoke of indecipherable. Please avoid strawman arguments.
comment on: http://stackoverflow.com/a/2728180

http://stackoverflow.com/a/2695231
has comment: http://stackoverflow.com/comment/48670352
type: AcceptedAnswer
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/75264931
has body: Yes, on Mac OS X there is a program called Jar Bundler that is installed when you install the free (assuming that you already own a copy of Mac OS X) Xcode Developer Tools that allows you to bundle a JAR file inside a native Mac OS X "*.app" application bundle with a nice and shiny icon just like other apps. Update The JAR bundler doesn't exist on later versions of OS X. As a workaround, you can manually create an OS X project that invokes Java. Or, there are a variety of build system extensions that do a similar thing; for example, the gradle-macappbundle plugin for Gradle will create such a wrapper app.
upvote count: 31
accepted answer of: http://stackoverflow.com/q/2695214
answers question: http://stackoverflow.com/q/2695214
score: 31

http://stackoverflow.com/comment/24835461
type: QuestionComment
has text: Sucks when you google it and this is the first thing you find...
score: 2
comment on: http://stackoverflow.com/q/2621785
type: Comment

http://stackoverflow.com/comment/2813350
type: AnswerComment
comment on: http://stackoverflow.com/a/2778637
score: 0
type: Comment
has text: This is a pretty awesome answer, thanks for taking the time to write it up and link to everything.

http://stackoverflow.com/comment/2608677
score: 0
type: Comment
has text: It is as easy to "clone" (or literally, clone()) an array as well as a List.
type: AnswerComment
comment on: http://stackoverflow.com/a/2599787

http://stackoverflow.com/comment/115022183
has text: @AlonsodelArte Not sure (there are complications like multiple nesting levels and anonymous classes). Not too relevant anyway, I just wanted to point out that the answer is technically incorrect for the question as written.
type: Comment
comment on: http://stackoverflow.com/a/2690339
score: 1
type: AnswerComment

http://stackoverflow.com/comment/63626006
comment on: http://stackoverflow.com/a/2773843
type: Comment
has text: What is a 'PRESENT object'?
score: 5
type: AnswerComment

http://stackoverflow.com/comment/2679071
score: 0
type: AnswerComment
has text: Can't get this to work, haven't tried it with Spotify yet. But I can't get the code to work, care to put it in a context on how to use it? I'm new to this whole Intent-thingie.
type: Comment
comment on: http://stackoverflow.com/a/2659676

http://stackoverflow.com/a/2623856
type: AcceptedAnswer
downvote count: 0
type: Answer
score: 2
upvote count: 2
has body: You can do whatever you want using the getValueAt(...) and setValueAt(...) methods. So you get the values of the two columns and combine them into a single string and then reset the value in the first column. Then you set the second column to the empty string.
answers question: http://stackoverflow.com/q/2622467
accepted answer of: http://stackoverflow.com/q/2622467

dispatchevent
tags question: http://stackoverflow.com/q/2708408
tag name: dispatchevent
type: Tag

http://stackoverflow.com/a/2733739
accepted answer of: http://stackoverflow.com/q/2733688
downvote count: 0
answers question: http://stackoverflow.com/q/2733688
has comment: http://stackoverflow.com/comment/2761784
has body: If you're looking for an embeddable database, my recommendation would be H2 (stands for Hypersonic 2, (re)written by the author of HSQLDB). See the detailed comparison of features and of performances. Using a 100% Java database would allow to run it in the same process and make things a lot easier IMO.
upvote count: 38
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2793358
score: 38
has comment: http://stackoverflow.com/comment/2761690
type: Answer
has comment: http://stackoverflow.com/comment/2784426
has comment: http://stackoverflow.com/comment/2761709
has comment: http://stackoverflow.com/comment/39919289

overloading
tags question: http://stackoverflow.com/q/2722856
tags question: http://stackoverflow.com/q/2659496
tags question: http://stackoverflow.com/q/2637268
type: Tag
tags question: http://stackoverflow.com/q/2706258
tag name: overloading
tags question: http://stackoverflow.com/q/2744511

http://stackoverflow.com/comment/134567642
type: Comment
comment on: http://stackoverflow.com/a/76310933
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).
score: 1
type: AnswerComment

http://stackoverflow.com/a/2617876
upvote count: 7
type: Answer
has body: Global Constants As others state, global constants don't have the same negative connotation as global variables. Global variables make a program difficult to debug and maintain because of uncontrolled modifications. Global constants (public static final) don't create the same problem Nevertheless, object-orientation is about binding code close to its data to enhance understandability and maintainability. You still have to find the right balance between storing global configuration values in a global class vs keeping data close to the code that will use it. It is probably also worth reminding here that, because the compiler may inline some constants, if you change a constant value, you may have to recompile and redeploy more than just the class that contains the constants. Externalizing Values You also asked about what professional apps do. Its not uncommon for those apps to make these types of values, like files paths, externally configurable. It depends on how likely the value is to change (i.e. how likely your app will move or your code will be used in another app) and how convenient or easy it is to recompile and redeploy the code with new values. If you do choose to make some values externally configurable, you still may want to encode default values for those items in the code. Here are some ways to externalize those values and some links to get you started. This is of course not an exhaustive list: System properties so you can specify them on the command line Property files [See StackOverflow Q - How to use java property files?] Resource Bundles [See StackOverflow Q - How to load a resource bundle from a file resource?]
answers question: http://stackoverflow.com/q/2617606
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2617606
score: 7
type: AcceptedAnswer

http://stackoverflow.com/q/2636086
score: 36
has body: my JavaDoc doesn't work when I have a code example with an annotation. Any suggestions? /** * &lt;pre&gt; * public class Demo { * @DemoAnnotation * public void demoMethod() { * } * } * &lt;/pre&gt; */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD}) public @interface DemoAnnotation {
has answer: http://stackoverflow.com/a/14038025
accepted answer: http://stackoverflow.com/a/2636111
favorite count: 0
has answer: http://stackoverflow.com/a/52067724
answer count: 5
linked to: http://stackoverflow.com/q/541920
type: AnsweredQuestion
has title: Code example with annotation in JavaDoc
has answer: http://stackoverflow.com/a/51323091
tagged with: java
tagged with: javadoc
possible better answer: http://stackoverflow.com/a/10035095
type: Question
has answer: http://stackoverflow.com/a/2636111
has answer: http://stackoverflow.com/a/10035095
upvote count: 36
downvote count: 0

http://stackoverflow.com/q/2768118
has answer: http://stackoverflow.com/a/2768176
possible better answer: http://stackoverflow.com/a/2768152
accepted answer: http://stackoverflow.com/a/2768136
type: AnsweredQuestion
has title: Am I compiling with x64 JDK?
score: 1
tagged with: java
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/2768136
answer count: 3
downvote count: 0
has answer: http://stackoverflow.com/a/2768152
favorite count: 0
has body: Do I have the 64 bit of JDK installed on my machine? My java -version says: C:\Documents and Settings\Administrator>java -version java version "1.6.0_20" Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode) Should I expect a performance improvement in using a 64 bit compiler versus a 32 bit one? Thanks, Mike

http://stackoverflow.com/q/2603871
accepted answer: http://stackoverflow.com/a/2603885
answer count: 2
tagged with: file-io
has answer: http://stackoverflow.com/a/2603982
favorite count: 0
has body: I just read the article Programming by Coincidence. At the end of the page there are excercises. A few code fragments that are cases of "programming by coincidence". But I cant figure out the error in this piece: This code comes from a general-purpose Java tracing suite. The function writes a string to a log file. It passes its unit test, but fails when one of the Web developers uses it. What coincidence does it rely on? public static void debug(String s) throws IOException { FileWriter fw = new FileWriter("debug.log", true); fw.write(s); fw.flush(); fw.close(); } What is wrong about this?
possible better answer: http://stackoverflow.com/a/2603982
upvote count: 6
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2603885
has title: 'Programming by Coincidence' Excercise: Java File Writer
tagged with: java
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/2613827
score: 5
has comment: http://stackoverflow.com/comment/2613725

http://stackoverflow.com/comment/95134680
type: AnswerComment
comment on: http://stackoverflow.com/a/34217962
type: Comment
has text: This doesn't access the constructor
score: 0

http://stackoverflow.com/comment/2747854
type: AnswerComment
comment on: http://stackoverflow.com/a/2721557
type: Comment
score: 2
has text: @danyal: Nope - the same class implementation is used for all generic uses. It is all implemented using direct casts to/from the right types in the right places.

http://stackoverflow.com/comment/2770860
type: Comment
has text: This looks to be `O(N^2)`, when `O(N log N)` is the upper bound with comparison-based sort. `O(N)` possible if non comparison-based sort is applicable.
comment on: http://stackoverflow.com/a/2741632
score: 1
type: AnswerComment

http://stackoverflow.com/q/2599499
upvote count: 5
has comment: http://stackoverflow.com/comment/2608547
has comment: http://stackoverflow.com/comment/2608246
has answer: http://stackoverflow.com/a/2599724
has comment: http://stackoverflow.com/comment/2608297
downvote count: 0
has comment: http://stackoverflow.com/comment/2608271
has title: k-combinations of a set of integers in ascending size order
has answer: http://stackoverflow.com/a/2605826
possible better answer: http://stackoverflow.com/a/2599640
favorite count: 0
has comment: http://stackoverflow.com/comment/2608225
has answer: http://stackoverflow.com/a/2599640
has answer: http://stackoverflow.com/a/2599570
has body: Programming challenge: Given a set of integers [1, 2, 3, 4, 5] I would like to generate all possible k-combinations in ascending size order in Java; e.g. [1], [2], [3], [4], [5], [1, 2], [1, 3] ... [1, 2, 3, 4, 5] It is fairly easy to produce a recursive solution that generates all combinations and then sort them afterwards but I imagine there's a more efficient way that removes the need for the additional sort.
answer count: 4
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/2605826
type: Question
score: 5
tagged with: algorithm

http://stackoverflow.com/a/2701278
score: 1
type: Answer
answers question: http://stackoverflow.com/q/2701255
has body: You can try (from commons-lang): ArrayUtils.toString(vector.toArray());
upvote count: 1
downvote count: 0

http://stackoverflow.com/a/2646142
downvote count: 0
answers question: http://stackoverflow.com/q/2645783
type: Answer
has body: I would do it like so: public boolean overlap(List&lt;Interval&gt; intervals) { int countMinusOne = intervals.size() - 1; for (int i = 0; i &lt; countMinusOne; i++) { Interval first = intervals.get(i); for (int j = i + 1; j &lt;= countMinusOne; j++) { Interval second = intervals.get(j); if (second.getStart() &lt;= first.getEnd() &amp;&amp; second.getEnd() &gt;= first.getStart()) return true; } } return false; } This assumes that the start of an interval is always smaller than the end of an interval. It does as little checks as possible.
upvote count: 1
score: 1

http://stackoverflow.com/comment/6841969
score: 0
has text: Please close or delete this question. For REST service I must use JAX-RS. And I did it by using Jersey.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2688960

http://stackoverflow.com/q/2598393
has title: Hibernate Transient Extends problem
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/2598498
tagged with: jpa
downvote count: 0
favorite count: 0
upvote count: 3
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2598430
has body: @MappedSuperclass public abstract class BaseAbstract implements Serializable{ private static final long serialVersionUID = 1L; protected String test = //some random value; public String getTest() { return test; } public void setTest(String test){ this.test = test; } } @Entity public class Artist extends BaseAbstract { private static final long serialVersionUID = 1L; private Integer id; @override @Transient public String getTest() { return test; } ..... } My question is... when i am trying to do any operation on the artist, along with id and name, test is also getting saved which should not be the case... if i add the same transient on the baseabstract class getTest() method, i see test column NOT getting created(ideally what it should happen) but if i try to override the method with adding annotaion in the sub class it creates the test column... I dont know why this is happening since when hibernate is creating the artist object and checks for annotations, it should see the transient annotation present on the getTest() of artist method...and should not create a column in the database... Let me know if you need any clarification.... Any response on this is greatly appreciated.... Thank you
score: 3
tagged with: java
tagged with: hibernate
tagged with: orm

http://stackoverflow.com/a/2683458
type: Answer
accepted answer of: http://stackoverflow.com/q/2683264
answers question: http://stackoverflow.com/q/2683264
score: 5
type: AcceptedAnswer
upvote count: 5
has body: Instead of JasperPrint print = JasperFillManager.fillReport(report, parameters); I used JasperPrint print = JasperFillManager.fillReport(report, parameters, new JREmptyDataSource()); and it worked. Thanks!
has comment: http://stackoverflow.com/comment/2712297
downvote count: 0

http://stackoverflow.com/q/2733255
upvote count: 48
favorite count: 0
score: 48
tagged with: android
tagged with: regex
accepted answer: http://stackoverflow.com/a/2733263
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2733298
tagged with: java
tagged with: whitespace
type: Question
has body: I want to replace all whitespace characters in a string with a "+" and all "ß" with "ss"... it works well for "ß", but somehow eclipse won't let me use \s for a whitespace.. I tried "\t" instead, but it doesn't work either.. I get the following error: Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \ ) this is my code: try { String temp1 = from.getText().toString(); start_from = temp1.replaceAll("ß", "ss"); start_from = start_from.replaceAll("\s", "+"); } why doesn't it work? is it a problem with android, eclipse or what? thanks in advance!
possible better answer: http://stackoverflow.com/a/2733277
has title: Java doesn't work with regex \s, says: invalid escape sequence
has answer: http://stackoverflow.com/a/2733277
has comment: http://stackoverflow.com/comment/2761088
has answer: http://stackoverflow.com/a/2733263
has comment: http://stackoverflow.com/comment/2761327
answer count: 3
downvote count: 0

http://stackoverflow.com/a/36057027
downvote count: 2
answers question: http://stackoverflow.com/q/2607289
has body: Even shorter: List&lt;Integer&gt; list = Arrays.asList(1, 2, 3, 4);
type: Answer
score: 11
upvote count: 13

http://stackoverflow.com/comment/16152918
score: 0
type: AnswerComment
has text: So what was it? I run into the same problem when loading entity and adding new entity as a child collection item
type: Comment
comment on: http://stackoverflow.com/a/4285530

http://stackoverflow.com/q/2645801
tagged with: java
has answer: http://stackoverflow.com/a/2645871
tagged with: scripting-language
type: Question
has answer: http://stackoverflow.com/a/2647616
upvote count: 12
has answer: http://stackoverflow.com/a/2646789
possible better answer: http://stackoverflow.com/a/2645871
has body: I prefer to use scripting languages for short tasks, anything such as a really simple http bot, bulk importing/exporting data to/from somewhere, etc etc... Basic throw-away scripts and simple stuff. The point being, that a scripting language is just an efficient tool to write quick programs with. As for my understanding of Groovy at this point... If you were to program in Groovy, and you wan't to write a quick script, wouldn't you be forced to going back to regular java syntax (and we know how that can be convoluted compared to a scripting language) in order to do anything more complicated? For example, if I want to do some http scripting, wouldn't I just be right back at using java syntax to invoke Commons HttpClient? To me, the point of a scripting language is for quickly typed and less forced constructs. And here is another thing, it doesn't seem that there is any incentive for groovy based libraries to be developed when there are already so many good java one's out there, thus making groovy appear to be a Java dependent language with minor scripting features. So right now I am wondering if I could switch to Groovy as a scripting language or continue to use a more common scripting language such as Perl, Python or Ruby.
score: 12
tagged with: groovy
has answer: http://stackoverflow.com/a/2647629
downvote count: 0
answer count: 7
accepted answer: http://stackoverflow.com/a/2647616
favorite count: 0
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2648980
has answer: http://stackoverflow.com/a/75608503
has title: Using Groovy as a scripting language
has answer: http://stackoverflow.com/a/6421686

http://stackoverflow.com/a/2650199
has body: Compiling is just converting the source code to binary, building is compiling and linking any other files needed into the build directory
answers question: http://stackoverflow.com/q/2650168
score: 0
type: Answer

http://stackoverflow.com/q/2633483
score: 96
has body: General-purpose computing on graphics processing units (GPGPU) is a very attractive concept to harness the power of the GPU for any kind of computing. I'd love to use GPGPU for image processing, particles, and fast geometric operations. Right now, it seems the two contenders in this space are CUDA and OpenCL. I'd like to know: Is OpenCL usable yet from Java on Windows/Mac? What are the libraries ways to interface to OpenCL/CUDA? Is using JNA directly an option? Am I forgetting something? Any real-world experience/examples/war stories are appreciated.
has comment: http://stackoverflow.com/comment/2772291
tagged with: opencl
has comment: http://stackoverflow.com/comment/2660283
has comment: http://stackoverflow.com/comment/2649504
has answer: http://stackoverflow.com/a/11967701
has answer: http://stackoverflow.com/a/7677584
has comment: http://stackoverflow.com/comment/2770675
linked to: http://stackoverflow.com/q/18014327
tagged with: cuda
tagged with: gpgpu
has comment: http://stackoverflow.com/comment/2654552
has comment: http://stackoverflow.com/comment/27051993
upvote count: 97
has comment: http://stackoverflow.com/comment/2650259
has comment: http://stackoverflow.com/comment/2756531
has answer: http://stackoverflow.com/a/3307145
has answer: http://stackoverflow.com/a/2781891
has answer: http://stackoverflow.com/a/56705136
accepted answer: http://stackoverflow.com/a/3307145
answer count: 8
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2647888
has answer: http://stackoverflow.com/a/33642825
has comment: http://stackoverflow.com/comment/2652319
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/27555175
has answer: http://stackoverflow.com/a/2645182
downvote count: 1
possible better answer: http://stackoverflow.com/a/7677584
favorite count: 0
has title: Best approach for GPGPU/CUDA/OpenCL in Java?

http://stackoverflow.com/q/2754782
has answer: http://stackoverflow.com/a/10816786
has answer: http://stackoverflow.com/a/5484888
has answer: http://stackoverflow.com/a/2755714
has answer: http://stackoverflow.com/a/2755075
downvote count: 0
favorite count: 0
answer count: 4
tagged with: jbutton
type: AnsweredQuestion
tagged with: miglayout
possible better answer: http://stackoverflow.com/a/2755714
score: 1
tagged with: java
has title: Remove JButton padding in MigLayout
tagged with: look-and-feel
upvote count: 1
has body: I have a small "popup" like this: But I don't want the padding around the button, I want it to be as small as it can be with the supplied text. btn.setMargin(new Insets(1, 1, 1, 1)); panel.add(lbl, "wrap"); panel.add(btn); frame.pack(); frame.setVisible(true); At least this doesn't work... Can this be achieved on MigLayout or should I use some other layout manager for this frame.
type: Question
tagged with: padding
accepted answer: http://stackoverflow.com/a/2755075

http://stackoverflow.com/comment/13175665
type: Comment
comment on: http://stackoverflow.com/a/2786116
score: 0
has text: Thanks for posting... I just made the same silly mistake and this saved me some time.
type: AnswerComment

http://stackoverflow.com/q/2667283
has comment: http://stackoverflow.com/comment/2685770
tagged with: java-me
has answer: http://stackoverflow.com/a/2667313
linked to: http://stackoverflow.com/q/1710423
upvote count: 1
answer count: 1
tagged with: java
accepted answer: http://stackoverflow.com/a/2667313
has comment: http://stackoverflow.com/comment/2692483
type: AnsweredQuestion
tagged with: mobile
downvote count: 0
has body: i have a j2me application , it does the File IO operation, but every time it performs it , it asks user for permission. is there any way to bypass it? i heard that suppose if i make this application certified then i would be able to run it in max. secure mode to bypass such issues.
score: 1
has title: How to bypass the user confirmation in J2ME?
favorite count: 0
type: Question

http://stackoverflow.com/a/2602974
has body: The regionMatches method has a case sensitive parameter.
type: Answer
has comment: http://stackoverflow.com/comment/2612412
score: 13
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2602934
upvote count: 13
accepted answer of: http://stackoverflow.com/q/2602934

http://stackoverflow.com/a/2777676
accepted answer of: http://stackoverflow.com/q/2776786
has comment: http://stackoverflow.com/comment/2815052
score: 3
upvote count: 3
answers question: http://stackoverflow.com/q/2776786
type: AcceptedAnswer
downvote count: 0
has body: Right-click on your project in Eclipse, and select Export. Select Java->Runnable JAR File. You can then select a particular Eclipse Launch Configuration on which to base the export (i.e. the main class and the classpath used to run it), whether to extract or package the required libraries, and whether to create an ANT script (so you could build the JAR file outside of Eclipse).
type: Answer

http://stackoverflow.com/comment/21795411
type: QuestionComment
has text: I recommend you to have a look at this [excellent article](http://www.venishjoe.net/2009/11/java-string-concatenation-and.html).
comment on: http://stackoverflow.com/q/2721998
score: 1
type: Comment

http://stackoverflow.com/comment/2795726
type: AnswerComment
type: Comment
has text: I'm not sure what it does exactly. I just spotted the connection between the description in the API, your problem, and that the call was missing in your code.
comment on: http://stackoverflow.com/a/2763251
score: 0

http://stackoverflow.com/q/2606619
tagged with: java
answer count: 6
has answer: http://stackoverflow.com/a/2607073
has answer: http://stackoverflow.com/a/2606728
tagged with: mouseevent
type: Question
has answer: http://stackoverflow.com/a/2608619
upvote count: 1
has answer: http://stackoverflow.com/a/2636939
favorite count: 0
has title: Move multiple BufferedImage in Java2D?
linked to: http://stackoverflow.com/q/2590655
has body: How can I mousedrag different BufferedImages in Java2D? For instance, if I have ten or more images, how can I move that images which my mouse is over? Now I'm importing an BufferedImage with BufferedImage img = new BufferdImage(new File("filename")); And I'm painting this with Graphics2D with public void paintComponent(Graphics g) { super.paintComponent(g); g2d = (Graphics2D) g; g2d.drawImage(img, x1, y1, null); g2d.drawImage(img2, x2, y2,null); } Everytime I'm moving on a image I'm repaint()-ing the entire screen. My mousemove class is as follows class MouseMotionHandler extends MouseMotionAdapter { @Override public void mouseDragged(MouseEvent e) { x1 = e.getX() - (img.getWidth() / 2); y1 = e.getY() - (img.getHeight() / 2); repaint(); } } With this method I'm able to "drag" one picture, but what to do when I will drag more individually?
has answer: http://stackoverflow.com/a/2606722
has answer: http://stackoverflow.com/a/2606697
tagged with: java-2d
downvote count: 0
type: UnansweredQuestion
score: 1
tagged with: bufferedimage

http://stackoverflow.com/comment/2790198
has text: Oh, the *actual* problem was thus to-tal-ly *not* related to generics. You should have copypasted the exact compilation error message and chosen a better title to make that more clear.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2629786

http://stackoverflow.com/q/2634354
type: UnansweredQuestion
has body: I'm wondering if there's a java library out there that can manipulate 3gp files. Mostly I'm interested in splitting or merging existing video files. I've looked at JMF (java media framework), but it doesn't support 3gp…and FFmpeg looks promising, but it's not clear that the library allows splitting/merging of existing files. Does such a library exist?
type: Question
tagged with: video
tagged with: java
has answer: http://stackoverflow.com/a/3653695
tagged with: 3gp
answer count: 1
score: 0
has title: Splitting/Merging 3gp files using a java library
tagged with: video-processing

http://stackoverflow.com/q/2600854
upvote count: 27
type: AnsweredQuestion
tagged with: reflection
has title: How to work with varargs and reflection
has body: Simple question, how make this code working ? public class T { public static void main(String[] args) throws Exception { new T().m(); } public // as mentioned by Bozho void foo(String... s) { System.err.println(s[0]); } void m() throws Exception { String[] a = new String[]{"hello", "kitty"}; System.err.println(a.getClass()); Method m = getClass().getMethod("foo", a.getClass()); m.invoke(this, (Object[]) a); } } Output: class [Ljava.lang.String; Exception in thread "main" java.lang.IllegalArgumentException: wrong number of arguments at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597)
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/2600945
score: 27
accepted answer: http://stackoverflow.com/a/2600890
answer count: 2
downvote count: 0
tagged with: variadic-functions
has answer: http://stackoverflow.com/a/2600890
favorite count: 0
possible better answer: http://stackoverflow.com/a/2600945

http://stackoverflow.com/a/2647787
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/2663776
answers question: http://stackoverflow.com/q/2647099
upvote count: 2
accepted answer of: http://stackoverflow.com/q/2647099
has body: Try with the classpath*: prefix.
type: AcceptedAnswer
type: Answer

http://stackoverflow.com/comment/2693611
type: AnswerComment
comment on: http://stackoverflow.com/a/2674336
type: Comment
score: 0
has text: Good point. I made the same mistake of mentioning B-Tree when I meant binary tree - I'll edit my answer.

http://stackoverflow.com/a/2694658
upvote count: 4
downvote count: 0
has comment: http://stackoverflow.com/comment/2716594
has body: There are a couple of things wrong here. You have not overriden Object.equals. Use @Override public boolean equals(Object obj). There is a potential integer overflow error in compareTo. This is probably the cause of this particular error. It will upset the sorting, and hence the search may well not succeed. The compareTo method claims two instances are equal if the hash code happens to match (could be a difficult error to catch, without code review). For integer overflow issue, see question Why is my simple comparator broken?
has comment: http://stackoverflow.com/comment/2716475
score: 4
accepted answer of: http://stackoverflow.com/q/2694526
has comment: http://stackoverflow.com/comment/2716531
answers question: http://stackoverflow.com/q/2694526
type: AcceptedAnswer
type: Answer

http://stackoverflow.com/a/2667568
has comment: http://stackoverflow.com/comment/2686545
score: 6
answers question: http://stackoverflow.com/q/2667264
has comment: http://stackoverflow.com/comment/2686854
has comment: http://stackoverflow.com/comment/2719580
has body: The exact behavior here depends entirely on the JVM implementation. In spec (that is what a proper JVM implementation needs to provide you), it can happen in parallel, it can happen first before your code executes, or it can not happen at all. In practice, my observation on JVMs I have happened to observe is that it runs immediately in a separate thread. However, in some cases multiple calls spawn multiple threads, sometimes it queues the requests on one thread. The Garbage collection launched was always a "stop-the-world" type (that is it was very complete and slowed or paused the application). However, given your comment to @Chris Dail, your underlying problem isn't the behavior of a System.gc() call. Calling System.gc() can have some uses. It can be used clear memory so you can get a sense of how large the footprint of the application actually is currently. It can also be used as a strategy to ensure that a stop-the-world garbage collection happens earlier so that it "stops the world" for a shorter amount of time because there is less memory to clear. (I should note that as JVM's get more and more sophisticated this kind of thing is less and less necessary, and actually becomes counter-productive). What it does not do however, is in any way solve an OutOfMemoryError. The JVM will not give you an OutOfMemoryError until it has garbage collected to the best of its ability. Calling System.gc does not change that. If you have an OutOfMemoryError it is likely because you are holding reference to objects in ways that you don't really need, but that are preventing those Objects memory from being reclaimed.
type: AcceptedAnswer
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/2686538
upvote count: 6
accepted answer of: http://stackoverflow.com/q/2667264

http://stackoverflow.com/comment/59846665
score: 0
type: AnswerComment
type: Comment
has text: @CodeChimp If you really want to use a switch statement, there are various ways round this, e.g.: use a hash function to convert the longs to ints, build up a Map<Long, Integer> to map the longs from the DB to int constants, use Long.toString() and then switch over strings (which is supported as of JDK7)... I really wonder if not being able to switch on longs is such a stop-the-world scenario!
comment on: http://stackoverflow.com/a/2676333

http://stackoverflow.com/a/10179861
has comment: http://stackoverflow.com/comment/34567060
has comment: http://stackoverflow.com/comment/115927923
score: 133
has body: Using global static variables is not good software engineering practice. Converting an object's fields into primitive data types can be a hectic job. Using serializable is OK, but it's not performance-efficient on the Android platform. Parcelable is specifically designed for Android and you should use it. Here is a simple example: Passing custom objects between Android activities You can generate Parcelable code for you class using this site.
upvote count: 137
has comment: http://stackoverflow.com/comment/46855673
has comment: http://stackoverflow.com/comment/38768627
type: Answer
has comment: http://stackoverflow.com/comment/77807674
has comment: http://stackoverflow.com/comment/58678819
answers question: http://stackoverflow.com/q/2736389
has comment: http://stackoverflow.com/comment/36281196
has comment: http://stackoverflow.com/comment/58973327
downvote count: 4

http://stackoverflow.com/comment/2655359
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2639355
has text: What else can it be? Do I need to "save" it or something?

http://stackoverflow.com/comment/48704855
score: 1
has text: @hajder Then your only option is to use the exact type: `Collection<Thing>`. The reason for this is that you must be sure that the get method will return something that you can cast to `Thing`, and the add method accepts a `Thing`, which it can cast to the actual element type. The only type that satisfies both criteria is `Thing` itself.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2723538

http://stackoverflow.com/q/2612434
upvote count: 13
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2612613
tagged with: java
possible better answer: http://stackoverflow.com/a/2612537
has answer: http://stackoverflow.com/a/2612537
type: Question
has answer: http://stackoverflow.com/a/2612474
has title: What Are Some Prominent Real-World Applications of Java?
has answer: http://stackoverflow.com/a/2612488
accepted answer: http://stackoverflow.com/a/2612486
has answer: http://stackoverflow.com/a/2612464
has comment: http://stackoverflow.com/comment/2623414
has answer: http://stackoverflow.com/a/2612545
has answer: http://stackoverflow.com/a/2612480
has answer: http://stackoverflow.com/a/2612450
has answer: http://stackoverflow.com/a/2612641
has answer: http://stackoverflow.com/a/2612616
favorite count: 0
has comment: http://stackoverflow.com/comment/2624544
answer count: 12
has body: I'm a beginning programmer and the I&amp;CS program at our school starts us off learning Java. It seems to me like C and its spin-offs are way more prevalent in the real world. Is this true? How do expert programmers use Java for their work? To be more precise, I want to know in what situations would a programmer prefer to use Java over other languages. OpenOffice is definitely a prominent example of Java, but couldn't it have been coded using anything else?
downvote count: 2
has answer: http://stackoverflow.com/a/2612770
score: 11
has answer: http://stackoverflow.com/a/2612486

http://stackoverflow.com/a/2614484
has comment: http://stackoverflow.com/comment/101054616
type: Answer
answers question: http://stackoverflow.com/q/2614473
score: 245
upvote count: 245
has comment: http://stackoverflow.com/comment/105929806
has comment: http://stackoverflow.com/comment/34005077
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2614473
has body: This is useful if you want the currently executing method to still throw the exception while allowing resources to be cleaned up appropriately. Below is a concrete example of handling the exception from a calling method. public void yourOtherMethod() { try { yourMethod(); } catch (YourException ex) { // handle exception } } public void yourMethod() throws YourException { try { db.store(mydata); } finally { db.cleanup(); } }

http://stackoverflow.com/q/2784420
tagged with: javax.swing.text
tagged with: swing
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2784541
tagged with: java
has answer: http://stackoverflow.com/a/2784541
accepted answer: http://stackoverflow.com/a/2804120
has body: I'm experiencing an intermittent problem with a class that extends javax.swing.text.DefaultStyledDocument. This document is being sent to a printer. Most of the time the formatting of the document looks correct, but once in a while it doesn't. It looks like some of the changes in the formatting have not been applied. I took a look at the DefaultStyledDocument.styleChanged(Style style) code: /** * Called when any of this document's styles have changed. * Subclasses may wish to be intelligent about what gets damaged. * * @param style The Style that has changed. */ protected void styleChanged(Style style) { // Only propagate change updated if have content if (getLength() != 0) { // lazily create a ChangeUpdateRunnable if (updateRunnable == null) { updateRunnable = new ChangeUpdateRunnable(); } // We may get a whole batch of these at once, so only // queue the runnable if it is not already pending synchronized(updateRunnable) { if (!updateRunnable.isPending) { SwingUtilities.invokeLater(updateRunnable); updateRunnable.isPending = true; } } } } /** * When run this creates a change event for the complete document * and fires it. */ class ChangeUpdateRunnable implements Runnable { boolean isPending = false; public void run() { synchronized(this) { isPending = false; } try { writeLock(); DefaultDocumentEvent dde = new DefaultDocumentEvent(0, getLength(), DocumentEvent.EventType.CHANGE); dde.end(); fireChangedUpdate(dde); } finally { writeUnlock(); } } } Does the fact that SwingUtilities.invokeLater(updateRunnable) is called, rather than invokeAndWait(updateRunnable), mean that I can't count on my formatting changes appearing in the document before it is rendered? If that is the case, is there a way to ensure that I don't proceed with rendering until the updates have occurred?
type: Question
score: 0
answer count: 2
tagged with: swingutilities
tagged with: defaultstyleddocument
has answer: http://stackoverflow.com/a/2804120
has title: DefaultStyledDocument.styleChanged(Style style) may not run in a timely manner?

http://stackoverflow.com/q/2718742
tagged with: jsp
linked to: http://stackoverflow.com/q/1993493
tagged with: tomcat
has comment: http://stackoverflow.com/comment/2744580
favorite count: 0
has title: Problems with Tomcat server and JSP web application
has comment: http://stackoverflow.com/comment/45320015
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2718784
downvote count: 1
type: Question
tagged with: java
has body: I am running a JSP/Servlet Web application and out of nowhere we experienced some random problems that don't make any sense. I checked the catalina.out file to check the log files, and I noticed it contained some of the following messages SEVERE: Error starting static Resources java.lang.IllegalArgumentException: Invalid or unreadable WAR file : error in opening zip file INFO: validateJarFile(/home/weremo/appservers/ apache-tomcat-6.0.26/webapps /WMA/WEB-INF/lib/ servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class I am aware of what this message means, but am in the dark as to what could have caused it, or what effects it could have on the application.
score: -1
accepted answer: http://stackoverflow.com/a/2718784
has comment: http://stackoverflow.com/comment/2744605
upvote count: 0
answer count: 1

http://stackoverflow.com/a/2762137
upvote count: 181
has comment: http://stackoverflow.com/comment/2794298
has comment: http://stackoverflow.com/comment/2794339
answers question: http://stackoverflow.com/q/2762093
has comment: http://stackoverflow.com/comment/2794386
has comment: http://stackoverflow.com/comment/2794319
has comment: http://stackoverflow.com/comment/2794446
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2762093
downvote count: 0
has comment: http://stackoverflow.com/comment/2794341
has comment: http://stackoverflow.com/comment/2794375
has comment: http://stackoverflow.com/comment/2794325
has body: EDIT Here are two versions. One using ArrayList and other using HashSet Compare them and create your own version from this, until you get what you need. This should be enough to cover the: P.S: It is not a school assignment :) So if you just guide me it will be enough part of your question. continuing with the original answer: You may use a java.util.Collection and/or java.util.ArrayList for that. The retainAll method does the following: Retains only the elements in this collection that are contained in the specified collection see this sample: import java.util.Collection; import java.util.ArrayList; import java.util.Arrays; public class Repeated { public static void main( String [] args ) { Collection listOne = new ArrayList(Arrays.asList("milan","dingo", "elpha", "hafil", "meat", "iga", "neeta.peeta")); Collection listTwo = new ArrayList(Arrays.asList("hafil", "iga", "binga", "mike", "dingo")); listOne.retainAll( listTwo ); System.out.println( listOne ); } } EDIT For the second part ( similar values ) you may use the removeAll method: Removes all of this collection's elements that are also contained in the specified collection. This second version gives you also the similar values and handles repeated ( by discarding them). This time the Collection could be a Set instead of a List ( the difference is, the Set doesn't allow repeated values ) import java.util.Collection; import java.util.HashSet; import java.util.Arrays; class Repeated { public static void main( String [] args ) { Collection&lt;String&gt; listOne = Arrays.asList("milan","iga", "dingo","iga", "elpha","iga", "hafil","iga", "meat","iga", "neeta.peeta","iga"); Collection&lt;String&gt; listTwo = Arrays.asList("hafil", "iga", "binga", "mike", "dingo","dingo","dingo"); Collection&lt;String&gt; similar = new HashSet&lt;String&gt;( listOne ); Collection&lt;String&gt; different = new HashSet&lt;String&gt;(); different.addAll( listOne ); different.addAll( listTwo ); similar.retainAll( listTwo ); different.remo…
has comment: http://stackoverflow.com/comment/2794384
type: Answer
has comment: http://stackoverflow.com/comment/2794416
score: 181

http://stackoverflow.com/q/2626953
tagged with: java
has comment: http://stackoverflow.com/comment/2639987
has comment: http://stackoverflow.com/comment/2639997
has body: Possible Duplicate: What are major differences between C# and Java? I believe it was Eric Sink that said "C# is Java done right". I am pretty familiar with Java, and thought I could try to learn some C#. As I understand it, these two OO-languages are very similar, so what are the actual differences (if any)?
upvote count: 7
downvote count: 1
has answer: http://stackoverflow.com/a/2627054
possible better answer: http://stackoverflow.com/a/2627007
favorite count: 0
has answer: http://stackoverflow.com/a/2627051
has comment: http://stackoverflow.com/comment/2640005
has comment: http://stackoverflow.com/comment/2639994
answer count: 4
accepted answer: http://stackoverflow.com/a/2626956
type: AnsweredQuestion
score: 6
has answer: http://stackoverflow.com/a/2627007
duplicate of: http://stackoverflow.com/q/295224
has comment: http://stackoverflow.com/comment/2640111
has answer: http://stackoverflow.com/a/2626956
type: Question
tagged with: c#
linked to: http://stackoverflow.com/q/295224
has title: What are the main differences between C# and Java?

http://stackoverflow.com/comment/42472305
has text: @Ingo "Who is mandating that making a new list from a cat and a list of dogs actually changes the list of dogs?" This is inherent in the nature of references. In the code snippet above, the variables named `dogs` and `animals` refer to _the same object_.
score: 1
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2745301

http://stackoverflow.com/a/2746489
answers question: http://stackoverflow.com/q/2746386
has comment: http://stackoverflow.com/comment/2775961
upvote count: 4
type: AcceptedAnswer
downvote count: 0
has body: Place this at the top of your batch file: setlocal enabledelayedexpansion Then inside the for loop, replace %_classpath% with !_classpath! Without delayed expansion enabled, %_classpath% gets expanded once, at the beginning of your for loop. [Edit] In response to a comment, here is a full code-listing @echo off setlocal enabledelayedexpansion set _classpath=. for %%i in (%1/lib/*.*) do ( set _classpath=!_classpath!;%%i ) echo %_classpath% pause
type: Answer
score: 4
has comment: http://stackoverflow.com/comment/2776176
accepted answer of: http://stackoverflow.com/q/2746386

http://stackoverflow.com/a/2709635
type: AcceptedAnswer
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2709553
has body: Femaref's answer is pretty good; I'd like to expand on it. Operators are (usually) hard-wired into the language: Stuff like +, -, * and / are usually directly translated by the compiler into machine language (if that's the underlying mechanism for that language system) without the need to explicitly call a method in a library. This is how it is/was in C, for instance. If those operators weren't defined in the language, you'd have to code plus(2,2) instead of 2 + 2. Operators defined in the language come with the benefit of built-in priority. * and / usually have higher priority than + and -, so you can write 3 * 3 + 4 * 4 and get 25, not 52 or 84 that you'd get without such priorization or different priorities. The line becomes a little grey when operators are recognized by the compiler but still delegated to a library. Complex numbers in FORTRAN may be an example: Often the compiler will not bother to directly compile complex operations into machine code but will generate machine code to call a library. Most people think only of the arithmetic operators, like +, - and so forth. But you could also consider square brackets ( [ ] ) an operator for array indexing, for example. Some languages let you overload their operators, so you can substitute a call to a method for whatever the operator normally does. Most languages don't let you define your own operators that support the same mechanisms as the built-in ones. Scala is an exception here; you can define a +++ operator if you like and have it hook up to a method you provide. Some people think operator overloading makes code harder to understand, so the jury is still out about whether this is a good idea.
score: 1
accepted answer of: http://stackoverflow.com/q/2709553
upvote count: 1

http://stackoverflow.com/a/2710317
upvote count: 1
answers question: http://stackoverflow.com/q/2710269
downvote count: 3
has comment: http://stackoverflow.com/comment/2734849
score: -2
type: Answer
has body: the first method won't work. You can't upcast the clone of the parent class. It would be an instance of the parent class. A clone = (A)super.clone(); // can't do this

http://stackoverflow.com/a/2631637
score: 1
has comment: http://stackoverflow.com/comment/2645077
answers question: http://stackoverflow.com/q/2631389
has comment: http://stackoverflow.com/comment/2645005
accepted answer of: http://stackoverflow.com/q/2631389
upvote count: 1
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2645010
has comment: http://stackoverflow.com/comment/2646818
type: Answer
has comment: http://stackoverflow.com/comment/2646541
downvote count: 0
has body: It seems like you get stuck against a wall because you are oscillating around distance 0.6. For instance: Drive angling toward wall, eventually reaching &lt; 0.6f Rotate away from wall, stop when > 0.6f. In other words 0.6000001f (for instance) Resume normal trajectory. Almost immediately &lt; 0.6f Goto 2 You will get stuck angling slightly toward and slightly away from the wall. You need a buffer zone. Once you get within MIN_DIS distance from the wall you need to rotate away until you reach some BUFFER_DIS from the wall where BUFFER_DIS > MIN_DIS by a fair amount. EDIT: Looks like you have a few issues. First you are checking if the laser_data is close to a wall, and if it is you are rotating toward the wall. You need to check if it is NOT close to a wall, and rotate toward it. Second, you are in a very tight while loop, adjusting wheel speeds. This will probably result in bad things. You need to call a trackWall() function when you are too far from the wall, which will poll laser.isDataReady() in a separate loop. Either that, or you need a state-machine in your main polling loop. If not, you are pointlessly adjusting wheel speed with stale laser data. Third, can you guarantee that the wall will always be within 0.6f? If not, your robot will spin infinitely if it gets to far from the wall.

http://stackoverflow.com/a/2716424
has body: Change "CHARACTER VARYING" to "varchar". The command-line psql client accepts the type name "CHARACTER VARYING", but the JDBC driver does not. The source for org.postgresql.jdbc2.TypeInfoCache contains a list of accepted type names. Consider part of the ambiguously-worded contract for createArrayOf(): The typeName is a database-specific name which may be the name of a built-in type, a user-defined type or a standard SQL type supported by this database. I always assumed driver implementors interpret the phrases "database-specific name" and "supported by this database" to mean "accept whatever you want". But maybe you could file this as a bug against the Postgres JDBC driver. Good luck.
score: 8
type: Answer
downvote count: 0
upvote count: 8
answers question: http://stackoverflow.com/q/2711224
accepted answer of: http://stackoverflow.com/q/2711224
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2742242

http://stackoverflow.com/a/11555106
answers question: http://stackoverflow.com/q/2697341
upvote count: 16
has comment: http://stackoverflow.com/comment/114342491
has comment: http://stackoverflow.com/comment/28807476
type: Answer
has comment: http://stackoverflow.com/comment/62937428
has body: Run your unit test to a breakpoint, then in the Debug perspective of Eclipse, open the Display view (Window, Show View, Display) and enter org.hsqldb.util.DatabaseManagerSwing.main(new String[] { "--url", "jdbc:hsqldb:mem:testdb", "--noexit" }); (as per dimdm's post), highlight it, right-click and choose Execute.
downvote count: 0
score: 16
has comment: http://stackoverflow.com/comment/121066636
has comment: http://stackoverflow.com/comment/85837159

http://stackoverflow.com/comment/56903372
type: QuestionComment
score: 8
comment on: http://stackoverflow.com/q/2758224
has text: Assertions can be turned off. This mean you are not guaranteed that they will "fire" in production, which is where you need it most.
type: Comment

http://stackoverflow.com/a/2697699
type: Answer
score: 2
upvote count: 2
has body: You can use apache collections, they provide a bunch of handy features including predicate: public class MyPredicate implements Predicate { public boolean evaluate(Object input) { return (MyObject).name = "myName"; } } then you can test your collection using : CollectionUtils.find(myCollection, new MyPredicate()); This will return the first object matching the predicate or null if none matches it.
answers question: http://stackoverflow.com/q/2697630
downvote count: 0

http://stackoverflow.com/a/2615573
has body: It looks like the JVM tries to unbox the second null to float instead of Float, thus NullPointerException. Hit it myself once. My take is that the second if does it because the true part of the first if evaluates as a float, not a Float. After giving it a second thought, I think this a way of Java telling you that you are doing something strange. Just don't nest ternary ifs and you will be fine :-)
type: Answer
answers question: http://stackoverflow.com/q/2615498
has comment: http://stackoverflow.com/comment/2627090
has comment: http://stackoverflow.com/comment/2627395
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/2627088
downvote count: 0

http://stackoverflow.com/a/2655611
answers question: http://stackoverflow.com/q/2655580
upvote count: 1
score: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/2672263
type: Answer
has body: The JID is composed of user@domain/resource. The resource is optional, and provides more information about how the user is communicating (e.g. desktop or client app). EDIT: See the Java JID class
has comment: http://stackoverflow.com/comment/2672450
has comment: http://stackoverflow.com/comment/2672324

http://stackoverflow.com/q/2678748
has body: There is an SAP server that has some webservices I need to use, so I am trying to use wsimport to generate the client stubs. I don't want to find all the wsdls and schemas that are referenced and modify them to do it locally, as that isn't sustainable, if they service should change. So, how can I use wsimport to fetch a wsdl and generate the client stubs when the server is using Windows Integrated Authentication, where even the wsdl requires credentials.
score: 1
tagged with: code-generation
upvote count: 1
tagged with: windows-authentication
type: Question
has title: Generate webservice soap client from wsdl when server using Windows Integrated Authentication
tagged with: java
tagged with: webservice-client
has answer: http://stackoverflow.com/a/2989325
answer count: 1
downvote count: 0
favorite count: 0
type: UnansweredQuestion

http://stackoverflow.com/comment/2741439
comment on: http://stackoverflow.com/q/2715611
score: 0
has text: Is the setter for all mapped fields called? that is strange!
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2776990
has answer: http://stackoverflow.com/a/2777411
downvote count: 0
tagged with: jsp
has title: Can I send a POST form in an encoding other than of its body?
favorite count: 0
has answer: http://stackoverflow.com/a/2777498
type: AnsweredQuestion
score: 1
accepted answer: http://stackoverflow.com/a/2777482
tagged with: java
possible better answer: http://stackoverflow.com/a/2777411
tagged with: web-applications
upvote count: 1
type: Question
has body: I have an HTML page that looks like: &lt;HTML&gt; &lt;meta http-equiv='Content-Type' content='text/html; charset=gb2312'&gt; &lt;BODY onload='document.forms[0].submit();'&gt; &lt;form name="form" method="post" action="/path/to/some/servlet"&gt; &lt;input type="hidden" name="username" value="麗安"&gt; &lt;!-- UTF-8 characters --&gt; &lt;/form&gt; &lt;/BODY&gt; &lt;/HTML&gt; As you can see, the content of this page is UTF-8, but I need to send it with GB2312 character encoding, as the servlet that I am sending this page to expects from me GB2312. Is this a valid scenario? Because in the servlet, I couldn't retrieve these Chinese characters back using a filter that sets the character encoding to GB2312! I've created a sample Servlet: package org.daz; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class EncodingServlet extends HttpServlet { private static final long serialVersionUID = 1L; private static final String ENCODING = "GB2312"; protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { setCharacterEncoding(request, response); String username = request.getParameter("username"); System.out.println(username); } private void setCharacterEncoding(HttpServletRequest request, HttpServletResponse response)throws IOException{ request.setCharacterEncoding(ENCODING); response.setCharacterEncoding(ENCODING); } } The output is: 楹��
tagged with: encoding
has answer: http://stackoverflow.com/a/2777482
tagged with: servlets
answer count: 3

http://stackoverflow.com/q/2780129
upvote count: 45
downvote count: 0
has title: Get enum by its inner field
has answer: http://stackoverflow.com/a/2780740
favorite count: 0
has comment: http://stackoverflow.com/comment/2818302
linked to: http://stackoverflow.com/q/64415585
answer count: 5
has body: Have enum with inner fields, kind of map. Now I need to get enum by its inner field. Wrote this: package test; /** * Test enum to test enum =) */ public enum TestEnum { ONE(1), TWO(2), THREE(3); private int number; TestEnum(int number) { this.number = number; } public TestEnum findByKey(int i) { TestEnum[] testEnums = TestEnum.values(); for (TestEnum testEnum : testEnums) { if (testEnum.number == i) { return testEnum; } } return null; } } But it's not very efficient to look up through all enums each time I need to find appropriate instance. Is there any other way to do the same?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/62530179
linked to: http://stackoverflow.com/q/507602
tagged with: java
has answer: http://stackoverflow.com/a/2780170
possible better answer: http://stackoverflow.com/a/2780740
linked to: http://stackoverflow.com/q/335311
accepted answer: http://stackoverflow.com/a/2780170
type: Question
tagged with: enums
has answer: http://stackoverflow.com/a/2780172
has comment: http://stackoverflow.com/comment/66368805
has answer: http://stackoverflow.com/a/2780158
score: 45
has comment: http://stackoverflow.com/comment/2818115

http://stackoverflow.com/comment/117137158
type: AnswerComment
comment on: http://stackoverflow.com/a/14858183
type: Comment
has text: System.setProperty("user.timezone", "EST"); this is working fine. Thank you
score: 1

http://stackoverflow.com/comment/2658373
has text: You're probably going to have to provide more context than this. Answering generally, however, it's generally a good idea to have your database access---and as much business logic as possible---be on the server side, particularly so the less you trust your users. As far as "properties file", I don't know what you're talking about.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2643384

http://stackoverflow.com/comment/2742895
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2717005
has text: Just to confirm, it's already all within a single transaction.
type: AnswerComment

http://stackoverflow.com/a/2703527
has comment: http://stackoverflow.com/comment/2730355
type: Answer
has comment: http://stackoverflow.com/comment/2731768
downvote count: 1
score: 2
has comment: http://stackoverflow.com/comment/2731396
upvote count: 3
has body: asserts are used for inserting checks in your code that will fail very loudly during development and be ignored during production (determined by a flag). This has been inherited from the C world, but has not caught on due to the more systematic approach given by e.g. jUnit where you have independent test suites instead which can be run at will. I would recommend you look into Test Driven Development using e.g. junit before investigating too much time in asserts. You will most likely find, like me, that asserts are less useful than unit tests.
has comment: http://stackoverflow.com/comment/2727529
answers question: http://stackoverflow.com/q/2703480
has comment: http://stackoverflow.com/comment/2731633

http://stackoverflow.com/q/2599222
has title: Eclipse doesn't build
accepted answer: http://stackoverflow.com/a/2599575
has answer: http://stackoverflow.com/a/2599247
tagged with: eclipse
score: 0
answer count: 2
possible better answer: http://stackoverflow.com/a/2599247
has body: A previously working Ecplise now gives me the error Java Virtual Machine Launcher Could not find main class: testing2. Program will exist. testing2 is my class and a source file exists but Ecplise doesn't seem to build the .class file. Maybe I hit the wrong hotkey and changed accidently some setting?
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2608093
tagged with: java
has answer: http://stackoverflow.com/a/2599575
type: Question

http://stackoverflow.com/a/2641509
score: -1
has comment: http://stackoverflow.com/comment/2658298
downvote count: 1
has body: This will lead you to Integer overflow because int types goes from approx. -2E7 to 2E7
type: Answer
answers question: http://stackoverflow.com/q/2641262
upvote count: 0

http://stackoverflow.com/a/2652503
has body: Also pay attention to the JGraphT library in Java.
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2652404
type: Answer
score: 1
upvote count: 1
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2652404

http://stackoverflow.com/q/2660295
has body: I'm getting a compiler error for this line: Collections.sort(terms, new QuerySorter_TFmaxIDF(myInteger)); My customized Comparator is pretty basic; here's the signature and constructor: public class QuerySorter_TFmaxIDF implements Comparator&lt;Term&gt;{ private int numberOfDocs; QuerySorter_TFmaxIDF(int n){ super(); numberOfDocs = n; } } Is there an error because I'm passing an argument into the Comparator? I need to pass an argument...
has title: Java Collections Sort not accepting comparator constructor with arg
has answer: http://stackoverflow.com/a/2660518
type: AnsweredQuestion
downvote count: 0
possible better answer: http://stackoverflow.com/a/2660306
score: 1
has comment: http://stackoverflow.com/comment/2677473
has comment: http://stackoverflow.com/comment/2678714
has answer: http://stackoverflow.com/a/2660306
tagged with: collections
type: Question
tagged with: java
tagged with: comparator
answer count: 3
upvote count: 1
has answer: http://stackoverflow.com/a/2660533
accepted answer: http://stackoverflow.com/a/2660533
tagged with: sorting
favorite count: 0

http://stackoverflow.com/comment/2813955
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2766521
has text: If you have to implement IOFileFilter.accept(File,String), then why dont you just put a call back to accept(File) from it?
score: 0

http://stackoverflow.com/comment/2819358
has text: @Ukko, the only load on the system apart from the server/clients (which is stable) was the VNC server I was using from work when checking out the situation and some misc. background apps (this is your standard home workstation, mostly idle).
type: QuestionComment
score: 0
type: Comment
comment on: http://stackoverflow.com/q/2783915

http://stackoverflow.com/comment/2788198
type: Comment
comment on: http://stackoverflow.com/a/2756754
score: 0
type: AnswerComment
has text: From my perspective this is a little dumb. The programming language shouldn't take care of this kind of errors. But I understand the issue now. Thank you.

http://stackoverflow.com/a/2672412
type: AcceptedAnswer
downvote count: 0
type: Answer
upvote count: 19
has comment: http://stackoverflow.com/comment/74551490
score: 19
answers question: http://stackoverflow.com/q/2672399
has comment: http://stackoverflow.com/comment/2695635
has body: Local variables automatically cease to exist when the execution of the block in which they are declared completes. { int a = some_initialisation_value; .... } // a automatically vanishes here.
accepted answer of: http://stackoverflow.com/q/2672399

http://stackoverflow.com/comment/2785512
score: 0
type: Comment
has text: *I don't want to use JSTL EL* Why not? Is it just ignorance?
type: QuestionComment
comment on: http://stackoverflow.com/q/2754272

http://stackoverflow.com/q/2661126
has answer: http://stackoverflow.com/a/2661133
tagged with: diacritics
favorite count: 0
linked to: http://stackoverflow.com/q/14998726
has body: With the help of tucuxi from the existing post Java remove HTML from String without regular expressions I have built a method that will parse out any basic HTML tags from a string. Sometimes, however, the original string contains html hexadecimal characters like &amp;#x00E9 (which is an accented e). I have started to add functionality which will translate these escaped characters into real characters. You're probably asking: Why not use regular expressions? Or a third party library? Unfortunately I cannot, as I am developing on a BlackBerry platform which does not support regular expressions and I have never been able to successfully add a third party library to my project. So, I have gotten to the point where any &amp;#x00E9 is replaced with "e". My question now is, how do I add an actual 'accented e' to a string? Here is my code: public static String removeHTML(String synopsis) { char[] cs = synopsis.toCharArray(); String sb = new String(); boolean tag = false; for (int i = 0; i &lt; cs.length; i++) { switch (cs[i]) { case '&lt;': if (!tag) { tag = true; break; } case '&gt;': if (tag) { tag = false; break; } case '&amp;': char[] copyTo = new char[7]; System.arraycopy(cs, i, copyTo, 0, 7); String result = new String(copyTo); if (result.equals("&amp;#x00E9")) { sb += "e"; } i += 7; break; default: if (!tag) sb += cs[i]; } } return sb.toString(); } Thanks!
possible better answer: http://stackoverflow.com/a/2661630
tagged with: http://stackoverflow.com/tag/html
accepted answer: http://stackoverflow.com/a/2661135
has answer: http://stackoverflow.com/a/2661630
answer count: 4
tagged with: parsing
tagged with: character
has comment: http://stackoverflow.com/comment/2678395
downvote count: 1
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/2488967
upvote count: 5
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/51211964
has title: Java how can I add an accented "e" to a string?
score: 4
has answer: http://stackoverflow.com/a/2661135

http://stackoverflow.com/a/2650088
has comment: http://stackoverflow.com/comment/2666180
has comment: http://stackoverflow.com/comment/2666149
answers question: http://stackoverflow.com/q/2649975
type: Answer
has comment: http://stackoverflow.com/comment/2666166
score: 5
accepted answer of: http://stackoverflow.com/q/2649975
upvote count: 5
downvote count: 0
has comment: http://stackoverflow.com/comment/2666138
has body: Try this: "(?&lt;=[.!?])\\s+" This uses lookarounds to match \\s+ preceded by [.!?]. If you want to remove the punctuations as well, then just include it as part of the match: "[.!?]+\\s+" This will split "ORLY!?!? LOL" into "ORLY" and "LOL"
has comment: http://stackoverflow.com/comment/2666185
type: AcceptedAnswer

http://stackoverflow.com/comment/2795951
score: 2
comment on: http://stackoverflow.com/a/2763462
type: AnswerComment
has text: Nah, that couldn't cause an AbstractMethodError.
type: Comment

http://stackoverflow.com/a/2774365
has body: I think the best thing you can do is using a normalizer that splits unicode characters with accents into two separate character. Java includes this in class Normalizer, see here. This, for example, will split U+00C1 LATIN CAPITAL LETTER A WITH ACUTE into U+0041 LATIN CAPITAL LETTER A U+0301 COMBINING ACUTE ACCENT and will do this for every character that has accents or other diacritical mark (http://en.wikipedia.org/wiki/Diacritic). Then you can check if the resulting CharSequence has some of the accents character (and this will imply hard coding them) or simply check if the normalized version is equal to the starting one, this will imply that there isn't any character that has been decomposed. Java Normalizer already has this facility in isNormalized(CharSequence src, Normalizer.Form form), but you should check the various forms available to see if there's one suitable for your needs. EDIT: if you just need basic accent supports (like just è é à ò ì ù) you can just go with oedo option, if you need full support for all the existing accents it would be crazy to hard code them all..
upvote count: 14
score: 14
answers question: http://stackoverflow.com/q/2774320
downvote count: 0
has comment: http://stackoverflow.com/comment/2808412
type: Answer

http://stackoverflow.com/q/2687103
has answer: http://stackoverflow.com/a/2687252
has comment: http://stackoverflow.com/comment/2707692
type: AnsweredQuestion
tagged with: java.util.scanner
has comment: http://stackoverflow.com/comment/2707734
upvote count: 2
has comment: http://stackoverflow.com/comment/2707700
has body: I dont know how to describe it well, but i will try. Ok, i want to be able to build my java program so that when it opens, it will look and work exactly as it does in the console. So it reads the Scanner class and prints normally, and does everything it would do if it was in the console. Ive looked around for this and havent found anything. I can make a gui java program fairly easily, but i would rather have a terminal, console like program, that works exactly as the java console, thanks.
has title: How to build your non-gui Java program into a console program
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/3999098
has answer: http://stackoverflow.com/a/2687124
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/2707697
has answer: http://stackoverflow.com/a/68862882
tagged with: jar
has comment: http://stackoverflow.com/comment/2707717
favorite count: 0
tagged with: console
accepted answer: http://stackoverflow.com/a/2687124
possible better answer: http://stackoverflow.com/a/2687252
tagged with: terminal
answer count: 3

http://stackoverflow.com/a/2612996
answers question: http://stackoverflow.com/q/2612976
downvote count: 6
has comment: http://stackoverflow.com/comment/2624354
has comment: http://stackoverflow.com/comment/44856146
has comment: http://stackoverflow.com/comment/2624917
accepted answer of: http://stackoverflow.com/q/2612976
has comment: http://stackoverflow.com/comment/3448044
has body: You can do it either recursively or iteratively (looping). Iteratively: static String reverseMe(String s) { StringBuilder sb = new StringBuilder(); for(int i = s.length() - 1; i &gt;= 0; --i) sb.append(s.charAt(i)); return sb.toString(); } Recursively: static String reverseMe(String s) { if(s.length() == 0) return ""; return s.charAt(s.length() - 1) + reverseMe(s.substring(0,s.length()-1)); }
has comment: http://stackoverflow.com/comment/13490228
type: AcceptedAnswer
score: 50
has comment: http://stackoverflow.com/comment/76884883
type: Answer
upvote count: 56

http://stackoverflow.com/q/2746997
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/3059800
tagged with: jpa
score: 0
answer count: 1
has title: Strange compilation error - GAS3 generated class
tagged with: graniteds
accepted answer: http://stackoverflow.com/a/3059800
has body: I am pretty new to GraniteDS..So far I have been able to successfully configure it to work with my remote java services as well as generate the equivalent AS3 files from my POJO's. But I am getting this strange error while building one of the classes using GAS3 [ERROR] C:\TestGDS_All\TestGDS-flex-remoteobjects\target\generated-sources\com\mycompany\TestGDS\masterdata\model\TankGradesMlBas e.as:[77,29] Syntax error: expecting identifier before use. public function set use(value:String):void { [ERROR] C:\TestGDS_All\TestGDS-flex-remoteobjects\target\generated-sources\com\mycompany\TestGDS\masterdata\model\TankGradesMlBas e.as:[77,52] Syntax error: expecting leftparen before leftbrace. public function set use(value:String):void { [ERROR] C:\TestGDS_All\TestGDS-flex-remoteobjects\target\generated-sources\com\mycompany\TestGDS\masterdata\model\TankGradesMlBas e.as:[77,52] Syntax error: expecting identifier before leftbrace. public function set use(value:String):void { [ERROR] C:\TestGDS_All\TestGDS-flex-remoteobjects\target\generated-sources\com\mycompany\TestGDS\masterdata\model\TankGradesMlBas e.as:[77,52] Syntax error: expecting rightparen before leftbrace. public function set use(value:String):void { [ERROR] C:\TestGDS_All\TestGDS-flex-remoteobjects\target\generated-sources\com\mycompany\TestGDS\masterdata\model\TankGradesMlBas e.as:[80,29] Syntax error: expecting identifier before use. public function get use():String { [ERROR] C:\TestGDS_All\TestGDS-flex-remoteobjects\target\generated-sources\com\mycompany\TestGDS\masterdata\model\TankGradesMlBas e.as:[80,42] Syntax error: expecting leftparen before leftbrace. public function get use():String { [ERROR] C:\TestGDS_All\TestGDS-flex-remoteobjects\target\generated-sources\com\mycompany\TestGDS\masterdata\model\TankGradesMlBas e.as:[80,42] Syntax error: expecting identifier before leftbrace. public function get use():String { [ERROR] C:\TestGDS_All\TestGDS-flex-remoteobjects\target\generated-sources\com\mycompany\TestGD…
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2777055

http://stackoverflow.com/comment/20331314
type: AnswerComment
type: Comment
score: 16
has text: @JonSkeet - Of course, but who is mandating that making a new list from a cat and a list of dogs actually changes the list of dogs? This is an arbitrary implementation decision in Java. One that goes counter to logic and intuition.
comment on: http://stackoverflow.com/a/2745301

http://stackoverflow.com/a/2644508
downvote count: 0
has body: Have a look at http://www.geonames.org
upvote count: 8
answers question: http://stackoverflow.com/q/2644477
type: Answer
has comment: http://stackoverflow.com/comment/12097300
score: 8

eofexception
tags question: http://stackoverflow.com/q/2599284
tags question: http://stackoverflow.com/q/2666040
type: Tag
tag name: eofexception

http://stackoverflow.com/comment/53197102
type: AnswerComment
score: 0
type: Comment
has text: Out of curiosity how does this work for odd numbers? Can't hare still pass the turtle on odd length linked lists?
comment on: http://stackoverflow.com/a/3301796

http://stackoverflow.com/q/2746598
tagged with: jsp
answer count: 16
accepted answer: http://stackoverflow.com/a/2746755
has title: Alternatives to JSP for Spring MVC view layer
has answer: http://stackoverflow.com/a/8977522
has answer: http://stackoverflow.com/a/2746662
favorite count: 0
linked to: http://stackoverflow.com/q/5913373
has answer: http://stackoverflow.com/a/5183563
tagged with: spring
has answer: http://stackoverflow.com/a/2746799
has answer: http://stackoverflow.com/a/17814674
tagged with: spring-mvc
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/10823563
has answer: http://stackoverflow.com/a/2747251
has body: I'm looking to create a new app from scratch and will probably use Spring MVC and possibly Spring Web Flow. The projects created by Spring Roo use Spring MVC and optionally Web Flow. What are some good alternatives for view technology, or is JSP with Spring and JSTL taglibs and jQuery the way to go?
tagged with: java
has answer: http://stackoverflow.com/a/30680076
has answer: http://stackoverflow.com/a/2747288
has answer: http://stackoverflow.com/a/8976843
has answer: http://stackoverflow.com/a/12623777
has comment: http://stackoverflow.com/comment/100379417
has answer: http://stackoverflow.com/a/12965842
possible better answer: http://stackoverflow.com/a/11021458
type: Question
has answer: http://stackoverflow.com/a/11021458
upvote count: 80
has answer: http://stackoverflow.com/a/2746755
has answer: http://stackoverflow.com/a/29895662
has comment: http://stackoverflow.com/comment/66370312
has comment: http://stackoverflow.com/comment/9275178
score: 80
has answer: http://stackoverflow.com/a/2746730
downvote count: 0

http://stackoverflow.com/comment/2748772
has text: I'm a big fan of google collections. But I don't see any advantages which google collections can give in this particular example. There will be one more project-dependency, more lines of code, more complicated code, almost sure that it'll be slower. And no any pros.
type: Comment
comment on: http://stackoverflow.com/a/2722434
type: AnswerComment
score: 0

http://stackoverflow.com/a/55720911
score: 0
answers question: http://stackoverflow.com/q/2751073
type: Answer
has body: const convertMinutesToDays = (minutes) =&gt; { let hours let days let restMinutes const onedayMinutes = 1440 //24*60 if(minutes &lt; 60){ return `${minutes} Minutes` }else if(minutes &gt; 60 &amp;&amp; minutes &lt; onedayMinutes){ hours = Math.floor(minutes/60) restMinutes = minutes%60 return `${hours} Hours ${restMinutes} Minutes` }else{ days = Math.floor((minutes/60)/24) restMinutes = minutes % onedayMinutes hours = Math.floor(restMinutes/60) restMinutes = restMinutes % 60 return `${days} Days ${hours} Hours ${restMinutes} Minutes` } }

http://stackoverflow.com/comment/88914079
type: Comment
comment on: http://stackoverflow.com/a/2654050
has text: FYI, the 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: AnswerComment
score: 0

http://stackoverflow.com/comment/2788328
score: 0
type: Comment
has text: Ok. Note that I changed `[0-9A-Fa-f]*` to `[0-9A-Fa-f]+`. Don't forget that `*` also matches 0 characters. That is `^\\s*[0-9A-Fa-f]*\\s*$` matches the empty line (in which `\\s*`, `[0-9A-Fa-f]*`, and `\\s*` all correspond to the empty string. `+` means, "at least one character", which may be closer to what you want.
comment on: http://stackoverflow.com/a/2756809
type: AnswerComment

http://stackoverflow.com/q/2761823
has answer: http://stackoverflow.com/a/2761887
has title: How can I implement a download rate limited in Java?
favorite count: 0
upvote count: 3
has answer: http://stackoverflow.com/a/2761857
answer count: 4
tagged with: download
downvote count: 0
tagged with: rate
possible better answer: http://stackoverflow.com/a/2761887
has comment: http://stackoverflow.com/comment/2793902
tagged with: limit
type: AnsweredQuestion
score: 3
has answer: http://stackoverflow.com/a/2761860
tagged with: network-programming
has body: I'm going to implement a (simple) downloader application in Java as a personal exercise. It is going to run several jobs in different threads, in a way that I will be downloading a few files at the same time at all times during execution. I want to be able to define a download rate limit that is shared between all the download jobs, but I don't know how to do it even for a single download task. How should I go about doing this? What are the solutions I should try implementing? Thanks.
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/2761888
accepted answer: http://stackoverflow.com/a/2761888

http://stackoverflow.com/a/2623419
has body: Theoretically, with 3 boolean arrays you'll need to do: firstState[n] = false; secondState[n] = true; thirdState[n] = false; every time when you want to change n-th element state. Here you can see 3 taking element by index operations and 3 assignment operations. With 1 byte array you'll need: elements[n] = 1; It's more readable and 3 times faster. And one more advantage of this solution it that you can easily add as many new states as you want (when with boolean arrays you'll need to introduce new arrays). But I don't think you'll ever see the performance difference. UPD: actually I'd make it more java way (not looking that you don't find easy ways) and use array of enums. This will make it much more clear and will give you some flexibility (maybe in future you'll decide that oop is not so bad thing): enum ElementState { FIRST, SECOND, THIRD; } ElementState[] elementStates = new ElementState[N]; ... elementStates[i] = ElementState.FIRST;
type: Answer
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/2623366
upvote count: 2

http://stackoverflow.com/q/2693860
answer count: 5
has answer: http://stackoverflow.com/a/31715233
has answer: http://stackoverflow.com/a/2693920
has answer: http://stackoverflow.com/a/2693903
upvote count: 3
type: UnansweredQuestion
tagged with: stack
tagged with: java
linked to: http://stackoverflow.com/q/2168803
tagged with: queue
type: Question
score: 3
has title: Java - sorted stack
tagged with: sorting
has answer: http://stackoverflow.com/a/2694103
has comment: http://stackoverflow.com/comment/2715600
downvote count: 0
has answer: http://stackoverflow.com/a/8229117
favorite count: 0
has comment: http://stackoverflow.com/comment/2716458
has comment: http://stackoverflow.com/comment/2715566
has body: I need a sorted stack. I mean, the element removed from the stack must be the one with great priority. Stack dimension varies a lot (becomes bigger very fast). I need also to search elements in that stack. Does Java give some good implementation for this? What class or algorithm do you suggest for this? I'm using a PriorityQueue right now which I consider reasonable except for searching, so I'm wondering if I can use something better. I also need to remove elements! In summary: I need to maintain a sorted stack/queue, get the element with greater priority fast and also remove elements as fast as possible

http://stackoverflow.com/comment/137096306
type: AnswerComment
comment on: http://stackoverflow.com/a/18741740
type: Comment
has text: See also https://stackoverflow.com/a/77764610/227779 for more details about the Apache Commons `ObjectUtils` approach vs other methods (particularly if you are using Java 9, and are fine with exceptions if all values are `null`)
score: 0

http://stackoverflow.com/a/2619671
score: 3
upvote count: 3
answers question: http://stackoverflow.com/q/2619643
has body: You mean define, not initialize. The problem you're having (after that pretty radical edit) is you're defining a constructor that doesn't initialize a final variable, which Java doesn't allow -- all finals need to be initialized by the time the instance is finished constructing. Either initialize it in your constructor, or make it non-final
downvote count: 0
has comment: http://stackoverflow.com/comment/2631891
type: Answer

http://stackoverflow.com/comment/81370630
score: 0
has text: @DN1 feel free to improve it
type: AnswerComment
comment on: http://stackoverflow.com/a/21073312
type: Comment

http://stackoverflow.com/a/4321226
has body: nicer approach probably.. had seen the logic somewhere..here is my code which might do the job. public class revWords { public static void main(String[] args) { revWords obj = new revWords(); String print = obj.reverseWords("I am God"); System.out.println(print); } public String reverseWords(String words) { if(words == null || words.isEmpty() || !words.contains(" ")) return words; String reversed = ""; for( String word : words.split(" ")) reversed = word + " " + reversed; return reversed; } }
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/2713655
upvote count: 1
type: Answer

http://stackoverflow.com/comment/2792835
score: 0
type: Comment
type: QuestionComment
has text: Edited again. The problem is dividing the path. I need to find the distance between two paths, that is, the distance from every point in the first path to the corresponding point in the second path. That is why I need them to have the same number of points.
comment on: http://stackoverflow.com/q/2760469

http://stackoverflow.com/comment/2809736
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2769035
type: AnswerComment
has text: @Oscar: No, the concrete strategy doesn't require polymorphism here at all. The point is that you've used a map to completely bypass polymorphism. All you do in your example is get a `Referee` from a factory and call `decideFightBetween` on it. You may as well make `decideFightBetween` a method on the factory. Returning the referee is just a token attempt to use polymorphism after completely bypassing it.

http://stackoverflow.com/q/2768748
has answer: http://stackoverflow.com/a/2768995
has answer: http://stackoverflow.com/a/2768818
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2769527
has answer: http://stackoverflow.com/a/2769032
has body: I have two classes; let's call them Ogre and Wizard. (All fields are public to make the example easier to type in.) public class Ogre { int weight; int height; int axeLength; } public class Wizard { int age; int IQ; int height; } In each class I can create a method called, say, battle() that will determine who will win if an Ogre meets and Ogre or a Wizard meets a Wizard. Here's an example. If an Ogre meets an Ogre, the heavier one wins. But if the weight is the same, the one with the longer axe wins. public Ogre battle(Ogre o) { if (this.height &gt; o.height) return this; else if (this.height &lt; o.height) return o; else if (this.axeLength &gt; o.axeLength) return this; else if (this.axeLength &lt; o.axeLength) return o; else return this; // default case } We can make a similar method for Wizards. But what if a Wizard meets an Ogre? We could of course make a method for that, comparing, say, just the heights. public Wizard battle(Ogre o) { if (this.height &gt; o.height) return this; else if (this.height &lt; o.height) return o; else return this; } And we'd make a similar one for Ogres that meet Wizard. But things get out of hand if we have to add more character types to the program. This is where I get stuck. One obvious solution is to create a Character class with the common traits. Ogre and Wizard inherit from the Character and extend it to include the other traits that define each one. public class Character { int height; public Character battle(Character c) { if (this.height &gt; c.height) return this; else if (this.height &lt; c.height) return c; else return this; } } Is there a better way to organize the classes? I've looked at the strategy pattern and the mediator pattern, but I'm not sure how either of them (if any) could help here. My goal is to reach some kind of common battle method, so that if an Ogre meets an Ogre it uses the Ogre-vs-Ogre battle, but if an Ogre meets a Wizard, it uses a more generic one. Further, what if the characters that meet share …
tagged with: design-patterns
type: Question
has comment: http://stackoverflow.com/comment/2801777
has comment: http://stackoverflow.com/comment/2801990
tagged with: oop
tagged with: java
has answer: http://stackoverflow.com/a/2803706
has answer: http://stackoverflow.com/a/2768888
has answer: http://stackoverflow.com/a/2768984
upvote count: 22
has title: Using inheritance and polymorphism to solve a common game problem
linked to: http://stackoverflow.com/q/948564
has comment: http://stackoverflow.com/comment/16147618
downvote count: 0
has answer: http://stackoverflow.com/a/2769483
has answer: http://stackoverflow.com/a/2768809
tagged with: inheritance
answer count: 13
score: 22
has answer: http://stackoverflow.com/a/2768829
has answer: http://stackoverflow.com/a/2768910
has answer: http://stackoverflow.com/a/2768865
has answer: http://stackoverflow.com/a/2769035
favorite count: 0

http://stackoverflow.com/a/2633892
upvote count: 1
answers question: http://stackoverflow.com/q/2633873
downvote count: 0
type: Answer
has body: Short answer is yes, you should be able to do ArrayList.contains(new Integer(14)), for example, to see if 14 is in the list. The reason is that Integer overrides the equals method to compare itself correctly against other instances with the same value.
score: 1

http://stackoverflow.com/q/2684817
type: Question
downvote count: 0
tagged with: javascript
has answer: http://stackoverflow.com/a/2687582
tagged with: http://stackoverflow.com/tag/html
answer count: 1
favorite count: 0
upvote count: 1
has title: Embed Javafx in html
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2687582
score: 1
tagged with: java
tagged with: javafx
has body: I would like to simply ask if it is possible to embed a javafx application inside an html file. And if it is possible then I would like to know how to do this. I am open to using javascript etc. if it is required.

http://stackoverflow.com/a/2663855
upvote count: 14
has comment: http://stackoverflow.com/comment/15655052
accepted answer of: http://stackoverflow.com/q/2663204
has body: Writing to the file system from a Java EE container is not really recommended, especially if you need to process the written data: it is not transactional it harms the portability (what if you are in a clustered environment) it requires to setup external parameters for the target location If this is an option, I would store the files in database or use a JCR repository (like Jackrabbit).
has comment: http://stackoverflow.com/comment/15654123
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2695753
downvote count: 1
answers question: http://stackoverflow.com/q/2663204
has comment: http://stackoverflow.com/comment/6987161
has comment: http://stackoverflow.com/comment/15648466
type: Answer
score: 13
has comment: http://stackoverflow.com/comment/15648214
has comment: http://stackoverflow.com/comment/15646981
has comment: http://stackoverflow.com/comment/15649970
has comment: http://stackoverflow.com/comment/2692750

http://stackoverflow.com/comment/2790884
comment on: http://stackoverflow.com/a/2758816
type: Comment
has text: If they're both public classes, both in the "tools" package and both in the same directory, it should work.
score: 0
type: AnswerComment

http://stackoverflow.com/a/40231862
downvote count: 0
has body: tl;dr LocalDate ld = myUtilDate.toInstant() .atZone( ZoneId.of( "America/Montreal" ) ) .toLocalDate(); Details The Question and other Answers use outmoded old date-time classes that have proven to be poorly-designed, confusing, and troublesome. Now legacy, supplanted by the java.time classes. Instant truncated To more directly address the question: Convert to java.time, from java.util.Date to java.time.Instant. Truncate to the date. Convert via new methods added to the old classes. Instant instant = myUtilDate.toInstant(); The truncation feature is built into the Instant class. The Instant class represents a moment on the timeline in UTC with a resolution of nanoseconds (up to nine (9) digits of a decimal fraction). Instant instantTruncated = instant.truncatedTo( ChronoUnit.DAYS ); ZonedDateTime &amp; LocalDate But the approach above has issues. Both java.util.Date and Instant represent a moment on the timeline in UTC rather than an particular time zone. So if you drop the time-of-day, or set it to 00:00:00, you are getting a date that only makes sense in UTC. If you meant the date for Auckland NZ or Montréal Québec, you may have the wrong date. So a better approach is to apply your desired/expected time zone to the Instant to get a ZonedDateTime. Another problem is that we are inappropriately using a date-time object to represent a date-only value. Instead we should use a date-only class. From the ZonedDateTime we should extract a LocalDate if all you want is the date-only. The LocalDate class represents a date-only value without time-of-day and without time zone. ZoneId z = ZoneId.of( "America/Montreal" ); ZonedDateTime zdt = instant.atZone( z ); LocalDate ld = zdt.toLocalDate(); 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 as java.util.Date, Calendar, &amp; SimpleDateFormat. The Joda-Time project, now in maintenance mode, advises migration to java.time. To learn mo…
upvote count: 2
type: Answer
score: 2
answers question: http://stackoverflow.com/q/2775411

http://stackoverflow.com/a/2749143
has body: The way android generates the R.... values basically makes it so that java reserved keywords cannot be used as file names. If you look in gen.[project.path].R.java you will see a static int for each resource. The names have to be valid java names since it is a java file.
upvote count: 7
type: AcceptedAnswer
type: Answer
accepted answer of: http://stackoverflow.com/q/2749139
answers question: http://stackoverflow.com/q/2749139
downvote count: 0
score: 7

http://stackoverflow.com/a/2887516
has body: Arabic language has 29 alphabets, some of these alphabets are having sub alphabets like the Alif (أ) which can come in different forms. if you managed to be sub alphabet tolerant i.e. to allow spelling mistakes on these characters e.g. أحمد and احمد and إحمد and آحمد although they have different UTF8 values, you can take them as close results. moreover, if you can derive roots from words to allow searching for singulars, plurals, verbs, nouns, etc. so if someone typed قال (said) you can include in the searched terms the words قول (saying) and (يقول) (to say) and مقال (a saying), etc. it will require a complicated engine to do such thing finally, if you consider tashkeel (decorating vowels) that are optional in typing where you could take as a more specific search but would allow ignoring it e.g. رجل could match رَجُلٌ (meaning a man) or رَجَلَ (meaning walked on feet) or رِِِِِجْل (leg) I hope this would help
answers question: http://stackoverflow.com/q/2752471
score: 0
type: Answer

http://stackoverflow.com/a/2722983
score: 1
has comment: http://stackoverflow.com/comment/2750177
has comment: http://stackoverflow.com/comment/2752817
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2749329
has comment: http://stackoverflow.com/comment/2749499
has body: From a first glance: Why are you using a DataOutputStream ? Totally inadequate for your goal. Just use your provided outputstream: writer = connect.getOutputStream(); BTW, it's dubious practice to call "writer" that variable, Java makes a clear conceptual difference between readers/writers (char oriented) and streams (byte oriented). UPDATE: Another bad practice, which calls for trouble: you are mixing readers/writers (char oriented) and streams (byte oriented) unnecessarily - and without a specifyng a charset encoding. BufferedReader br = new BufferedReader(new InputStreamReader(input.getInputStream())); You must use a Reader when you are dealing with text (in a know encoding), use a InputStream if your are just dealing with bytes.
has comment: http://stackoverflow.com/comment/2754584
accepted answer of: http://stackoverflow.com/q/2722934
type: Answer
has comment: http://stackoverflow.com/comment/2749799
has comment: http://stackoverflow.com/comment/2751053
answers question: http://stackoverflow.com/q/2722934
has comment: http://stackoverflow.com/comment/2751511
upvote count: 2
has comment: http://stackoverflow.com/comment/2756217
has comment: http://stackoverflow.com/comment/6948664
downvote count: 1
has comment: http://stackoverflow.com/comment/2749920
has comment: http://stackoverflow.com/comment/2749749

http://stackoverflow.com/a/12554138
answers question: http://stackoverflow.com/q/2638200
has comment: http://stackoverflow.com/comment/25648503
score: 43
has comment: http://stackoverflow.com/comment/27118616
type: Answer
has comment: http://stackoverflow.com/comment/34961400
upvote count: 43
downvote count: 0
has comment: http://stackoverflow.com/comment/19768789
has body: This is how it should be (a clean version of Adam's answer): TokenStream stream = analyzer.tokenStream(null, new StringReader(text)); CharTermAttribute cattr = stream.addAttribute(CharTermAttribute.class); stream.reset(); while (stream.incrementToken()) { System.out.println(cattr.toString()); } stream.end(); stream.close();

http://stackoverflow.com/comment/2640005
type: Comment
type: QuestionComment
has text: I'm going to have to agree with BlueRaja, just because err... I don't know Java xD... But to be honest, the reason why I do like c# is because its... Err... TBH I don't have a reason. I lose, you win.
score: 0
comment on: http://stackoverflow.com/q/2626953

http://stackoverflow.com/comment/2737698
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2712483
type: AnswerComment
has text: I think you're making this more complicated than it needs to be by using a tile numbering scheme. You'll be better served by naming your tiles according to their 2d coordinates.

http://stackoverflow.com/a/5169339
has comment: http://stackoverflow.com/comment/6466654
type: Answer
has comment: http://stackoverflow.com/comment/6466695
has comment: http://stackoverflow.com/comment/6466538
upvote count: 1
has comment: http://stackoverflow.com/comment/6467246
has comment: http://stackoverflow.com/comment/6466491
score: 1
has comment: http://stackoverflow.com/comment/6466386
has comment: http://stackoverflow.com/comment/6449499
downvote count: 0
has body: Support for overriding virtual C++ methods is planned in BridJ (a JNA alternative that supports C++), but it's not there yet. Update: As of version 0.4, BridJ supports implementing C++ interfaces from Java : Consider the following C++ class : #ifndef TEST_EXPORTS #define TEST_EXPORTS #endif class TEST_EXPORTS TestClass { public: virtual int add(int a, int b); }; You'd bind this class from Java with these BridJ bindings : public class TestClass extends CPPObject { @Virtual(0) public native int add(int a, int b); }; And would be able to subclass your C++ class from Java very naturally : TestClass test = new TestClass() { @Override public int add(int a, int b) { return a + b; } };
answers question: http://stackoverflow.com/q/2638986
has comment: http://stackoverflow.com/comment/6466449

http://stackoverflow.com/a/2698242
answers question: http://stackoverflow.com/q/2698217
has comment: http://stackoverflow.com/comment/2720819
downvote count: 0
has comment: http://stackoverflow.com/comment/2720896
has comment: http://stackoverflow.com/comment/2720869
type: Answer
has comment: http://stackoverflow.com/comment/2720789
upvote count: 1
score: 1
has body: Use Collections#synchronizedMap(). As per my belief, if I use Collections.synchronizedMap(), I would have to use synchronized blocks for getter/setter. This is not true. You only need to synchronize the iteration on any of the views (keyset, values, entryset). Also see the abovelinked API documentation.
has comment: http://stackoverflow.com/comment/2720879

http://stackoverflow.com/comment/137250806
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/2761019
has text: You are right that it is unambiguous, but it requires extra effort from every reader who wants to know by following the link or seeing if it's mentioned in the question again (it is common and useful to skim the question and see if a solution answers one's problem) and makes copy pasting to test a potential solution harder.
type: Comment

http://stackoverflow.com/q/2756166
has answer: http://stackoverflow.com/a/2756618
upvote count: 30
type: Question
has body: I'm specifically interested in Scala (2.8) techniques for building strings with formats as well as interesting ways to make such a capability easily accessible where it's useful (lists of bytes, String, ...?).. public class Hex { public static String valueOf (final byte buf[]) { if (null == buf) { return null; } final StringBuilder sb = new StringBuilder(buf.length * 2); for (final byte b : buf) { sb.append(String.format("%02X", b &amp; 0xff)); } return sb.toString(); } public static String valueOf (final Byteable o) { return valueOf(o.toByteArray()); } } This is only a learning exercise (so the utility and implementation of the Java isn't a concern.) Thanks
answer count: 3
has title: What is/are the Scala way(s) to implement this Java "byte[] to Hex" class
favorite count: 0
score: 30
accepted answer: http://stackoverflow.com/a/2756627
possible better answer: http://stackoverflow.com/a/2756674
tagged with: scala
has answer: http://stackoverflow.com/a/2756674
has answer: http://stackoverflow.com/a/2756627
type: AnsweredQuestion
downvote count: 0
tagged with: java

http://stackoverflow.com/a/16636323
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/2627992
has body: create a pair of client / server, so that after the execution, client server sends the correct time and date. Then, the client asks the server pm GMT and the server sends back the answer right.
upvote count: 1
type: Answer

http://stackoverflow.com/comment/32086417
has text: @fortran That's fine as long as they way it's implemented happens to coincide with your exact use case. Admittedly a lot of the time it doesn't matter - but when you're dealing with (say) huge lists it's nice to be able to pick the implementation that's more efficient for your use case (adding/enumerating/searching/etc)
comment on: http://stackoverflow.com/a/2690259
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/2905510
answers question: http://stackoverflow.com/q/2780761
score: 0
has body: Use a profiling solutions that supports multiple metrics. We call them (metrics) meters in our product supporting standard ones like CPU time, blocking time, waiting time even custom meters based on key performance indicators. I assume you would also like to see what exactly a thread is doing which in that case you definitely need to consider a product rather than a home grown ad hoc solution.
type: Answer

http://stackoverflow.com/a/2623143
answers question: http://stackoverflow.com/q/2623061
score: 1
has body: Use commons-configuration, it is designed (to a certain extend) to allow you to write data to any configuration format.
type: AcceptedAnswer
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/2623061
upvote count: 1

http://stackoverflow.com/comment/2787134
type: Comment
comment on: http://stackoverflow.com/a/2753964
has text: The average formula I gave WM is the same one used in apache math: http://commons.apache.org/math/api-1.0/org/apache/commons/math/stat/descriptive/moment/Mean.html
type: AnswerComment
score: 0

http://stackoverflow.com/a/2995051
score: 10
upvote count: 10
type: Answer
has body: Close the ObjectOutputStream at the end. ObjectOutputStream out = new ObjectOutputStream(con.getOutputStream()); out.writeObject(user);//user is an object of a serializable class out.flush(); out.close(); //Don,t close your out here ObjectInputStream in = new ObjectInputStream(con.getInputStream()); status = (String)in.readObject(); in.close(); out.close(); //Close your out after reading the input
answers question: http://stackoverflow.com/q/2666040
downvote count: 0

http://stackoverflow.com/q/2675666
has title: Help needed in formatting date in Java
answer count: 2
upvote count: 1
has answer: http://stackoverflow.com/a/2675701
accepted answer: http://stackoverflow.com/a/2675701
possible better answer: http://stackoverflow.com/a/2675752
favorite count: 0
tagged with: date-format
has body: Hi I have the following date as String format. Input 2010-04-20 05:34:58.0 Output I want the string like 20, Apr 2010 Can someone tell me how to do it ?
type: AnsweredQuestion
downvote count: 0
score: 1
has answer: http://stackoverflow.com/a/2675752
type: Question
tagged with: java
tagged with: date

http://stackoverflow.com/a/2687156
score: 1
upvote count: 1
has body: REAL Studio (formally REALbasic) certainly meets this requirement. It creates native applications that have no external dependencies for OS X and Windows (plus Linux).
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/2610332

http://stackoverflow.com/q/2752529
type: AnsweredQuestion
score: 3
tagged with: oop
upvote count: 3
tagged with: java
possible better answer: http://stackoverflow.com/a/2752539
has answer: http://stackoverflow.com/a/2752539
type: Question
tagged with: c#
accepted answer: http://stackoverflow.com/a/2752536
has body: I have a wrapper class for the Bitmap class called BitmapZone. Assuming we have a WIDTH x HEIGHT bitmap picture, this wrapper class should serve the purpose of allowing me to send to other methods/classes itself instead of the original bitmap. I can then better control what the user is or not allowed to do with the picture (and I don't have to copy the bitmap lots of times to send for each method/class). My question is: knowing that all BitmapZone's are created from a Bitmap, what do you find preferrable? Constructor syntax: something like BitmapZone bitmapZone = new BitmapZone(originalBitmap, x, y, width, height); Factory Method Pattern: BitmapZone bitmapZone = BitmapZone.From(originalBitmap, x , y, width, height); Factory Method Pattern: BitmapZone bitmapZone = BitmapZone.FromBitmap(originalBitmap, x, y, width, height); Other? Why? Thanks
tagged with: factory-pattern
downvote count: 0
has answer: http://stackoverflow.com/a/2752830
has title: Better to use constructor or method factory pattern?
favorite count: 0
tagged with: constructor
has answer: http://stackoverflow.com/a/2752534
has answer: http://stackoverflow.com/a/2752536
answer count: 4

http://stackoverflow.com/a/37956733
type: Answer
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/2743130
downvote count: 0
has body: This happened if you change something in data set using native sql query but persisted object for same data set is present in session cache. Use session.evict(yourObject);

http://stackoverflow.com/comment/2782598
score: 0
has text: PLease mark an answer as being the right one, so the questions can be closed.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/2744497

http://stackoverflow.com/q/2626640
has answer: http://stackoverflow.com/a/2626737
has comment: http://stackoverflow.com/comment/2639690
favorite count: 0
has answer: http://stackoverflow.com/a/53131733
type: UnansweredQuestion
tagged with: transpose
type: Question
has answer: http://stackoverflow.com/a/2626718
has answer: http://stackoverflow.com/a/2626877
tagged with: java
has comment: http://stackoverflow.com/comment/2639710
has body: I have been working on two methods that will Transpose and Untranspose a String respectively. The solutions that I have come up with both work to the best of my knowledge. I just want to know if I could have solved these problems in a simpler way. My code seems like it is too long for the task that is being performed. The first method, transpose(), will take a String as a parameter and transpose it. If "bridge" is entered, the output will be "bergid". Likewise, with the unTranspose() method, if the user enters "bergid", the output will be "bridge". public void transpose( String s ) { String t = ""; int end = s.length() - 1; for ( int i = 0; i &lt; s.length() / 2; i++ ) { t += Character.toString( s.charAt( i ) ) + Character.toString( s.charAt( end ) ); end--; } // Lenth of String is odd if ( s.length() % 2 == 1 ) { // add character in middle of String to the end of the new String t+= Character.toString( s.charAt( s.length() / 2 ) ); } System.out.println( t ); } public void unTranspose( String s ) { String t = ""; // Length of String is odd if ( s.length() % 2 == 1 ) { for ( int i = 0; i &lt; s.length(); i+=2 ) { t+= Character.toString( s.charAt( i ) ); } for ( int i = s.length() - 2; i &gt; 0; i -= 2 ) { t += Character.toString( s.charAt( i ) ); } System.out.println( t ); } // Length of String is even else if ( s.length() % 2 == 0 ) { for ( int i = 0; i &lt; s.length() - 1; i+=2 ) { t+= Character.toString( s.charAt( i ) ); } for ( int i = s.length() - 1; i &gt; 0; i -= 2 ) { t+= Character.toString( s.charAt( i ) ); } System.out.println( t ); } } My code looks horrible. I'm still not used to formatting my code correctly. Please bear with me. Thanks for your time Definition transpose ---------&gt; "123Xcba" "1a2b3cX" &lt;----------- untranspose
has answer: http://stackoverflow.com/a/2626759
upvote count: 4
answer count: 8
downvote count: 0
tagged with: string
score: 4
has answer: http://stackoverflow.com/a/2629425
has answer: http://stackoverflow.com/a/2626758
has title: Transposing and Untransposing a String in java
has answer: http://stackoverflow.com/a/2626777

http://stackoverflow.com/q/2696496
favorite count: 0
accepted answer: http://stackoverflow.com/a/2696548
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2718728
upvote count: 2
has comment: http://stackoverflow.com/comment/2718721
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/2719305
has body: Hi, How to run java/ jdk or jre /bin command using java program???
possible better answer: http://stackoverflow.com/a/2696545
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/2696545
has title: how to run a java/bin command using java?
answer count: 2
has answer: http://stackoverflow.com/a/2696548

http://stackoverflow.com/q/2643179
has body: I am trying to run a plugin designed for Vuze using Java. For this I am using a command like this: /home/x/jre1.6.0_14/bin/java -Dazureus.config.path=/home/x/plugin_directory -Dfile.encoding=ANSI_X3.4-1968 -classpath /home/x/P/lib/swtgraphics2d.jar:/home/x/P/lib/Azureus2.jar:/home/x/P/lib/swt.jar org.gudy.azureus2.ui.swt.Main The problem with this is that the launch is failing with an error: changeLocale: *Default Language* != English (United States). Searching without country.. changeLocale: Searching for language English in *any* country.. changeLocale: no message properties for Locale 'English (United States)' (en_US), using 'English (default)' Invoking main failed java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.aelitis.azureus.launcher.MainExecutor$1.run(MainExecutor.java:37) at java.lang.Thread.run(Unknown Source) Caused by: org.eclipse.swt.SWTError: No more handles [gtk_init_check() failed] at org.eclipse.swt.SWT.error(SWT.java:3910) at org.eclipse.swt.widgets.Display.createDisplay(Display.java:863) at org.eclipse.swt.widgets.Display.create(Display.java:851) at org.eclipse.swt.graphics.Device.&lt;init&gt;(Device.java:152) at org.eclipse.swt.widgets.Display.&lt;init&gt;(Display.java:479) at org.eclipse.swt.widgets.Display.&lt;init&gt;(Display.java:470) at org.gudy.azureus2.ui.swt.mainwindow.SWTThread.&lt;init&gt;(SWTThread.java:84) at org.gudy.azureus2.ui.swt.mainwindow.SWTThread.createInstance(SWTThread.java:59) at org.gudy.azureus2.ui.swt.mainwindow.Initializer.&lt;init&gt;(Initializer.java:110) at org.gudy.azureus2.ui.swt.Main.&lt;init&gt;(Main.java:88) at org.gudy.azureus2.ui.swt.Main.main(Main.java:255) ... 6 more Exception in thread "MainRunner" java.lang.SecurityException: VM exit operation prohibited at org.gud…
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2643554
tagged with: java
type: Question
has title: Supressing GUI?
downvote count: 0
tagged with: ubuntu
accepted answer: http://stackoverflow.com/a/2643554
has answer: http://stackoverflow.com/a/2643192
answer count: 3
possible better answer: http://stackoverflow.com/a/2643311
score: 2
tagged with: user-interface
has answer: http://stackoverflow.com/a/2643311
favorite count: 0
tagged with: linux
upvote count: 2

http://stackoverflow.com/comment/13635028
comment on: http://stackoverflow.com/a/3751841
type: Comment
type: AnswerComment
has text: I tried adding overridden log4j.xml into src/test/resources, but it looks like being ignored. I still get those `INFO: WELD-000900 1.1.4 (Final)`. Any ideas?
score: 0

http://stackoverflow.com/q/2742299
tagged with: http://stackoverflow.com/tag/c
score: 0
answer count: 3
accepted answer: http://stackoverflow.com/a/2742339
has body: I'm trying to do a convex hull approach and the little problem is that I need to get all sets of three consecutive vertices, like this: private void isConvexHull(Ponto[] points) { Arrays.sort(points); for (int i = 0; i &lt;points.length; i++) { isClockWise(points[i],points[i+1],points[i+2]); } //... } I always do something that I don't consider clean code. Could please help me find one or more ways to this? I want it to be circular, i.e., if my fisrt point of the a set is the last element in the array, the 2nd element will be the 3rd in the list and the 3rd in that set will be the the 2nd element in the list, and so on. They must be consecutive, that's all.
has answer: http://stackoverflow.com/a/79535282
possible better answer: http://stackoverflow.com/a/2742458
tagged with: c++
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2742458
tagged with: java
has comment: http://stackoverflow.com/comment/140263565
has answer: http://stackoverflow.com/a/2742339
type: Question
has title: How to get all sets of three consecutive elements in an array or ArrayList with a for statement, circling the end to the beginning?
linked to: http://stackoverflow.com/q/2741846

http://stackoverflow.com/a/2769018
has comment: http://stackoverflow.com/comment/2813468
upvote count: 11
has comment: http://stackoverflow.com/comment/99800584
accepted answer of: http://stackoverflow.com/q/2768931
type: AcceptedAnswer
downvote count: 0
has body: Not in the standard Java API, but ... Apache Commons has a lot of handy String helper methods in StringUtils ... including StringUtils.right("apple",1) http://commons.apache.org/lang/api/org/apache/commons/lang/StringUtils.html#right(java.lang.String,%20int) just grab a copy of commons-lang.jar from commons.apache.org
type: Answer
answers question: http://stackoverflow.com/q/2768931
score: 11

http://stackoverflow.com/a/71423697
has comment: http://stackoverflow.com/comment/126253488
downvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/126253492
has body: package com. company; public class practise7 { static void star1(int n){ if(n&gt;0){ for(int i = 0; i&lt;n; i++){ System.out.print(&quot;*&quot;); } System.out.println(&quot;&quot;); star1(n-1); } } public static void main(String[] args) { star1(4); } } to forward star pattern package com. company; public class practise7 { static void star1(int n){ if(n&gt;0){ star1(n-1); for(int i = 0; i&lt;n; i++){ System.out.print(&quot;*&quot;); } System.out.println(&quot;&quot;); } } public static void main(String[] args) { star1(4); } }
upvote count: 0
answers question: http://stackoverflow.com/q/2717111
score: -1

relative-path
type: Tag
tags question: http://stackoverflow.com/q/2639943
tag name: relative-path

http://stackoverflow.com/q/2758577
has answer: http://stackoverflow.com/a/2759882
has title: Websphere 6.1, Datasource, two apps
has comment: http://stackoverflow.com/comment/2795603
score: 1
tagged with: java
has body: I've got a webapp running on a Websphere 6.1 Server which JNDI lookups for a datasource. This webapp runs fine, the Websphere server recognizes the datasource ref in the web.xml etc.. Now we added a second webapp which should use this datasource with same configuration but I recieve a ClassCastException when I try to access the datasource. To locate the problem I've put this into my code try{ InitialContext ctx = new InitialContext(); Object obj = ctx.lookup(N2WebConstants.datasourceJNDI); System.err.println(obj.toString()); System.err.println(obj.getClass()); con = ((DataSource) obj).getConnection(); }catch (Exception e){ System.err.println(e); System.err.println(e.getCause()); } In the error log this is printed [5/10/10 9:45:13:531 CEST] 00000176 SystemErr R com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource@e9240c0 [5/10/10 9:45:13:532 CEST] 00000176 SystemErr R class com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource [5/10/10 9:45:13:539 CEST] 00000176 SystemErr R java.lang.ClassCastException at java.lang.Throwable.&lt;init&gt;(Throwable.java:181) at java.lang.Exception.&lt;init&gt;(Exception.java:29) at java.lang.RuntimeException.&lt;init&gt;(RuntimeException.java:32) at java.lang.ClassCastException.&lt;init&gt;(ClassCastException.java:29) at de.ac.action.MAction.execute(MAction.java:77) at de.ac.web.GetTheView.doService(GetTheView.java:88) at de.ac.web.GetTheView.doGet(GetTheView.java:60) at javax.servlet.http.HttpServlet.service(HttpServlet.java:743) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1096) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:570) at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478) at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3444) at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:267) at com.ibm.ws.webcontainer.WebContainer.handleRequest(Web…
tagged with: datasource
has comment: http://stackoverflow.com/comment/2838558
has comment: http://stackoverflow.com/comment/2790476
has answer: http://stackoverflow.com/a/2823928
type: Question
tagged with: websphere
answer count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/2854854
favorite count: 0
has comment: http://stackoverflow.com/comment/2794684
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/2803745
upvote count: 1

http://stackoverflow.com/comment/2666277
has text: I doubt if there is a common real-world need for it hence a utility readily available.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2650180

http://stackoverflow.com/comment/2748743
type: AnswerComment
type: Comment
score: 2
comment on: http://stackoverflow.com/a/2722434
has text: @glaz: it's only not generic. Guava (Google Collections) is. I wouldn't miss parameterized types.

http://stackoverflow.com/q/2655255
has title: jdbc nested transactions
favorite count: 0
linked to: http://stackoverflow.com/q/521669
type: UnansweredQuestion
tagged with: jdbc
answer count: 0
downvote count: 0
has comment: http://stackoverflow.com/comment/34239143
type: Question
has body: What is the behaviour of nested transactions. I am using java + jdbc ? Eg: tx1.begin do stuff1 tx2.begin do stuff2 tx2.commit do stuff1.1 tx1.rollback tx2 is basically inside another function. Will the results from tx2 be persisted ? In case behaviour is db specific, what is it in case of Sql server 2005 ?
tagged with: transactions
score: 1
tagged with: java
upvote count: 1
duplicate of: http://stackoverflow.com/q/521669

http://stackoverflow.com/comment/8765653
type: Comment
comment on: http://stackoverflow.com/a/2780702
has text: No, since most of us are using out-of-order-processors, nothing is defined. JLS: "It should be noted that the presence of a happens-before relationship between two actions does not necessarily imply that they have to take place in that order in an implementation. If the reordering produces results consistent with a legal execution, it is not illegal." Since those two statements aren't directly affected by each other (accessing the same variable or similar), reordering is allowed.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/2690879
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/2672172
score: 0
has text: @Chuk Lee: good thought. Switch or if, however, the point is that it is clunky and not good OO design. Chris Cooper's answer is good in OO-design terms.

http://stackoverflow.com/a/55860428
downvote count: 0
has comment: http://stackoverflow.com/comment/133970049
upvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/100286086
score: 2
answers question: http://stackoverflow.com/q/2723838
has body: in java1.7+ You can use this code to get file`s create time ! private static LocalDateTime getCreateTime(File file) throws IOException { Path path = Paths.get(file.getPath()); BasicFileAttributeView basicfile = Files.getFileAttributeView(path, BasicFileAttributeView.class, LinkOption.NOFOLLOW_LINKS); BasicFileAttributes attr = basicfile.readAttributes(); long date = attr.creationTime().toMillis(); Instant instant = Instant.ofEpochMilli(date); return LocalDateTime.ofInstant(instant, ZoneId.systemDefault()); }

http://stackoverflow.com/q/2605131
has comment: http://stackoverflow.com/comment/2615108
has body: I have a written a method to get all the records and return in the List Type, but I got out of memory error. So I changed return type from List to Enumeration, in the method, instead of ArrayList, uses Vector and return vector.elements at the end of the method. It works without any error. but I did not understand why. Could someone explain Why this Enumeration worked?
score: 4
answer count: 2
has title: Difference between the List and Enumeration
tagged with: java
has answer: http://stackoverflow.com/a/2605905
upvote count: 4
type: AnsweredQuestion
downvote count: 0
possible better answer: http://stackoverflow.com/a/2605177
has answer: http://stackoverflow.com/a/2605177
favorite count: 0
type: Question
accepted answer: http://stackoverflow.com/a/2605905

http://stackoverflow.com/comment/2633376
has text: @Steve Emmerson: Sorry, overlooked the word "similar". But @nicerobot makes a good point. I would like to add C# to his list of examples.
comment on: http://stackoverflow.com/a/2617687
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/2640581
has body: The problem lies in how you instantiated your Frame (CashMachine), not (directly) with its implementation. You are calling buildGUI twice, one in the object's constructor, and then in the Driver class that instantiates the object. As a result, you are creating (and laying out) two sets of buttons. When the buttons of the first set were eventually disabled, your mousing activity was revealing the second set of buttons. And a flaw in your ActionListener implementation can cause inputCount to take on values greater than 6, so buttons in the second set were not eventually disabled like those from the first set. buildGUI should be private; it should be called in the CashMachine constructor, and not by your Driver class. Conversely, in my opinion, CashMachine.setVisible should be called by the Driver class, and not by the CashMachine constructor.
has comment: http://stackoverflow.com/comment/2655963
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2663633
downvote count: 0
has comment: http://stackoverflow.com/comment/2664014
answers question: http://stackoverflow.com/q/2640380
accepted answer of: http://stackoverflow.com/q/2640380
score: 3
type: Answer
upvote count: 3
has comment: http://stackoverflow.com/comment/2655244

http://stackoverflow.com/q/2620533
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2620549
possible better answer: http://stackoverflow.com/a/2651587
downvote count: 0
score: 26
has body: I've often read that in the Sun JVM short-lived objects ("relatively new objects") can be garbage collected more efficiently than long-lived objects ("relatively old objects") Why is that so? Is that specific to the Sun JVM or does this result from a general garbage collection principle?
favorite count: 0
has answer: http://stackoverflow.com/a/2620545
type: Question
answer count: 8
has answer: http://stackoverflow.com/a/2620540
tagged with: garbage-collection
has answer: http://stackoverflow.com/a/2620557
has answer: http://stackoverflow.com/a/2622305
has answer: http://stackoverflow.com/a/2620588
tagged with: java
upvote count: 26
has answer: http://stackoverflow.com/a/2620707
has comment: http://stackoverflow.com/comment/2633039
has title: Why make short and long-lived objects a difference in garbage collection?
has answer: http://stackoverflow.com/a/2651587
accepted answer: http://stackoverflow.com/a/2620588

http://stackoverflow.com/q/2709593
possible better answer: http://stackoverflow.com/a/2709831
has answer: http://stackoverflow.com/a/2709672
has answer: http://stackoverflow.com/a/57776583
has answer: http://stackoverflow.com/a/2711682
has answer: http://stackoverflow.com/a/48764601
has answer: http://stackoverflow.com/a/2709831
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/33722419
score: 231
favorite count: 0
has answer: http://stackoverflow.com/a/2709604
type: Question
has answer: http://stackoverflow.com/a/10674125
downvote count: 2
has answer: http://stackoverflow.com/a/2738648
has answer: http://stackoverflow.com/a/10496435
has answer: http://stackoverflow.com/a/6289804
tagged with: enums
has answer: http://stackoverflow.com/a/77069655
has answer: http://stackoverflow.com/a/53163279
tagged with: java
has body: I just found out that Java allows enums to implement an interface. What would be a good use case for that?
linked to: http://stackoverflow.com/q/427902
has answer: http://stackoverflow.com/a/16279972
has answer: http://stackoverflow.com/a/19779148
upvote count: 233
accepted answer: http://stackoverflow.com/a/2709604
answer count: 18
has title: Why would an Enum implement an Interface?
has comment: http://stackoverflow.com/comment/93494648
has answer: http://stackoverflow.com/a/78781193
has answer: http://stackoverflow.com/a/2709615
linked to: http://stackoverflow.com/q/2111768
has answer: http://stackoverflow.com/a/2709618

http://stackoverflow.com/q/2746816
has answer: http://stackoverflow.com/a/2746929
downvote count: 0
accepted answer: http://stackoverflow.com/a/2746840
tagged with: parsing
favorite count: 0
type: AnsweredQuestion
score: 3
has body: I was trying to parse the string: Portfolio1[{Exchange:NASDAQ-Symbol:INFY-Full Name:Infosys Technologies Limited (ADR)-Share Count:100.0-Percent Gain:388.2258065-The position cost is:1240.0 USD-This position made today:-46.9997 USD-This position has a total gain of:4814.0 USD-This position is worth:6054.0 USD}--{Exchange:NASDAQ-Symbol:GOOG-Full Name:Google Inc.-Share Count:10.0-Percent Gain:17.98444444-The position cost is:4500.0 USD-This position made today:-10.70007 USD-This position has a total gain of:809.3 USD-This position is worth:5309.3 USD}--{Exchange:NASDAQ-Symbol:QCOM-Full Name:QUALCOMM, Inc.-Share Count:0.0-Percent Gain:0.0}--]Portfolio2[{Exchange:NASDAQ-Symbol:GOOG-Full Name:Google Inc.-Share Count:1000.0-Percent Gain:32.56679151-The position cost is:400500.0 USD-This position made today:-1070.007 USD-This position has a total gain of:130430.0 USD-This position is worth:530930.0 USD}--{Exchange:NASDAQ-Symbol:MSFT-Full Name:Microsoft Corporation-Share Count:10.0-Percent Gain:-4.03125-The position cost is:320.0 USD-This position made today:-2.93001 USD-This position has a total gain of:-12.9 USD-This position is worth:307.1 USD}--{Exchange:NYSE-Symbol:IBM-Full Name:International Business Machines Corp.-Share Count:10.0-Percent Gain:397.80769230000004-The position cost is:260.0 USD-This position made today:-10.30014 USD-This position has a total gain of:1034.3 USD-This position is worth:1294.3 USD}--{Exchange:NASDAQ-Symbol:NVDA-Full Name:NVIDIA Corporation-Share Count:100.0-Percent Gain:-10.79418345-The position cost is:1788.0 USD-This position made today:-70.0 USD-This position has a total gain of:-193.0 USD-This position is worth:1595.0 USD}--]"; with delimiter as [ and my code was String delims = "["; String[] tokens = s.split(delims); for (int i = 0; i &lt; tokens.length; i++) System.out.println(tokens[i]); but it is giving me error java.util.regex.PatternSyntaxException: Unclosed character class near index 0 [
upvote count: 3
tagged with: java
has answer: http://stackoverflow.com/a/2746840
has title: Java parsing Error
possible better answer: http://stackoverflow.com/a/2746929
type: Question
answer count: 2

http://stackoverflow.com/comment/42262487
type: Comment
comment on: http://stackoverflow.com/a/2650188
score: 1
has text: What you're talking about is "Interpretation" ... compiling is turning the human readable code into machine code
type: AnswerComment

http://stackoverflow.com/a/2710907
has body: Yes, since it's public you can use it from another class. If it's in your Loan class you write Loan.HOME_LOAN_TERMS.FIFTEEN_YEAR to refer to it from a different class.
upvote count: 1
has comment: http://stackoverflow.com/comment/2735619
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2710897
has comment: http://stackoverflow.com/comment/2744734
score: 1
accepted answer of: http://stackoverflow.com/q/2710897
type: Answer

http://stackoverflow.com/comment/2734319
type: AnswerComment
comment on: http://stackoverflow.com/a/2709916
type: Comment
has text: Yes, I know this this does not explain the NPE, but it's surely a bug nonetheless
score: 0

http://stackoverflow.com/q/2682793
tagged with: arrays
downvote count: 0
has body: I want to create a game that starts with 3 green dots on the left and 3 red dots on the right with a space between them. The endgame should have the colors switched sides. The rules of the game are that, if there is a space next to a dot it should be able to move there, also if an opposite color is next to it - it should be able to jump over iff there is a space behind the opposite color. My question is located below the code. Here is the code: //import mind.*; import javax.swing.*; import java.util.*; import java.lang.*; import java.awt.*; public class Drive { String[] middle = new String[7]; public Drive() { int player1, player2; boolean gameEnd, checkempty, checkempty2, enemy, enemy2; // Gamepieces String gr,rd,tom; gr="G"; rd="R"; tom=" "; // beginning of the game, endgame and the updating array String[] begin = {gr,gr,gr,tom,rd,rd,rd}; String[] mellan = new String[7]; String[] end = {rd,rd,rd,tom,gr,gr,gr}; Scanner in = new Scanner(System.in); while (mellan!=end) { mellan=begin; for(int i=0; i&lt;mellan.length; i++) { System.out.print(mellan[i]); } System.out.print(" Choose 0-6: "); int digits = in.nextInt(); //BOOLEAN for game rules!!! checkempty = mellan[digits+1]==tom; checkempty2 = mellan[digits-1]==tom; enemy = (mellan[digits]==gr &amp;&amp; mellan[digits+1]==rd &amp;&amp; mellan[digits+2]==tom); enemy2 = (mellan[digits]==rd &amp;&amp; mellan[digits-1]==gr &amp;&amp; mellan[digits-2]==tom); if(checkempty) { mellan[digits+1]=mellan[digits]; mellan[digits]=tom; } else if (checkempty2) { mellan[digits-1]=mellan[digits]; mellan[digits]=tom; } else if (enemy) { mellan[digits+2]=mellan[digits]; mellan[digits]=tom; } else if (enemy2) { mellan[digits-2]=mellan[digits]; mellan[digits]=tom; } } System.out.print("Nicely Done"); } // Test Drive! public static void main(String args[]) { new Drive(); } } Problem: Right now, it's making up the game logic. If the dots weren't able to move backwards I would have done the task. But since they are able to move backwards, it …
tagged with: logic
answer count: 3
accepted answer: http://stackoverflow.com/a/2682894
favorite count: 0
upvote count: 2
has answer: http://stackoverflow.com/a/2682890
type: AnsweredQuestion
score: 2
possible better answer: http://stackoverflow.com/a/2682968
has answer: http://stackoverflow.com/a/2682968
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/2682894
has title: Java Array Game - Game Logic Concept

http://stackoverflow.com/q/2738204
tagged with: visual-studio
has title: Problem with connecting to a java web service running on WebSphere 6.1
type: AnsweredQuestion
tagged with: websphere-6.1
has comment: http://stackoverflow.com/comment/2781454
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/2766895
has comment: http://stackoverflow.com/comment/2766789
has answer: http://stackoverflow.com/a/2743856
score: 0
accepted answer: http://stackoverflow.com/a/2743856
answer count: 1
has body: I have one machine running a java web service on IBM WebSphere. It is using port 9081. I also have a client to this web service written in c#.NET. The funny thing is that I can easily reference the web service in Visual Studio 2005 (I get the wsdl definition) by http://ip_address:9081/ProjectName/services/MyService?wsdl but I cannot call any of the exposed remote methods. I get an error saying : {"No connection could be made because the target machine actively refused it 127.0.0.1:9081"} I would appreciate any ideas.
tagged with: web-services

midp
tags question: http://stackoverflow.com/q/2691177
tags question: http://stackoverflow.com/q/2708124
tags question: http://stackoverflow.com/q/2598162
tag name: midp
tags question: http://stackoverflow.com/q/2632788
type: Tag
tags question: http://stackoverflow.com/q/2756160
tags question: http://stackoverflow.com/q/2631450

http://stackoverflow.com/comment/2737666
has text: try showing us some code
type: Comment
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/2712750

http://stackoverflow.com/a/2642390
answers question: http://stackoverflow.com/q/2642371
accepted answer of: http://stackoverflow.com/q/2642371
upvote count: 3
has body: JNI access uses mangled names; you will need to wrap the system API in a JNI stub with the correct name and arguments. You can't call a system API directly. I recommend researching JNI thoroughly, or using something like JNA to alleviate some of the drudge work. For example, given Java: package com.mycompany.jni; public MyClass { native boolean someMethod(String arg) ... } the native method linked is something like: JNIEXPORT jboolean JNICALL Java_com_mycompany_jni_MyClass_someMethod(JNIEnv *jep, jobject thsObj, jstring arg)
has comment: http://stackoverflow.com/comment/2657298
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2657372
score: 3
type: Answer

http://stackoverflow.com/comment/139537908
comment on: http://stackoverflow.com/a/77360128
score: 0
type: AnswerComment
has text: For me complains that version is not provided, which makes sense that is what dependency management is doing
type: Comment

http://stackoverflow.com/a/2713062
downvote count: 0
has body: Why don't you "clear" (I mean do not draw anything on your boards) and call a repaint on the JLayeredPane. This will force to redraw the full stack of Panels, no? EDIT: add a code sample with StackLayout from Romain GUY, see the ClearShape &amp; paintComponent methods EDIT2: calling the repaint can also be done using the good Clipping region to render faster, but I let you modify the code for this... package swing; import java.awt.AlphaComposite; import java.awt.BasicStroke; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Composite; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.Shape; import java.awt.event.ActionEvent; import java.awt.geom.Ellipse2D; import java.awt.image.BufferedImage; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JPanel; public class ClearLayeredPanelsGUI extends JFrame { Action clearRect; Action drawRect; Action clearRound; Action drawRound; TransparentBoard rectBoard; TransparentBoard roundBoard; JPanel whiteBackground; JPanel stack; JPanel buttonBar; public ClearLayeredPanelsGUI() { initPanels(); } private void initPanels() { initStackPanel(); initButtonPanel(); this.getContentPane().setLayout(new BorderLayout()); this.getContentPane().add(stack, BorderLayout.CENTER); this.getContentPane().add(buttonBar, BorderLayout.NORTH); } private void initStackPanel() { stack = new JPanel(new StackLayout()); stack.setPreferredSize(new Dimension(300, 300)); whiteBackground = new JPanel(); whiteBackground.setOpaque(true); whiteBackground.setBackground(Color.WHITE); rectBoard = new TransparentBoard(Color.BLUE, new Rectangle(0, 0, 100, 200)); roundBoard = new TransparentBoard(Color.RED, new Ellipse2D.Float(0.0f, 0.0f, 150.0f, 100.0f)); stack.add(whiteBackground, StackLayout.TOP); stack.add(roundBoard, StackLayout.TOP…
has comment: http://stackoverflow.com/comment/2737950
type: Answer
accepted answer of: http://stackoverflow.com/q/2712732
has comment: http://stackoverflow.com/comment/2745170
has comment: http://stackoverflow.com/comment/2744622
upvote count: 1
has comment: http://stackoverflow.com/comment/2741166
score: 1
answers question: http://stackoverflow.com/q/2712732
type: AcceptedAnswer

linked-list
tags question: http://stackoverflow.com/q/2703971
tags question: http://stackoverflow.com/q/2663115
tag name: linked-list
tags question: http://stackoverflow.com/q/2653040
tags question: http://stackoverflow.com/q/2779067
type: Tag
tags question: http://stackoverflow.com/q/2614252
tags question: http://stackoverflow.com/q/2784816
tags question: http://stackoverflow.com/q/2666717
tags question: http://stackoverflow.com/q/2642853
tags question: http://stackoverflow.com/q/2774173
tags question: http://stackoverflow.com/q/2657298
tags question: http://stackoverflow.com/q/2709551
tags question: http://stackoverflow.com/q/2754891

http://stackoverflow.com/a/2710681
accepted answer of: http://stackoverflow.com/q/2710498
has body: On HP-UX -Xverbosegc [:help] | [0 | 1] [:file = [stdout | stderr | ]] IBMs JDK Any platform that uses the IBM JDK -Xverbosegclog[:[,,]] Sun JDK -Xloggc:file Report on each garbage collection event, as with -verbose:gc, but log this data to file. In addition to the information -verbose:gc gives, each reported event will be preceeded by the time (in seconds) since the first garbage-collection event. Always use a local file system for storage of this file to avoid stalling the JVM due to network latency. The file may be truncated in the case of a full file system and logging will continue on the truncated file. This option overrides -verbose:gc if both are given on the command line.
score: 2
type: AcceptedAnswer
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2710498
upvote count: 2

http://stackoverflow.com/comment/11385168
comment on: http://stackoverflow.com/a/2767278
type: AnswerComment
has text: In netbeans, right click context menu has "Call Hierarchy" option. Can be invoked by clicking on a method defintion.
type: Comment
score: 1

http://stackoverflow.com/a/79466428
answers question: http://stackoverflow.com/q/2773824
score: 0
has body: Although HashSets and HashMaps implement different interfaces. A HashSet is essentially using a HashMap Instance for its internal implementation. You can confirm this at the official documentation at - https://docs.oracle.com/javase/8/docs/api/java/util/HashSet.html OR Read a Medium post at - https://medium.com/@liberatoreanita/working-with-hashset-in-java-8993b411e3a9
type: Answer

http://stackoverflow.com/comment/2613914
type: Comment
comment on: http://stackoverflow.com/a/2603115
score: 0
has text: @Thorbjørn `ToolProvider.getSystemJavaCompiler()` will return `null` with a JRE (so you won't indeed be able to compile without a JDK).
type: AnswerComment

http://stackoverflow.com/comment/2794412
has text: what if i need to change arg1 itself though? i'd have to create a class for each parameter i'd like to change
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2762221
type: Comment

http://stackoverflow.com/comment/23419739
type: Comment
has text: @Mr_and_Mrs_D, I don't know, with Java 6 end of life, the real answer is to use the Java 7 options, it certainly will be soon enough. I am loath to remake answers that got upvotes and acceptance on a different premise.
comment on: http://stackoverflow.com/a/2699270
score: 0
type: AnswerComment

http://stackoverflow.com/q/2770877
score: 20
possible better answer: http://stackoverflow.com/a/25691389
tagged with: jdbctemplate
answer count: 10
has answer: http://stackoverflow.com/a/25691389
upvote count: 20
has answer: http://stackoverflow.com/a/48775098
tagged with: java
has answer: http://stackoverflow.com/a/5187308
has answer: http://stackoverflow.com/a/2771594
type: AnsweredQuestion
downvote count: 0
has body: From the Spring JDBC documentation, I know how to insert a blob using JdbcTemplate final File blobIn = new File("spring2004.jpg"); final InputStream blobIs = new FileInputStream(blobIn); jdbcTemplate.execute( "INSERT INTO lob_table (id, a_blob) VALUES (?, ?)", new AbstractLobCreatingPreparedStatementCallback(lobhandler) { protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException { ps.setLong(1, 1L); lobCreator.setBlobAsBinaryStream(ps, 2, blobIs, (int)blobIn.length()); } } ); blobIs.close(); And also how to retrieve the generated key of a newly inserted row: KeyHolder keyHolder = new GeneratedKeyHolder(); jdbcTemplate.update( new PreparedStatementCreator() { public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { PreparedStatement ps = connection.prepareStatement(INSERT_SQL, new String[] {"id"}); ps.setString(1, name); return ps; } }, keyHolder); // keyHolder.getKey() now contains the generated key Is there a way I could combine the two?
has answer: http://stackoverflow.com/a/8751585
has answer: http://stackoverflow.com/a/2771607
favorite count: 0
has title: Spring JdbcTemplate - Insert blob and return generated key
has answer: http://stackoverflow.com/a/28377806
type: Question
has answer: http://stackoverflow.com/a/32530868
accepted answer: http://stackoverflow.com/a/5187308
has answer: http://stackoverflow.com/a/12748671
tagged with: spring-jdbc
has answer: http://stackoverflow.com/a/14669549

http://stackoverflow.com/a/2636862
score: 3
upvote count: 3
has comment: http://stackoverflow.com/comment/2650986
has comment: http://stackoverflow.com/comment/2651428
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2636845
has body: Wouldn't you be better doing this with inheritance? Cat and Dog would be subclasses of Species. Persion would be a subclass of Cat and Pitbull would be a subclass of Dog. What are trying to achieve by wanting to use Enums?
answers question: http://stackoverflow.com/q/2636845
type: Answer
has comment: http://stackoverflow.com/comment/2653302

http://stackoverflow.com/a/2607980
score: 3
downvote count: 0
answers question: http://stackoverflow.com/q/2606653
type: Answer
has body: TCP/IP connections are disabled by default when you install the Express version of SQL Server. You need to run the SQL Server Configuration Manager and turn on TCP/IP. You also need to set the port it's listening on to 1433.
upvote count: 3

http://stackoverflow.com/comment/2749969
type: Comment
comment on: http://stackoverflow.com/a/2707559
type: AnswerComment
has text: @dmcer - in the transform method I'm overriding, I need to know the parent of the current tree that is being transformed. Since the only parameter of the transform method is the tree, how do I get the parent of that tree? That is, I want to use root while transforming, not after
score: 0

http://stackoverflow.com/comment/32393787
score: 3
type: AnswerComment
has text: https://github.com/rometools/rome appears to be the new location (see also https://rometools.jira.com)
type: Comment
comment on: http://stackoverflow.com/a/2729095

http://stackoverflow.com/comment/2779837
has text: Of course there is a difference. If you put a not-serializable object into the array, it will fail during compile time. In your version, it will fail during marshalling – which is bad.
type: AnswerComment
comment on: http://stackoverflow.com/a/2749730
score: 0
type: Comment

javascript
tags question: http://stackoverflow.com/q/2707374
tags question: http://stackoverflow.com/q/2657268
tags question: http://stackoverflow.com/q/2740031
tags question: http://stackoverflow.com/q/2626742
tags question: http://stackoverflow.com/q/2770672
tags question: http://stackoverflow.com/q/2761042
tags question: http://stackoverflow.com/q/2664578
tags question: http://stackoverflow.com/q/2680938
tags question: http://stackoverflow.com/q/2710334
tag name: javascript
tags question: http://stackoverflow.com/q/2724615
tags question: http://stackoverflow.com/q/2675776
tags question: http://stackoverflow.com/q/2664378
tags question: http://stackoverflow.com/q/2764842
tags question: http://stackoverflow.com/q/2652022
tags question: http://stackoverflow.com/q/2781574
tags question: http://stackoverflow.com/q/2705790
type: Tag
tags question: http://stackoverflow.com/q/2704415
tags question: http://stackoverflow.com/q/2622658
tags question: http://stackoverflow.com/q/2704643
tags question: http://stackoverflow.com/q/2758567
tags question: http://stackoverflow.com/q/2627237
tags question: http://stackoverflow.com/q/2664683
tags question: http://stackoverflow.com/q/2673762
tags question: http://stackoverflow.com/q/2747422
tags question: http://stackoverflow.com/q/2624997
tags question: http://stackoverflow.com/q/2771167
tags question: http://stackoverflow.com/q/2767690
tags question: http://stackoverflow.com/q/2683646
tags question: http://stackoverflow.com/q/2684817
tags question: http://stackoverflow.com/q/2765583
tags question: http://stackoverflow.com/q/2598207
tags question: http://stackoverflow.com/q/2666086
tags question: http://stackoverflow.com/q/2686870
tags question: http://stackoverflow.com/q/2682212
tags question: http://stackoverflow.com/q/2598162
tags question: http://stackoverflow.com/q/2780192

http://stackoverflow.com/a/47805407
score: 3
downvote count: 0
answers question: http://stackoverflow.com/q/2703161
upvote count: 3
has body: Tested on 4.5.4: SSLContext sslContext = new SSLContextBuilder() .loadTrustMaterial(null, (TrustStrategy) (arg0, arg1) -&gt; true).build(); CloseableHttpClient httpClient = HttpClients .custom() .setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE) .setSSLContext(sslContext) .build();
type: Answer

http://stackoverflow.com/comment/2821767
type: AnswerComment
type: Comment
score: 0
has text: This is a approuch for print a hastable, but i mean write hashtable into txt file i use BufferedWriter writer = new BufferedWriter(new FileWriter(resultOutputFile)); writer.write(googleHashTableResult); but it hava an error :erro The method write(int) in the type BufferedWriter is not applicable for the arguments
comment on: http://stackoverflow.com/a/2786049

http://stackoverflow.com/q/2614763
has title: Java: simple program to attach document or image
has answer: http://stackoverflow.com/a/2615448
has comment: http://stackoverflow.com/comment/2626079
score: 0
answer count: 1
type: UnansweredQuestion
has body: I have two buttons and one textset on JFrame. I need the first button to allow the user to browse for files and the second button to attach documents or images and displayed in textset.
tagged with: java
type: Question

http://stackoverflow.com/comment/2755181
comment on: http://stackoverflow.com/a/2727408
type: AnswerComment
has text: @pgras Why would you want to acquire the resources in the `try` block?? That just makes a mess of your code.
score: 0
type: Comment

http://stackoverflow.com/comment/65101460
comment on: http://stackoverflow.com/a/2770275
score: 1
type: AnswerComment
type: Comment
has text: I think it would be good also to explain the difference in case we have a method like this : `<E extends Number> E process(E elt)` vs `Number process(Number elt)`

http://stackoverflow.com/q/2648242
has body: Is this the best way to convert String hex to bytes? Or can you think a shorter/simpler? public static byte[] hexToBytes(String hex) { return hexToBytes(hex.toCharArray()); } public static byte[] hexToBytes(char[] hex) { int length = hex.length / 2; byte[] raw = new byte[length]; for (int i = 0; i &lt; length; i++) { int high = Character.digit(hex[i * 2], 16); int low = Character.digit(hex[i * 2 + 1], 16); int value = (high &lt;&lt; 4) | low; if (value &gt; 127) value -= 256; raw[i] = (byte) value; } return raw; }
answer count: 5
has answer: http://stackoverflow.com/a/14852798
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/39000127
has answer: http://stackoverflow.com/a/62026033
has title: Is this the best way to convert String hex to bytes?
type: Question
tagged with: arrays
has comment: http://stackoverflow.com/comment/2664489
possible better answer: http://stackoverflow.com/a/2648452
has answer: http://stackoverflow.com/a/2648452
has answer: http://stackoverflow.com/a/2648259
accepted answer: http://stackoverflow.com/a/2648259
upvote count: 1
has comment: http://stackoverflow.com/comment/2664049
favorite count: 0
tagged with: hex

http://stackoverflow.com/a/2755680
score: 0
type: Answer
has body: I saw your post and I thought to give you a fast answer. Check out this link: Reading file line by line You should go through the Java Tutorials as well. After you take each line you can save into a two dimensional array with something like this: String str; i = 0; j = 0; while ((str = in.readLine()) != null) { array[i][j] = str; j++; if (j == 3){ j = 0; i++; } } in.close(); Then you can play with the array values any way you like. Good luck.
has comment: http://stackoverflow.com/comment/2786972
answers question: http://stackoverflow.com/q/2755617

http://stackoverflow.com/comment/2749979
has text: And what about the fact that most of those files will be the same (most likely more then 90%) and transfering them, imho, is just an overkill.
type: AnswerComment
comment on: http://stackoverflow.com/a/2722722
type: Comment
score: 0

http://stackoverflow.com/a/2774626
has comment: http://stackoverflow.com/comment/123559738
has body: You can do it like you assumed. But your HashMap has to be templated: Map&lt;String, Map&lt;String, String&gt;&gt; map = new HashMap&lt;String, Map&lt;String, String&gt;&gt;(); Otherwise you have to do a cast to Map after you retrieve the second map from the first. Map map = new HashMap(); ((Map)map.get( "keyname" )).get( "nestedkeyname" );
upvote count: 87
answers question: http://stackoverflow.com/q/2774608
score: 87
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2774608
type: Answer

http://stackoverflow.com/comment/2790856
comment on: http://stackoverflow.com/a/2759040
has text: These problems could be resolved with a `ExecutorCompletionService`. I'm looking into that now.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/28021065
type: Comment
score: 26
comment on: http://stackoverflow.com/a/2624210
has text: @devsda He didn't say always unique, he said more likely to be unique. As for why, a quick search on google reveals this article: http://computinglife.wordpress.com/2008/11/20/why-do-hash-functions-use-prime-numbers/ explaining why 31 was used for Java string hashing. There is no mathematical proof given, but it does explain the general concept as to why primes work better.
type: AnswerComment

http://stackoverflow.com/comment/2684067
has text: `replace()` also replaces all occurrences but doesn't use regexp, so there are no special characters.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2665992
type: Comment

http://stackoverflow.com/q/2678232
downvote count: 0
has answer: http://stackoverflow.com/a/2681396
has title: Google App Engine Java app couldn't find javac?
answer count: 2
has body: I'm learning to use Google App Engine, I installed it in Netbeans, the project works, but when I clicked on "Deploy To Google App Engine", I got the following error : Beginning server interaction for ... 0% Creating staging directory 5% Scanning for jsp files. 8% Compiling jsp files. 11% Compiling java files. Error Details: Apr 20, 2010 3:51:23 PM org.apache.jasper.JspC processFile INFO: Built File: \PayPal_Monitor.jsp java.lang.IllegalStateException: cannot find javac executable based on java.home, tried "C:\Program Files (x86)\Java\jre6\bin\javac.exe" and "C:\Program Files (x86)\Java\bin\javac.exe" Unable to update app: cannot find javac executable based on java.home, tried "C:\Program Files (x86)\Java\jre6\bin\javac.exe" and "C:\Program Files (x86)\Java\bin\javac.exe" Please see the logs [C:\Users\NM\AppData\Local\Temp\appcfg3946701335172983337.log] for further information. The file "javac.exe" is in : C:\Program Files (x86)\Java\jdk1.6.0_18\bin How can I add it to "java.home" ? I'm using Win Vista, and I tried to add it from "System -> Environment Variables", but there is no "java.home" in there. Where can I find it ? Frank
favorite count: 0
tagged with: google-app-engine
has answer: http://stackoverflow.com/a/2681373
accepted answer: http://stackoverflow.com/a/2681373
possible better answer: http://stackoverflow.com/a/2681396
type: AnsweredQuestion
score: 1
tagged with: java
upvote count: 1
type: Question

http://stackoverflow.com/a/2657451
has body: The SD Java Profiler can capture statement block execution-count data no matter how short your run is. Relative execution counts will tell you where the time is spent.
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/2656059
downvote count: 0
type: Answer

http://stackoverflow.com/a/2781644
type: Answer
answers question: http://stackoverflow.com/q/2781574
score: 1
upvote count: 1
has body: Don't allow HTML tags. Don't output anything a user entered without HTML-escaping it first. This is the much more important point! Do this and you will not ever have an XSS problem. Provide a preview function so users can see what it will look like before posting. If you must allow HTML tags, define a whitelist and check user input against it. You can even use regex for this. Say you allow &lt;p&gt;, &lt;a href="..."&gt; and &lt;img src="..."&gt;: find everything in the user string that matches &lt;\S[^&gt;]*&gt; for every match, check it against &lt;(p|a href="[^"]+"|img src="[^"]+")/?&gt;|&lt;/(a|p)&gt; if it does not fit that rigorous regex, throw it away. See point #2 above. Try hard to deliberately break your system. Ask others to try and break your system.
downvote count: 0

http://stackoverflow.com/a/2763865
type: Answer
has comment: http://stackoverflow.com/comment/2796411
has body: (.+?) is an odd choice. Try ( *[0-9]+ *[A-Za-z]+ *[0-9]+ *) or just ([^&lt;]+) instead.
answers question: http://stackoverflow.com/q/2758708
score: 0

http://stackoverflow.com/comment/82608198
comment on: http://stackoverflow.com/a/14883245
type: AnswerComment
type: Comment
has text: works nicely, but how do I get it working in a batch file?
score: 0

http://stackoverflow.com/a/2653500
upvote count: 2
has body: Consider the following quote from an article about thread safety ("Java theory and practice: Characterizing thread safety"): In reality, any definition of thread safety is going to have a certain degree of circularity, as it must appeal to the class's specification -- which is an informal, prose description of what the class does, its side effects, which states are valid or invalid, invariants, preconditions, postconditions, and so on. (Constraints on an object's state imposed by the specification apply only to the externally visible state -- that which can be observed by calling its public methods and accessing its public fields -- rather than its internal state, which is what is actually represented in its private fields.) Thread safety For a class to be thread-safe, it first must behave correctly in a single-threaded environment. If a class is correctly implemented, which is another way of saying that it conforms to its specification, no sequence of operations (reads or writes of public fields and calls to public methods) on objects of that class should be able to put the object into an invalid state, observe the object to be in an invalid state, or violate any of the class's invariants, preconditions, or postconditions. Furthermore, for a class to be thread-safe, it must continue to behave correctly, in the sense described above, when accessed from multiple threads, regardless of the scheduling or interleaving of the execution of those threads by the runtime environment, without any additional synchronization on the part of the calling code. The effect is that operations on a thread-safe object will appear to all threads to occur in a fixed, globally consistent order. So your class itself is thread-safe, as long as it doesn't have any side effects. As soon as the methods mutate any external objects (e.g. some singletons, as already mentioned by others) it's not any longer thread-safe.
type: Answer
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/2653431

http://stackoverflow.com/q/2777535
has comment: http://stackoverflow.com/comment/6832849
score: 1
tagged with: java
has title: Obtaining FontMetrics before getting a Graphics instance
type: Question
has body: Typically, I'd obtain a graphics instance something like this: BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D g = img.createGraphics(); However, in the current project I'm working on, the width and height variables above are dependent upon the size of a number of text fragments that will later be drawn onto the graphics instance. But, to obtain the dimensions of the font being used I would usually use the FontMetrics that I get from the graphics object. FontMetrics metrics = g.getFontMetrics(); So, I have a nasty little dependency cycle. I cannot create the graphics object until I know the size of the text, and I cannot know the size of the text until I have a graphics object. One solution is just to create another BufferedImage/Graphics pair first in order to get the FontMetrics instance I need, but this seems unnecessary. So, is there a nicer way? Or is it the case that the width, height etc. properties for a Font are somehow dependent upon what (graphics, component...) the text is to be drawn on?
answer count: 1
downvote count: 0
tagged with: fontmetrics
favorite count: 0
has comment: http://stackoverflow.com/comment/6816548
has answer: http://stackoverflow.com/a/2778168
type: UnansweredQuestion
upvote count: 1

http://stackoverflow.com/comment/90556473
score: 0
type: AnswerComment
has text: One could even add a couple of lines of code to the returned `Iterable` instance to ensure that its `iterator()` is called only once. Just in case.
type: Comment
comment on: http://stackoverflow.com/a/2598254

http://stackoverflow.com/comment/2648072
score: 0
type: Comment
has text: Parent class loader delegation is an issue too, not just the class path. If naughty.jar is handled by a parent `ClassLoader` then the classes in it will always be resolved first (though a sealed package keeps this from happening as well).
comment on: http://stackoverflow.com/a/2633943
type: AnswerComment

http://stackoverflow.com/a/2605410
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/61789656
upvote count: 1
downvote count: 1
has body: Although you can't override the provided java.util.logging.Logger logger, you bind a new logger just like you would any other class: bind(Log.class).to(LogFactory.getLog(YourClass)); // or toInstance(...); But, creating a named logger is going to be a bit more difficult. If you dig through the Google Guice code (util.BinderImpl.java:87) you can see how they assign a distinct class name for each instance of the logger that's injected. However, I haven't inspected it carefully enough to know if it's easily reproducible. It might be possible to create a provider or inject a factory which somehow has access to the context so you can provide a named logger.
answers question: http://stackoverflow.com/q/2605198

http://stackoverflow.com/q/2685626
favorite count: 0
has answer: http://stackoverflow.com/a/10500258
has answer: http://stackoverflow.com/a/2685928
score: 11
has comment: http://stackoverflow.com/comment/102442318
tagged with: c++
type: AnsweredQuestion
tagged with: oop
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/2685987
has title: Explain Type Classes in Haskell
has body: I am a C++ / Java programmer and the main paradigm I happen to use in everyday programming is OOP. In some thread I read a comment that Type classes are more intuitive in nature than OOP. Can someone explain the concept of type classes in simple words so that an OOP guy like me can understand it?
has answer: http://stackoverflow.com/a/2685644
type: Question
has comment: http://stackoverflow.com/comment/2705836
upvote count: 11
possible better answer: http://stackoverflow.com/a/2685928
answer count: 6
has comment: http://stackoverflow.com/comment/2708990
tagged with: haskell
has answer: http://stackoverflow.com/a/2686004
tagged with: functional-programming
has answer: http://stackoverflow.com/a/2686021
accepted answer: http://stackoverflow.com/a/2686021

http://stackoverflow.com/q/2719153
has answer: http://stackoverflow.com/a/2719219
answer count: 3
has body: One of my interview Questions, if multiple users across the world are accessing the application, in which it uses a Table which has a Primary Key as Auto Increment Field. The Question how can you prevent the other user getting the Same Primary key when the other user is executing? My answer was I will obtain the Lock on the table and I will make the user to wait Until that user is released with the Primary key. But the Question How do you acquire the Table lock programmatically and implement this? If there are 1000 users coming every minute to the application, if you explicity hold the lock on the table, then the application will become slower? How do you manage this? Please suggest the possible answers for the above question
favorite count: 0
has answer: http://stackoverflow.com/a/2719179
has title: Acquiring Table Lock in Database - Interview Question
upvote count: 3
type: UnansweredQuestion
tagged with: php
score: 3
tagged with: java
tagged with: mysql
has answer: http://stackoverflow.com/a/2719218
type: Question
downvote count: 0

http://stackoverflow.com/a/2723864
score: 0
has comment: http://stackoverflow.com/comment/2750359
has body: ya but the problem is that the date which i am trying to extract is nested inside some text. So i was looking for a regex and using it with split method of string in java to extract the dates from the particular string.
answers question: http://stackoverflow.com/q/2723727
type: Answer

http://stackoverflow.com/comment/2776460
score: 0
type: Comment
has text: It doesn't allow me to delete it... Maybe mods can do it.
type: QuestionComment
comment on: http://stackoverflow.com/q/2746744

http://stackoverflow.com/a/2759303
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/2796523
has comment: http://stackoverflow.com/comment/2799511
answers question: http://stackoverflow.com/q/2757023
has comment: http://stackoverflow.com/comment/2797204
downvote count: 0
has body: I've never used hibernate, but based on the code provided it looks like the data from your database is returned in a List. Therefore you will need to create a custom TableModel to access the data in the List. The BeanTableModel might help you out.
type: Answer

http://stackoverflow.com/a/25391422
has comment: http://stackoverflow.com/comment/122986768
type: Answer
score: 3
upvote count: 3
downvote count: 0
has body: With Java 8, you can say Collection bunchOfItems = ...; bunchOfItems.stream().flatMap(k::getItems).forEach(i -&gt; /* operate on i */); or Item[] bunchOfItems = ...; Stream.of(bunchOfItems).flatMap(k::getItems).forEach(i -&gt; /* operate on i */); depending upon whether you have a Collection or an Array.
answers question: http://stackoverflow.com/q/2782893

http://stackoverflow.com/a/2749445
has comment: http://stackoverflow.com/comment/40031379
type: Answer
answers question: http://stackoverflow.com/q/2749375
has comment: http://stackoverflow.com/comment/39971738
has comment: http://stackoverflow.com/comment/39949932
has comment: http://stackoverflow.com/comment/40011496
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/40070423
has body: I accept that Java doesn't have great support for representing fractions, but you have to realise that it is impossible to keep things entirely precise when working with computers. At least in this case, the exception is telling you that precision is being lost. As far as I know, "infinite precision arithmetic with decimal numbers" just isn't going to happen. If you have to work with decimals, what you're doing is probably fine, just catch the exceptions. Otherwise, a quick google search finds some interesting resources for working with fractions in Java: http://commons.apache.org/math/userguide/fraction.html http://www.merriampark.com/fractions.htm Best way to represent a fraction in Java?
downvote count: 0
has comment: http://stackoverflow.com/comment/40012739
has comment: http://stackoverflow.com/comment/39980586

http://stackoverflow.com/a/2704190
upvote count: 0
answers question: http://stackoverflow.com/q/2704151
downvote count: 2
type: Answer
has body: You don't want to use File, you want to use java.io.ByteArrayInputStream
has comment: http://stackoverflow.com/comment/2727679
score: -2

http://stackoverflow.com/q/2672399
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2672425
has comment: http://stackoverflow.com/comment/36603126
downvote count: 0
tagged with: java
has body: I read this in Kathy Sierra's book: "Local variables are sometimes called stack, temporary, automatic, or method variables, but the rules for these variables are the same regardless of what you call them." Why are the local variables called automatic?
score: 19
type: Question
has answer: http://stackoverflow.com/a/2672425
has answer: http://stackoverflow.com/a/2672412
accepted answer: http://stackoverflow.com/a/2672412
tagged with: variables
upvote count: 19
answer count: 2
favorite count: 0
has title: Why are local variables also called "Automatic" in Java?
tagged with: local-variables

http://stackoverflow.com/comment/27081521
has text: It's strange how people are so afraid of pointers in C and are so fine with the *reference* idea in Java.
comment on: http://stackoverflow.com/a/2673458
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/2656995
has body: HashMap selections = new HashMap&lt;Integer, Float&gt;(); How can i get the Integer key of the 3rd smaller value of Float in all HashMap? Edit im using the HashMap for this for (InflatedRunner runner : prices.getRunners()) { for (InflatedMarketPrices.InflatedPrice price : runner.getLayPrices()) { if (price.getDepth() == 1) { selections.put(new Integer(runner.getSelectionId()), new Float(price.getPrice())); } } } i need the runner of the 3rd smaller price with depth 1 maybe i should implement this in another way?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2657045
has comment: http://stackoverflow.com/comment/2673873
tagged with: java
has answer: http://stackoverflow.com/a/2657015
has comment: http://stackoverflow.com/comment/2674022
has comment: http://stackoverflow.com/comment/2673897
type: Question
possible better answer: http://stackoverflow.com/a/2657003
score: 5
has comment: http://stackoverflow.com/comment/2673901
tagged with: hashmap
accepted answer: http://stackoverflow.com/a/2657015
tagged with: algorithm
has answer: http://stackoverflow.com/a/2657003
has title: nth item of hashmap
upvote count: 5
has answer: http://stackoverflow.com/a/2657000
has answer: http://stackoverflow.com/a/2657047
has comment: http://stackoverflow.com/comment/2673913
downvote count: 0
favorite count: 0
has comment: http://stackoverflow.com/comment/2673899
answer count: 5

http://stackoverflow.com/a/2708642
type: AcceptedAnswer
downvote count: 0
has body: I'm using the TinyMCE javascript editor Since you'd like to change the client side behaviour depending on the client, best is to handle this at the client side rather than the server side. In CSS world, you can hook on the media type to apply styles depending on the media used. Most used media types are screen (usually PCs), handheld (usually mobiles) and print (for the printed page). You can make use of it to hide the editor by just the following rule in your CSS: @media handheld { #elementIdContainingEditor { display: none; } } You can even specify separate stylesheets depending on the media used. If the problem is actually more that it doesn't work because JavaScript is disabled on the particular client, then you better have to execute the particular CSS when JS is disabled: Or the other way round, initially hide it and then show it when JS is enabled: This is more reliable than sniffing the agent in the server side.
type: Answer
accepted answer of: http://stackoverflow.com/q/2707374
answers question: http://stackoverflow.com/q/2707374
score: 4
upvote count: 4

http://stackoverflow.com/q/2651660
downvote count: 0
score: 1
tagged with: java
type: Question
has body: Is it possible to paint a JTable cell alone partially?Like 40% of it is green remaining is red?
answer count: 2
possible better answer: http://stackoverflow.com/a/2652927
tagged with: jtable
accepted answer: http://stackoverflow.com/a/2651695
upvote count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/2651695
has answer: http://stackoverflow.com/a/2652927
has title: Can we paint a JTable cell partially?
type: AnsweredQuestion

http://stackoverflow.com/q/2690143
tagged with: manifest
has body: I'm trying to compile a runnable jar-file for a project that makes use of hibernate. I'm trying to construct an ant build.xml file to streamline my build process, but I'm having troubles with the inclusion of the hibernate3.jar inside the final jar-file. If I run the ant script I manage to include all my library jars, and they are put in the final jar-file's root. When I run the jar-file I get a java.lang.NoClassDefFoundError: org/hibernate/Session error. If I make use of the built-in export to jar in Eclipse, it works only if I choose "extract required libraries into jar". But that bloats the jar, and includes too much of my project (i.e. unit tests). Below is my generated manifest: Manifest-Version: 1.0 Main-Class: main.ServerImpl Class-Path: ./ antlr-2.7.6.jar commons-collections-3.1.jar dom4j-1.6.1.jar hibernate3.jar javassist-3.9.0.GA.jar jta-1.1.jar slf4j-api-1.5.11.jar slf4j-simple-1.5.11.jar mysql-connector-java-5.1.12-bin.jar rmiio-2.0.2.jar commons-logging-1.1.1.jar And the part of the build.xml looks like this: &lt;target name="dist" depends="compile" description="Generates the Distribution Jar(s)"&gt; &lt;mkdir dir="${dist.dir}" /&gt; &lt;jar destfile="${dist.dir}/${dist.file.name}.jar" basedir="${build.prod.dir}" filesetmanifest="mergewithoutmain"&gt; &lt;manifest&gt; &lt;attribute name="Main-Class" value="${main.class}" /&gt; &lt;attribute name="Class-Path" value="./ ${manifest.classpath} " /&gt; &lt;attribute name="Implementation-Title" value="${app.name}" /&gt; &lt;attribute name="Implementation-Version" value="${app.version}" /&gt; &lt;attribute name="Implementation-Vendor" value="${app.vendor}" /&gt; &lt;/manifest&gt; &lt;zipfileset refid="hibernatefiles" /&gt; &lt;zipfileset refid="slf4jfiles" /&gt; &lt;zipfileset refid="mysqlfiles" /&gt; &lt;zipfileset refid="commonsloggingfiles" /&gt; &lt;zipfileset refid="rmiiofiles" /&gt; &lt;/jar&gt; &lt;/target&gt; The refids' for the zipfilesets point to the directories in a library directory lib in the roo…
has answer: http://stackoverflow.com/a/2690340
favorite count: 0
upvote count: 2
has title: Including hibernate jar dependencies in ant build
accepted answer: http://stackoverflow.com/a/2690340
type: AnsweredQuestion
score: 2
tagged with: java
tagged with: hibernate
type: Question
tagged with: ant
answer count: 1
tagged with: executable-jar
downvote count: 0

http://stackoverflow.com/a/2702670
has comment: http://stackoverflow.com/comment/2725900
upvote count: 5
answers question: http://stackoverflow.com/q/2702624
accepted answer of: http://stackoverflow.com/q/2702624
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2741152
score: 5
type: Answer
has comment: http://stackoverflow.com/comment/2725922
has comment: http://stackoverflow.com/comment/2726569
has body: First of all, BalusC is right. Secondly: If you're taking decisions based on the class type, you're not letting the polymorphism do its job. Your class structure may be wrong ( Like Car and Person should not be in the same hierarchy ) You could probably create an interface and code to it. interface Fooable { Fooable createInstance(); void doFoo(); void doBar(); } class Car implements Fooable { public Fooable createInstance() { return new Car(); } public void doFoo(){ out.println("Brroooom, brooooom"); } public void doBar() { out.println("Schreeeeeeeekkkkkt"); } } class Person implements Fooable { public Fooable createInstance(){ return new Person(); } public void foo() { out.println("ehem, good morning sir"); } public void bar() { out.println("Among the nations as among the individuals, the respect for the other rights means peace..");// sort of } } Later ... public class Xpto{ protected Fooable x; public void foo(){ Fooable y = x.createInstance(); // no more operations that depend on y's type. // let polymorphism take charge. y.foo(); x.bar(); } }

http://stackoverflow.com/comment/2781004
comment on: http://stackoverflow.com/a/2750751
score: 1
has text: I know very well what it does. I would say that your example exhibits a *bad practice* of instanceof. I would probably want to eliminate that conditional using polymorphism as described [here](http://sourcemaking.com/refactoring/replace-conditional-with-polymorphism)
type: Comment
type: AnswerComment

http://stackoverflow.com/a/3568203
type: Answer
has comment: http://stackoverflow.com/comment/3742138
accepted answer of: http://stackoverflow.com/q/2656159
answers question: http://stackoverflow.com/q/2656159
upvote count: 4
type: AcceptedAnswer
downvote count: 0
has body: Unfortunately, there isn't a configurable way to prevent that. Every task for a job gets one directory in history/userlogs, which will hold the stdout, stderr, and syslog task log output files. The retain hours will help keep too many of those from accumulating, but you'd have to write a good log rotation tool to auto-tar them. We had this problem too when we were writing to an NFS mount, because all nodes would share the same history/userlogs directory. This means one job with 30,000 tasks would be enough to break the FS. Logging locally is really the way to go when your cluster actually starts processing a lot of data. If you are already logging locally and still manage to process 30,000+ tasks on one machine in less than a week, then you are probably creating too many small files, causing too many mappers to spawn for each job.
score: 4

http://stackoverflow.com/q/2597965
answer count: 7
favorite count: 0
linked to: http://stackoverflow.com/q/2589741
has comment: http://stackoverflow.com/comment/4134298
upvote count: 47
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2597985
has answer: http://stackoverflow.com/a/2599489
has body: A number of times I've argued that using clone() isn't such a bad practice. Yes, I know the arguments. Bloch said it's bad. He indeed did, but he said that implementing clone() is bad. Using clone on the other hand, especially if it is implemented correctly by a trusted library, such as the JDK, is OK. Just yesterday I had a discussion about an answer of mine that merely suggests that using clone() for ArrayList is OK (and got no upvotes for that reason, I guess). If we look at the @author of ArrayList, we can see a familiar name - Josh Bloch. So clone() on ArrayList (and other collections) is perfectly fine (just look at their implementations). Same goes for Calendar and perhaps most of the java.lang and java.util classes. So, give me a reason why not to use clone() with JDK classes?
has answer: http://stackoverflow.com/a/2597997
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/2598004
has answer: http://stackoverflow.com/a/2598054
has title: Why people are so afraid of using clone() (on collection and JDK classes)?
type: Question
has comment: http://stackoverflow.com/comment/2606490
accepted answer: http://stackoverflow.com/a/2599165
score: 47
has comment: http://stackoverflow.com/comment/13594138
linked to: http://stackoverflow.com/q/2592985
possible better answer: http://stackoverflow.com/a/2597997
has answer: http://stackoverflow.com/a/2599165
has answer: http://stackoverflow.com/a/2597986

http://stackoverflow.com/q/2605747
answer count: 5
tagged with: maven
has body: By default during the build process maven is removing the empty directories. Do you know if a parameter can be specified in the pom to instruct maven to include empty directories in the generated target/test-classes folder?
has answer: http://stackoverflow.com/a/31116203
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/18197329
tagged with: java
accepted answer: http://stackoverflow.com/a/2605769
type: Question
has answer: http://stackoverflow.com/a/2605774
upvote count: 36
downvote count: 0
has answer: http://stackoverflow.com/a/2607131
has title: Maven - how to include empty directories
score: 36
possible better answer: http://stackoverflow.com/a/2607131
tagged with: directory
has answer: http://stackoverflow.com/a/2605769
favorite count: 0

http://stackoverflow.com/comment/10528996
comment on: http://stackoverflow.com/a/2780103
score: 12
type: AnswerComment
has text: This is from json-lib, not gson!
type: Comment

http://stackoverflow.com/comment/2629646
has text: possible duplicate of http://stackoverflow.com/questions/759376/alternative-to-jfilechooser
comment on: http://stackoverflow.com/q/2617762
score: 0
type: Comment
type: QuestionComment

heap-memory
tag name: heap-memory
tags question: http://stackoverflow.com/q/2718786
tags question: http://stackoverflow.com/q/2665100
tags question: http://stackoverflow.com/q/2747111
tags question: http://stackoverflow.com/q/2692745
tags question: http://stackoverflow.com/q/2735573
type: Tag
tags question: http://stackoverflow.com/q/2657525

http://stackoverflow.com/comment/2773567
score: 0
type: AnswerComment
has text: @Jon oh, please, keep this guy away from knives & guns! ;-) Point taken.
type: Comment
comment on: http://stackoverflow.com/a/2743470

http://stackoverflow.com/comment/44943556
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/2758642
has text: Yes you can, and I just found out how. See the page [custom-eclipse-perspective-with-initially-invisble-view-stacked-to-editor-area][1]. [1]: http://stackoverflow.com/questions/22921306/custom-eclipse-perspective-with-initially-invisble-view-stacked-to-editor-area
score: 0

http://stackoverflow.com/a/2624375
score: 16
has body: You may use clone() which works well if your object has immutable objects and/or primitives, but it may be a little problematic when you don't have these ( such as collections ) for which you may need to perform a deep clone. User userCopy = (User) user.clone();//make a copy for(...) { user.age = 1; user.id = -1; UserDao.update(user) user = userCopy; } It seems like you just want to preserve the attributes: age and id which are of type int so, why don't you give it a try and see if it works. For more complex scenarios you could create a "copy" method: publc class User { public static User copy( User other ) { User newUser = new User(); newUser.age = other.age; newUser.id = other.id; //... etc. return newUser; } } It should take you about 10 minutes. And then you can use that instead: User userCopy = User.copy( user ); //make a copy // etc. To read more about clone read this chapter in Joshua Bloch "Effective Java: Override clone judiciously"
downvote count: 0
answers question: http://stackoverflow.com/q/2624165
type: Answer
upvote count: 16

http://stackoverflow.com/a/2748421
score: 0
has body: While you should be fine, its a good idea to include not only the actual certificate for your site, but also the entire chain leading up to the root certificate. (Sometimes you'll bump into clients which are missing some intermediate certificates and this can cause annoying debugging problems.)
type: Answer
answers question: http://stackoverflow.com/q/2739955

http://stackoverflow.com/comment/48700921
type: QuestionComment
type: Comment
score: 2
has text: Java 8's Stream.boxed() will take care of the autoboxing and can be used for this. See my answer [below](http://stackoverflow.com/a/30281879/752918).
comment on: http://stackoverflow.com/q/2607289

http://stackoverflow.com/a/2756809
downvote count: 0
answers question: http://stackoverflow.com/q/2756794
has comment: http://stackoverflow.com/comment/2788457
has comment: http://stackoverflow.com/comment/2788691
type: Answer
has comment: http://stackoverflow.com/comment/2788270
accepted answer of: http://stackoverflow.com/q/2756794
has comment: http://stackoverflow.com/comment/2788314
has comment: http://stackoverflow.com/comment/2788328
has comment: http://stackoverflow.com/comment/2788398
upvote count: 4
has comment: http://stackoverflow.com/comment/2788343
has body: The s.next() takes care of the white-spaces. (The default tokenizer doesn't care about them.) import java.util.Scanner; public class Test { public static void main(String... args) { Scanner s = new Scanner(System.in); while (s.hasNext()) System.out.println(Integer.parseInt(s.next(), 16)); } } If you'd really like to stick with the Pattern-approach, I would recommend you to use the XDigit class: \p{XDigit} A hexadecimal digit: [0-9a-fA-F] Further more; The scanner.next(pattern) will return the entire matched pattern (including the white-spaces!) You need to work with capturing groups. Try the pattern ^\\s*(\\p{XDigit}+)\\s*$ And then get the actual hex-number with matcher.group(1)
has comment: http://stackoverflow.com/comment/2788622
score: 4
type: AcceptedAnswer

http://stackoverflow.com/comment/50495913
comment on: http://stackoverflow.com/a/2644534
score: 0
type: AnswerComment
type: Comment
has text: That's better than nothing. Thanks! However, I wish it also worked in block selects. :( It appears you really do have to do this one at a time.

smtp
tags question: http://stackoverflow.com/q/2681481
tags question: http://stackoverflow.com/q/2675824
tag name: smtp
tags question: http://stackoverflow.com/q/2643791
type: Tag
tags question: http://stackoverflow.com/q/2689177

sockets
tags question: http://stackoverflow.com/q/2717459
tags question: http://stackoverflow.com/q/2661022
tags question: http://stackoverflow.com/q/2675611
tags question: http://stackoverflow.com/q/2597693
tags question: http://stackoverflow.com/q/2749236
tags question: http://stackoverflow.com/q/2776729
tags question: http://stackoverflow.com/q/2607515
tags question: http://stackoverflow.com/q/2765636
tags question: http://stackoverflow.com/q/2777005
tags question: http://stackoverflow.com/q/2687238
type: Tag
tags question: http://stackoverflow.com/q/2675362
tags question: http://stackoverflow.com/q/2717023
tags question: http://stackoverflow.com/q/2750422
tags question: http://stackoverflow.com/q/2620687
tags question: http://stackoverflow.com/q/2687736
tags question: http://stackoverflow.com/q/2627706
tags question: http://stackoverflow.com/q/2772310
tags question: http://stackoverflow.com/q/2653118
tags question: http://stackoverflow.com/q/2630009
tag name: sockets
tags question: http://stackoverflow.com/q/2673045
tags question: http://stackoverflow.com/q/2718741
tags question: http://stackoverflow.com/q/2778325
tags question: http://stackoverflow.com/q/2719674
tags question: http://stackoverflow.com/q/2661659
tags question: http://stackoverflow.com/q/2642083
tags question: http://stackoverflow.com/q/2694797
tags question: http://stackoverflow.com/q/2784830
tags question: http://stackoverflow.com/q/2676890
tags question: http://stackoverflow.com/q/2719253
tags question: http://stackoverflow.com/q/2733078
tags question: http://stackoverflow.com/q/2680993
tags question: http://stackoverflow.com/q/2772324
tags question: http://stackoverflow.com/q/2705600

http://stackoverflow.com/a/2758816
has comment: http://stackoverflow.com/comment/2790884
has comment: http://stackoverflow.com/comment/2791186
has comment: http://stackoverflow.com/comment/2791060
type: Answer
has comment: http://stackoverflow.com/comment/2791099
has body: Make sure the files are in the same directory, with the same name as the package. Also, make sure the classpath is set correctly. Packages mimic the directory structure - "Test.java" in package "org.example.test" should be found at "org/example/test/Test.java". The following compiled your files for me: $ javac -cp "." *.java And I ran with $ cd .. $ java pacc.PackTest No problems here. BTW Apache Ant is generally preferred over makefiles in the Java universe.
answers question: http://stackoverflow.com/q/2758799
score: 6
downvote count: 0
has comment: http://stackoverflow.com/comment/2790716
has comment: http://stackoverflow.com/comment/2791255
has comment: http://stackoverflow.com/comment/2790747
has comment: http://stackoverflow.com/comment/2791161
has comment: http://stackoverflow.com/comment/2790610
upvote count: 6

http://stackoverflow.com/comment/12496044
comment on: http://stackoverflow.com/a/2671938
type: Comment
score: 23
has text: I don't understand the part about not being able to unit-test procedural code. Don't you just set up test cases that map correct input to correct output using the static method together with the class as your "unit"?
type: AnswerComment

http://stackoverflow.com/comment/123771889
type: Comment
score: 2
comment on: http://stackoverflow.com/a/2651833
type: AnswerComment
has text: @aderchox if you have a `Set<Pair<K,V>>`, you can’t ask whether it contains a particular `K`, as the contract of `contains` requires to return `true` if the particular object is within the set, which must be an instance of `Pair` having the same `K` *and* `V` to match. The same applies to the contract of `remove`. This is exactly the behavior of the set returned by `entrySet()` whose `contains` and `remove` methods operate in terms of `Map.Entry<K,V>` elements. Which is an entirely different API than `Map` itself, which has `containsKey`, `remove(key)`, etc, which is what this is all about..

http://stackoverflow.com/a/2623175
type: Answer
answers question: http://stackoverflow.com/q/2623091
accepted answer of: http://stackoverflow.com/q/2623091
has comment: http://stackoverflow.com/comment/2635720
score: 5
has body: Serialization is basically deep cloning. You need to track each object reference for reoccurrencies (for example by using IdentityHashMap). What ever is your final implementation method (if not external library) remember to check for object reoccurrencies or you may end up in an infinent loop (when object A has reference to object B that again has reference to object A or something more complex loop in an object graph). One way is to traverse through object graph with DFS-like algorithm and build the clone (serialized string) from there. This pseudo-code hopefully explains how: visited = {} function visit(node) { if node in visited { doStuffOnReoccurence(node) return } visited.add(node) doStuffBeforeOthers(node) for each otherNode in node.expand() visit(otherNode) doStuffAfterOthers(node) } The visited set in the example is where I would use identity set (if there was one) or IdentityHashMap. When finding out fields reflectively (thats the node.expand() part) remember to go through superclass fields also. Reflection should not be used in a "normal" development case. Reflection handles code as a data and you can ignore all normal object access restrictions. I've used this reflective deep copy stuff only for tests: In a test that checked different kinds of objects for deep object graph equality In a test that analyzed object graph size and other properties
upvote count: 5
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2635679

http://stackoverflow.com/comment/2639518
type: Comment
type: QuestionComment
has text: Yes the question is not clear. What do you mean "I've noticed that addAMeasurableThing in the CargoAirplane class never gets called, because both methods have the same signature. " what is your test class implementation?
comment on: http://stackoverflow.com/q/2626482
score: 0

http://stackoverflow.com/comment/110556906
type: AnswerComment
score: 0
type: Comment
has text: This did not work for me. javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security. provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
comment on: http://stackoverflow.com/a/50274496

http://stackoverflow.com/comment/2727929
type: Comment
type: QuestionComment
score: 16
comment on: http://stackoverflow.com/q/2704417
has text: Perhaps the benchmark also does not reflect the strengths of Go. It may be that other benchmarks are actually faster than this. Besides, often it's not the performance but the readability of the code that counts most.

http://stackoverflow.com/q/2633002
has comment: http://stackoverflow.com/comment/2646570
score: 6
answer count: 3
has answer: http://stackoverflow.com/a/2633043
has answer: http://stackoverflow.com/a/2633176
has comment: http://stackoverflow.com/comment/2647607
downvote count: 0
favorite count: 0
has title: Handling downloads in Java
has body: How would I be able to handle downloads using HttpResponse in Java? I made an HttpGet request to a specific site - the site returns the file to be downloaded. How can I handle this download? InputStream doesn't seem to be able to handle it (or maybe I'm using it the wrong way.)
upvote count: 6
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2633176
tagged with: java
possible better answer: http://stackoverflow.com/a/2633061
has answer: http://stackoverflow.com/a/2633061
type: Question
tagged with: apache-httpcomponents

http://stackoverflow.com/a/2681908
has body: Well, I think that using multiple return is not readable. I prefer code as: String result = null; doLotOfStuff(); if (condition) { result = foo; } else { result = bar; } return result; Multiple returns is complicated to understand. But in your case I will prefer the postCheck doLotOfStuff(); if (condition) { return foo; } else { return bar; }
score: 4
has comment: http://stackoverflow.com/comment/58064195
has comment: http://stackoverflow.com/comment/2701581
has comment: http://stackoverflow.com/comment/2701566
upvote count: 5
type: Answer
has comment: http://stackoverflow.com/comment/2701531
answers question: http://stackoverflow.com/q/2681883
downvote count: 1
has comment: http://stackoverflow.com/comment/2706405

http://stackoverflow.com/q/2759300
has comment: http://stackoverflow.com/comment/2791068
score: 1
tagged with: java
tagged with: hibernate
upvote count: 1
type: Question
has title: How to set up jndi.properties for DataStore?
has body: I'm struggling to set connect a Java program to MySQL using JPA/Hibernate. I'm currently getting the following error when I try to call createEntityManagerFactory(): [main] ERROR org.hibernate.connection.DatasourceConnectionProvider - Could not find datasource: java:jdbc/myDataDS javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288) at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325) at javax.naming.InitialContext.lookup(InitialContext.java:392) at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:75) Googling seems to indicate that I need a jndi.properties file in META-INF in my classpath, but I can't seem to find any information about what that file should contain in my case. Edit: I'm running this stand-alone, for the time being.
has answer: http://stackoverflow.com/a/2759542
tagged with: jndi
tagged with: jpa
tagged with: datasource
answer count: 1
downvote count: 0
favorite count: 0
type: UnansweredQuestion

http://stackoverflow.com/a/2744618
upvote count: 8
type: Answer
score: 8
answers question: http://stackoverflow.com/q/2743741
has body: There is no way to lock a file in Android; even if there was, the files would only be locked when your application was running which wouldn't stop other apps accessing the file when the user hadn't started your app. SD Cards are usually formatted with FAT (or FAT32) and this is the case with Android. FAT offers very limited file permissions so you can't restrict access to the files this way. Again, even if you could do something like this, this wouldn't offer any protection if the user took the SD Card out of their phone and put it their PC. If you want to keep your application's files private you need to put them in the phone's internal storage in the area reserved for you application. Each application runs with a different User ID and each application's data directory is protected using UNIX-style file permissions which prevents other applications from reading them. So while this will stop other applications having access to your files it wouldn't stop a reasonably determined user with root access to their phone copying them off. Have a look at the Context.openFileInput(), Content.openFileOutput() and Context.getFilesDir() methods for details on how to store files in the phone's internal storage.
downvote count: 0

http://stackoverflow.com/q/2655580
has title: How can I get username of a gtalk user using XMPP with google appengine?
score: 2
upvote count: 2
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/2655611
tagged with: google-talk
has body: I am using google appengine for my gtalk agent , I want to get the username of the gtalk user how can I get it ? for your reference, check this XMPPService xmpp = XMPPServiceFactory.getXMPPService(); //STEP 2 Message msg = xmpp.parseMessage(req); JID fromJid = msg.getFromJid(); I am using the above things in the beginning .....
tagged with: xmpp
answer count: 1
downvote count: 0
favorite count: 0
type: UnansweredQuestion
tagged with: google-app-engine

http://stackoverflow.com/comment/31307190
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/2631684
has text: See similar issue at http://stackoverflow.com/questions/2411487/nullpointerexception-in-java-with-no-stacktrace

http://stackoverflow.com/comment/11369068
score: 0
type: Comment
has text: Snipping Tool does the trick on Win7. Thanks for the screenshot. This is just what I needed tonight! :)
comment on: http://stackoverflow.com/a/2612688
type: AnswerComment

http://stackoverflow.com/comment/102402494
comment on: http://stackoverflow.com/a/2697225
type: Comment
has text: "Mixed case" is also called "camel case". I do prefer the latter.
score: 0
type: AnswerComment

http://stackoverflow.com/q/2736389
has answer: http://stackoverflow.com/a/38359743
has answer: http://stackoverflow.com/a/31376154
has answer: http://stackoverflow.com/a/16638897
downvote count: 2
has answer: http://stackoverflow.com/a/68405985
has answer: http://stackoverflow.com/a/32933092
has answer: http://stackoverflow.com/a/2737115
tagged with: android-intent
has comment: http://stackoverflow.com/comment/53691608
accepted answer: http://stackoverflow.com/a/2736612
has answer: http://stackoverflow.com/a/37774966
type: Question
has answer: http://stackoverflow.com/a/2736843
tagged with: object
has title: How to pass an object from one activity to another on Android
linked to: http://stackoverflow.com/q/15999934
has answer: http://stackoverflow.com/a/7683528
tagged with: java
has answer: http://stackoverflow.com/a/5998148
has answer: http://stackoverflow.com/a/68635378
has answer: http://stackoverflow.com/a/42791765
has answer: http://stackoverflow.com/a/9009808
has answer: http://stackoverflow.com/a/62406575
has body: I am trying to work on sending an object of my customer class from one Activity and displaying it in another Activity. The code for the customer class: public class Customer { private String firstName, lastName, address; int age; public Customer(String fname, String lname, int age, String address) { firstName = fname; lastName = lname; age = age; address = address; } public String printValues() { String data = null; data = "First Name :" + firstName + " Last Name :" + lastName + " Age : " + age + " Address : " + address; return data; } } I want to send its object from one Activity to another and then display the data on the other Activity. How can I achieve that?
has answer: http://stackoverflow.com/a/2736791
has answer: http://stackoverflow.com/a/28829345
has answer: http://stackoverflow.com/a/21255137
has answer: http://stackoverflow.com/a/20056245
upvote count: 901
score: 899
has answer: http://stackoverflow.com/a/33773343
has answer: http://stackoverflow.com/a/7827593
has answer: http://stackoverflow.com/a/44243488
favorite count: 0
has answer: http://stackoverflow.com/a/28683252
has answer: http://stackoverflow.com/a/18165425
has answer: http://stackoverflow.com/a/2736612
has answer: http://stackoverflow.com/a/25693086
has answer: http://stackoverflow.com/a/26696682
has comment: http://stackoverflow.com/comment/114823547
has answer: http://stackoverflow.com/a/7454611
has answer: http://stackoverflow.com/a/11120538
has answer: http://stackoverflow.com/a/6923794
tagged with: android
has comment: http://stackoverflow.com/comment/115065715
has answer: http://stackoverflow.com/a/10179861
linked to: http://stackoverflow.com/q/14333449
possible better answer: http://stackoverflow.com/a/7827593
has answer: http://stackoverflow.com/a/44721066
tagged with: android-activity
linked to: http://stackoverflow.com/q/45617564
has answer: http://stackoverflow.com/a/16365132
has answer: http://stackoverflow.com/a/19700319
has answer: http://stackoverflow.com/a/69159469
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21658902
answer count: 35

http://stackoverflow.com/a/11329499
upvote count: 1
has body: What errors did you get?if you did not get any error it means the orbd started. i use 1050 on different computers ,it did not work on some of them.try 1049 or 777.
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2720731
score: 1

http://stackoverflow.com/comment/2728907
type: AnswerComment
comment on: http://stackoverflow.com/a/2704955
score: 0
type: Comment
has text: Thanks - on the question "you have an interface with a bunch of constants in it" that is incorrect. Just a simple class with static named quires in it.

wcf
tags question: http://stackoverflow.com/q/2663891
type: Tag
tag name: wcf
tags question: http://stackoverflow.com/q/2696783
tags question: http://stackoverflow.com/q/2723186
tags question: http://stackoverflow.com/q/2742793
tags question: http://stackoverflow.com/q/2772595
tags question: http://stackoverflow.com/q/2719198

http://stackoverflow.com/q/2706256
tagged with: data-structures
has body: There are different collections are used in Java like hashtable, hashset, vector, treeset, treemap and hashmap. How are they implemented internally? What are the actual datastructure used for these collection? And, What is order? It would be good if we discuss just a little bit about implementation of collection.
score: 0
has comment: http://stackoverflow.com/comment/2729892
answer count: 5
has comment: http://stackoverflow.com/comment/2729911
linked to: http://stackoverflow.com/q/559839
tagged with: big-o
has answer: http://stackoverflow.com/a/2706320
has answer: http://stackoverflow.com/a/2706377
has answer: http://stackoverflow.com/a/2706282
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2706384
tagged with: java
has title: What is the actual datastructure used in implementation of collection and their order?
type: Question
has answer: http://stackoverflow.com/a/61349461

http://stackoverflow.com/a/2644800
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/2644771
has comment: http://stackoverflow.com/comment/2659887
has comment: http://stackoverflow.com/comment/2659997
has comment: http://stackoverflow.com/comment/2659875
has body: testValue is a member variable, so the two threads see two independent copies. volatile is relevant when two or more threads have a reference to the same object. Make testValue static and volatile will have an effect. However, you may not (and probably will not) see that effect, as it is highly dependent on timing, scheduling and caching strategies which are out of your (or even the VM's) control. A missing volatile will only rarely have an effect, which makes such bugs very hard to catch. It will only be seen when a thread updates the value and the second thread reads the value and the value is still in the cache in either of the two threads.
upvote count: 1
type: Answer

http://stackoverflow.com/comment/117616531
comment on: http://stackoverflow.com/a/2685668
score: 0
type: AnswerComment
has text: @CorneliusJ.vanDyk No, this is Java. (I have no idea what you think this is.)
type: Comment

http://stackoverflow.com/comment/2694537
type: AnswerComment
has text: there is a similar (and more complete, IIRC) list that comes as part of nmap. +1
comment on: http://stackoverflow.com/a/2675513
score: 0
type: Comment

http://stackoverflow.com/comment/2819278
has text: So you're parsing an entire html file (as a stream). AFAIK, ANTLR can handle streams just fine, but writing a full html parser yourself is no trivial task, and I can't imagine there's no tool already out there that doe this. So, I'd ask people here if they know of such a tool instead of asking to help you create such a thing with ANTLR (or something similar).
comment on: http://stackoverflow.com/q/2773910
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/comment/2618902
has text: If he really *needs* the code for his homework because its hard for him, then he really needs to do it himself to get the practice.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2608446
score: 3

http://stackoverflow.com/a/2783473
downvote count: 0
has comment: http://stackoverflow.com/comment/6357270
type: Answer
score: 4
answers question: http://stackoverflow.com/q/2783190
upvote count: 4
has body: You need to make sure that the streams returned by getInputStream() and getOutputStream() are drained on individual threads and these threads are different from the one on which you close the stream returned by getOutputStream(). Basically it is a requirement to have at least 3 threads per sub-process if you want to manipulate and examine its stdin, stdout and stderr. One of the threads, depending on your circumstances, may be your current execution thread ( the one on which you create ProcessBuilder ).

http://stackoverflow.com/comment/18198028
comment on: http://stackoverflow.com/a/13336323
score: 0
type: AnswerComment
type: Comment
has text: OP found that out and indicated it in the comment on the question

http://stackoverflow.com/a/2643667
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2643641
downvote count: 0
answers question: http://stackoverflow.com/q/2643641
has comment: http://stackoverflow.com/comment/2658944
type: Answer
has comment: http://stackoverflow.com/comment/2660826
has comment: http://stackoverflow.com/comment/70535694
score: 40
upvote count: 40
has body: There are some hacky ways of doing this in JPA 1, but it's easiest to switch to a JPA 2 provider. The @OrderColumn annotation support is what you're looking for. Eclipselink have an ok tutorial on how to use it.
has comment: http://stackoverflow.com/comment/12571998

http://stackoverflow.com/comment/2796899
type: Comment
comment on: http://stackoverflow.com/a/2743748
score: 0
type: AnswerComment
has text: Nice! I never thought that it was possible! You have deep knowledge of everything Java related.

http://stackoverflow.com/comment/16621744
has text: But why is it important to distinguish a class from an interface? From a user's perspective, I don't think it really matters. All I would care about is that the types are compatable.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2729070

http://stackoverflow.com/a/13690003
has body: It depends on your definition of create account... it is possible to create an account inside a google group, or domain. By using the code below you can create accounts for your google group/domain. For this scenario YES you CAN create a google account. However, if you want to create a google account as in @gmail.com... I really have not found a way to do it programatically. Here is the link of where to download the google api, and the Documentation. https://developers.google.com/google-apps/provisioning/#creating_a_user_account Good Luck. import sample.appsforyourdomain.AppsForYourDomainClient; AppsForYourDomainClient client = new AppsForYourDomainClient(email, password, domain); client.createUser(String username, String givenName, String familyName, String password)
type: Answer
upvote count: 4
score: 3
answers question: http://stackoverflow.com/q/2699008
downvote count: 1

http://stackoverflow.com/q/2621996
answer count: 3
tagged with: android
has answer: http://stackoverflow.com/a/2622140
favorite count: 0
score: 2
upvote count: 2
has body: I'm working on an Android app in which I would like to use multi-touch. However, I do not want to completely leave out those still running a 1.x OS phone. How do you program the app so that you can use the 2.x multi-touch APIs (or any other higher level API for that matter) and still allow it to gracefully degrade on 1.x systems. If you create a project in Eclipse for 1.x can you even still access the 2.x APIs? Basically I want it to show up in the marketplace and work on all 1.6 and higher phones and just allow access to the higher level functionality if available. Also, if anyone can point me to any data on the number of 1.x devices vs. 2.x devices in use, it would be greatly appreciated.
type: Question
has title: Android app using 2.x APIs that will also run on 1.x
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/2622140
tagged with: eclipse
possible better answer: http://stackoverflow.com/a/2622095
has answer: http://stackoverflow.com/a/2622095
downvote count: 0
has answer: http://stackoverflow.com/a/7826268

http://stackoverflow.com/a/29208516
type: Answer
has body: You can use a jasper report to call your gorm but you need to set the language for the report to groovy not java as it's default. Then if you use subreports you need to disable jasper report multithreading and add additional jars. It's just work perfectly.
answers question: http://stackoverflow.com/q/2730777
score: 0

http://stackoverflow.com/q/2763454
has body: I'm having a little trouble with my MySQL- Connection- Pooling. This is the case: Different jobs are scheduled via Quartz. All jobs connect to different databases which works fine the whole day while the nightly scheduled jobs fail with a CommunicationsException... Quartz-Jobs: Job1 runs 0 0 6,10,14,18 * * ? Job2 runs 0 30 10,18 * * ? Job3 runs 0 0 5 * * ? As you can see the last job runs at 18 taking about 1 hour to run. The first job at 5am is the one that fails. I already tried all kinds of parameter-combinations in my resource config this is the one I am running right now: &lt;!-- Database 1 (MySQL) --&gt; &lt;Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxActive="100" maxIdle="30" maxWait="10000" removeAbandoned="true" removeAbandonedTimeout="60" logAbandoned="true" type="javax.sql.DataSource" name="jdbc/appDbProd" username="****" password="****" url="jdbc:mysql://127.0.0.1:3306/appDbProd?autoReconnect=true&amp;amp;useUnicode=true&amp;amp;characterEncoding=UTF-8" testWhileIdle="true" testOnBorrow="true" testOnReturn="true" validationQuery="SELECT 1" timeBetweenEvictionRunsMillis="1800000" /&gt; &lt;!-- Database 2 (MySQL) --&gt; &lt;Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxActive="100" maxIdle="30" maxWait="10000" removeAbandoned="true" removeAbandonedTimeout="60" logAbandoned="true" type="javax.sql.DataSource" name="jdbc/prodDbCopy" username="****" password="****" url="jdbc:mysql://127.0.0.1:3306/prodDbCopy?autoReconnect=true&amp;amp;useUnicode=true&amp;amp;characterEncoding=UTF-8" testWhileIdle="true" testOnBorrow="true" testOnReturn="true" validationQuery="SELECT 1" timeBetweenEvictionRunsMillis="1800000" /&gt; &lt;!-- Database 3 (MSSQL)--&gt; &lt;Resource auth="Container" driverClassName="net.sourceforge.jtds.jdbc.Driver" maxActive="30" maxIdle="30" maxWait="100" removeAbandoned="true" removeAbandonedTimeout="60" logAbandoned="true" name="jdbc/catalogDb" username="****" password="****" type="javax.sql.DataSou…
has comment: http://stackoverflow.com/comment/2795813
tagged with: quartz-scheduler
upvote count: 1
has answer: http://stackoverflow.com/a/2763472
has comment: http://stackoverflow.com/comment/11737277
type: Question
has comment: http://stackoverflow.com/comment/2828777
has answer: http://stackoverflow.com/a/4447160
answer count: 3
has comment: http://stackoverflow.com/comment/3614705
has comment: http://stackoverflow.com/comment/2796635
downvote count: 0
tagged with: tomcat
favorite count: 0
has title: JDBC CommunicationsException with MySQL Database
has answer: http://stackoverflow.com/a/2763494
tagged with: jdbc
type: UnansweredQuestion
score: 1
tagged with: java

http://stackoverflow.com/comment/2788199
type: QuestionComment
comment on: http://stackoverflow.com/q/2756567
has text: Java **source files** don't belong on the classpath. The classpath is the collection of directories and JAR files where the JVM looks for **class** files (compiled source code).
score: 0
type: Comment

http://stackoverflow.com/comment/2709979
type: AnswerComment
has text: Thanks, Steven! Good point about there being no need to actually put nulls into the map -- I must have spaced out there. And yeah, I think C# definitely has better idioms for these things these days.
type: Comment
comment on: http://stackoverflow.com/a/2684447
score: 0

http://stackoverflow.com/q/2683735
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/2683807
linked to: http://stackoverflow.com/q/2636129
has title: Can I refer to an object in its constructor?
has body: Can I do the following? public Manager(String userName) { game = new Game(userName); game.addManager(this); } The problem is that I refer to an object (this) in its constructor (before it was actually created).
tagged with: oop
has answer: http://stackoverflow.com/a/2684111
score: 4
has answer: http://stackoverflow.com/a/2683785
tagged with: this
answer count: 7
favorite count: 0
has answer: http://stackoverflow.com/a/2683872
has answer: http://stackoverflow.com/a/2683781
has answer: http://stackoverflow.com/a/2683835
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2683762
upvote count: 4
tagged with: constructor
has comment: http://stackoverflow.com/comment/2703513
downvote count: 0

http://stackoverflow.com/a/2764000
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/2763091
upvote count: 2
type: Answer
has body: Eclipse exposes the Syntax Tree of it's own Java compiler. You can simply access the elements. See here.

http://stackoverflow.com/comment/2747298
has text: Why do you use HTML? You can do text formatting with Styles.
comment on: http://stackoverflow.com/q/2721181
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/2601195
has comment: http://stackoverflow.com/comment/2612859
has body: My guess would be that your app is bottlenecked on memory access, i.e. your CPU cores spend most of the time waiting for data to be read from main memory. I'm not sure how well profilers can diagnose this kind of problem (the profiler itself could influence the behaviour considerably). You could verify the guess by having your code repeat the operations it does many times on a very small data set. If this guess is correct, the only thing you can do (other than getting a server with more memory bandwidth) is to try and increase the locality of your memory access to make better use of caches; but depending on the details of the application that may not be possible. Using more threads may in fact lead to worse performance because of cores sharing cache memory.
upvote count: 5
has comment: http://stackoverflow.com/comment/2610392
has comment: http://stackoverflow.com/comment/2610761
score: 5
downvote count: 0
answers question: http://stackoverflow.com/q/2601094
type: Answer

http://stackoverflow.com/q/2754793
tagged with: java
tagged with: hibernate
has body: JPA promises to be vendor neutral for persistence and database. But I already know than some persistence frameworks like hibernate are not perfect (character encoding, null comparison) and you need to adapt your schema for each database. Because there is two layers (the persistence framework and database), I would imagine they're some work to use some JPA codes... Does anyone has some experiences with multiple support and if yes, what are the tricks and recommendations to avoid such incompatibilities ?
has answer: http://stackoverflow.com/a/2755054
tagged with: jpa
downvote count: 0
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/2786731
accepted answer: http://stackoverflow.com/a/2755054
score: 2
upvote count: 2
type: Question
tagged with: jakarta-ee
type: AnsweredQuestion
has title: JPA and compatibility with persistance providers and databases vendors

http://stackoverflow.com/comment/2633326
score: 0
type: QuestionComment
type: Comment
has text: you only need non-negative integers right?
comment on: http://stackoverflow.com/q/2621017

http://stackoverflow.com/q/2660949
answer count: 1
downvote count: 0
score: 1
favorite count: 0
tagged with: sessionid
tagged with: request
accepted answer: http://stackoverflow.com/a/2660956
type: AnsweredQuestion
tagged with: java
upvote count: 1
type: Question
tagged with: ejb
has title: Is there a way to access HttpSession from EJB module?
has body: I'm currently in a need of getting session ID thus I need to get the HttpSession but I don't have any servlets in my EJB module. So perhaps some DI annotation like in webservices api?
has answer: http://stackoverflow.com/a/2660956
tagged with: httpsession

http://stackoverflow.com/comment/2790341
score: 1
comment on: http://stackoverflow.com/a/2758596
type: AnswerComment
has text: `ParameterizedType` represents (in this case) the following information: `Bar<Foo>` - i.e. (as far as I understood) - what geejay needs to know.
type: Comment

http://stackoverflow.com/q/2754847
favorite count: 0
has answer: http://stackoverflow.com/a/2755063
tagged with: android
type: AnsweredQuestion
upvote count: 3
tagged with: java
accepted answer: http://stackoverflow.com/a/2755063
type: Question
score: 3
has title: ClassCastException while using service
has body: I defined a local Service: public class ComService extends Service implements IComService { private IBinder binder = new ComServiceBinder(); public class ComServiceBinder extends Binder implements IComService.IServiceBinder { public IComService getService() { return ComService.this; } } public void test(String msg) { System.out.println(msg); } @Override public IBinder onBind(Intent intent) { return binder; } } The corresponding interface: public interface IComService { public void test(String msg); public interface IServiceBinder { IComService getService(); } } Then i try to bind the service in another activity in another application, where the same interface is available: bindService(new Intent("ch.ifi.csg.games4blue.gamebase.api.ComService"), conn, Context.BIND_AUTO_CREATE); and private ServiceConnection conn = new ServiceConnection() { @Override public void onServiceConnected(ComponentName name, IBinder service) { Log.i("INFO", "Service bound " + name); comService = ((IComService.IServiceBinder)service).getService(); serviceHandler.sendEmptyMessage(0); } @Override public void onServiceDisconnected(ComponentName arg0) { Log.i("INFO", "Service Unbound "); } }; but the line comService = ((IComService.IServiceBinder)service).getService(); always throws a 05-02 22:12:55.922: ERROR/AndroidRuntime(622): java.lang.ClassCastException: android.os.BinderProxy I can't explain why, I followed the app sample on http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/LocalServiceBinding.html Any hints would be nice!
downvote count: 0
answer count: 1

http://stackoverflow.com/a/2777532
score: 7
has body: Your prime check is very inefficient. In fact, you don't need to re-check multiples of already checked numbers. So when you check for %2, you don't need to check for %4. To find out whether a number is a prime, you only have to try to divide it by all known primes until you reach the square root of the number to be checked. Doing this reduces the number of divisions vastly: if your app has a list of the primes from 2..~44721 (for instance computed as preparation step), you can check all numbers until 2000000000 pretty quickly. Also, you should make sure to check the smaller of the two permutations first (e.g. in your sample first check 13, then 31). Edit: Here's a sample I quickly put together in C# (you'll need to do some minor syntactic changes to have it run on Java, but I just had a C# compiler at hand): public static long reverse(long value) { long result = 0; while (value &gt; 0) { result = result*10+(value%10); value /= 10; } return result; } public static long[] knownPrimes = new long[1000000]; public static int knownPrimeCount = 0; public static bool isPrime(long value) { // we loop through all already known primes and try to divide by those (sieve sort of) for (int primeIndex = 0; primeIndex &lt; knownPrimeCount; primeIndex++) { long primeToCheck = knownPrimes[primeIndex]; if (value % knownPrimes[primeIndex] == 0) { // can be divided by the given prime -&gt; not a prime return false; } if ((primeToCheck * primeToCheck) &gt; value) { // square exceeds the value -&gt; is a prime, no more checks needed return true; } } // if we come here, we've run out of primes to check against, and therefore we should indicate this as error throw new ArgumentException(string.Format("{0} is too large to be checked against known primes", value), "value"); } public static void Main(String[] args){ long loop = 2000000000; long n = 1999990000; // first we initialize all the primes we may be needing for the final computation knownPrimes[knownPrimeCount++] = 2; for (long i = 3; tr…
answers question: http://stackoverflow.com/q/2777509
upvote count: 7
has comment: http://stackoverflow.com/comment/2820005
has comment: http://stackoverflow.com/comment/2820643
downvote count: 0
type: Answer

http://stackoverflow.com/comment/2668812
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2652632
score: 2
has text: See also: http://stackoverflow.com/questions/2481862/how-to-limit-setaccessible-to-only-legitimate-uses

http://stackoverflow.com/a/2708518
has body: You could just add an empty border to the containing component
downvote count: 0
score: 1
upvote count: 1
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2708418
accepted answer of: http://stackoverflow.com/q/2708418
type: Answer

http://stackoverflow.com/a/2607327
has comment: http://stackoverflow.com/comment/2617446
downvote count: 0
has body: The problem is that varargs got introduced in Java 5 and unfortunately, Arrays.asList() got overloaded with a vararg version too. So Arrays.asList(numbers) is understood by the Java 5 compiler as a vararg parameter of int arrays. This problem is explained in more details in Effective Java 2nd Ed., Chapter 7, Item 42.
score: 135
type: Answer
answers question: http://stackoverflow.com/q/2607289
upvote count: 135

http://stackoverflow.com/q/2663115
has answer: http://stackoverflow.com/a/3301796
has answer: http://stackoverflow.com/a/3312392
has answer: http://stackoverflow.com/a/23565452
has answer: http://stackoverflow.com/a/73277372
has comment: http://stackoverflow.com/comment/19997522
has answer: http://stackoverflow.com/a/38062319
has answer: http://stackoverflow.com/a/21328022
type: Question
has answer: http://stackoverflow.com/a/2663155
has answer: http://stackoverflow.com/a/54990329
has answer: http://stackoverflow.com/a/2671970
has answer: http://stackoverflow.com/a/2680862
has answer: http://stackoverflow.com/a/54850855
has answer: http://stackoverflow.com/a/68584810
possible better answer: http://stackoverflow.com/a/3301796
has comment: http://stackoverflow.com/comment/2681803
has comment: http://stackoverflow.com/comment/2680718
has answer: http://stackoverflow.com/a/35307959
score: 477
tagged with: data-structures
answer count: 29
has body: Say you have a linked list structure in Java. It's made up of Nodes: class Node { Node next; // some user data } and each Node points to the next node, except for the last Node, which has null for next. Say there is a possibility that the list can contain a loop - i.e. the final Node, instead of having a null, has a reference to one of the nodes in the list which came before it. What's the best way of writing boolean hasLoop(Node first) which would return true if the given Node is the first of a list with a loop, and false otherwise? How could you write so that it takes a constant amount of space and a reasonable amount of time? Here's a picture of what a list with a loop looks like:
has answer: http://stackoverflow.com/a/74906350
favorite count: 0
has answer: http://stackoverflow.com/a/46390217
has answer: http://stackoverflow.com/a/15586079
has comment: http://stackoverflow.com/comment/19997526
has answer: http://stackoverflow.com/a/2663147
has answer: http://stackoverflow.com/a/50164504
has comment: http://stackoverflow.com/comment/19997518
has answer: http://stackoverflow.com/a/2663123
has answer: http://stackoverflow.com/a/51117234
has answer: http://stackoverflow.com/a/15123668
has comment: http://stackoverflow.com/comment/19997529
has comment: http://stackoverflow.com/comment/2680802
has comment: http://stackoverflow.com/comment/4972115
has answer: http://stackoverflow.com/a/36936879
has title: How to detect a loop in a linked list?
accepted answer: http://stackoverflow.com/a/2663147
upvote count: 479
has comment: http://stackoverflow.com/comment/2681464
has comment: http://stackoverflow.com/comment/2680842
has answer: http://stackoverflow.com/a/2683962
has comment: http://stackoverflow.com/comment/2680708
has comment: http://stackoverflow.com/comment/2680714
has comment: http://stackoverflow.com/comment/2680710
has comment: http://stackoverflow.com/comment/19997527
tagged with: linked-list
linked to: http://stackoverflow.com/q/494830
has comment: http://stackoverflow.com/comment/19997531
has answer: http://stackoverflow.com/a/2663136
has comment: http://stackoverflow.com/comment/19997530
downvote count: 2
has answer: http://stackoverflow.com/a/3158029
has comment: http://stackoverflow.com/comment/39712165
has answer: http://stackoverflow.com/a/12893153
has answer: http://stackoverflow.com/a/70720555
has comment: http://stackoverflow.com/comment/19997528
type: AnsweredQuestion
tagged with: algorithm
has answer: http://stackoverflow.com/a/46063377
has answer: http://stackoverflow.com/a/14351706
tagged with: java
has comment: http://stackoverflow.com/comment/2681643
has comment: http://stackoverflow.com/comment/11407863

http://stackoverflow.com/q/2683466
has comment: http://stackoverflow.com/comment/2703195
linked to: http://stackoverflow.com/q/2568625
tagged with: java
has comment: http://stackoverflow.com/comment/2703811
has answer: http://stackoverflow.com/a/3252031
has title: Java String.indexOf and empty Strings
has body: I'm curious why the String.indexOf is returning a 0 (instead of -1) when asking for the index of an empty string within a string. The Javadocs only say this method returns the index in this string of the specified string, -1 if the string isn't found. To me this behavior seems highly unexpected, I would have expected a -1. Any ideas why this unexpected behavior is going on? I would at the least think this is worth a note in the method's Javadocs... System.out.println("FOO".indexOf("")); // outputs 0 wtf!!! System.out.println("FOO".indexOf("bar")); // outputs -1 as expected System.out.println("FOO".indexOf("F")); // outputs 0 as expected System.out.println("".indexOf("")); // outputs 0 as expected, I think
type: Question
has answer: http://stackoverflow.com/a/72930724
has answer: http://stackoverflow.com/a/2683476
has answer: http://stackoverflow.com/a/2683509
accepted answer: http://stackoverflow.com/a/2683509
has comment: http://stackoverflow.com/comment/2703785
has comment: http://stackoverflow.com/comment/2703839
has comment: http://stackoverflow.com/comment/2703186
has comment: http://stackoverflow.com/comment/2703709
has comment: http://stackoverflow.com/comment/2703382
upvote count: 47
score: 45
has answer: http://stackoverflow.com/a/34067219
answer count: 7
tagged with: string
favorite count: 0
has answer: http://stackoverflow.com/a/71004220
possible better answer: http://stackoverflow.com/a/2683476
downvote count: 2
has answer: http://stackoverflow.com/a/30642644
has comment: http://stackoverflow.com/comment/2703915
has comment: http://stackoverflow.com/comment/2703727
linked to: http://stackoverflow.com/q/4802015
type: AnsweredQuestion

http://stackoverflow.com/q/2744753
favorite count: 0
has comment: http://stackoverflow.com/comment/2773998
has answer: http://stackoverflow.com/a/2745059
has answer: http://stackoverflow.com/a/2744932
has comment: http://stackoverflow.com/comment/2774062
upvote count: 1
has answer: http://stackoverflow.com/a/2745695
possible better answer: http://stackoverflow.com/a/2745059
type: AnsweredQuestion
tagged with: algorithm
score: 1
tagged with: java
has title: Algorithm to detect how many words typed, also multi sentence support (Java)
type: Question
has answer: http://stackoverflow.com/a/2745345
downvote count: 0
accepted answer: http://stackoverflow.com/a/2745695
has body: Problem: I have to design an algorithm, which does the following for me: Say that I have a line (e.g.) alert tcp 192.168.1.1 (caret is currently here) The algorithm should process this line, and return a value of 4. I coded something for it, I know it's sloppy, but it works, partly. private int counter = 0; public void determineRuleActionRegion(String str, int index) { if (str.length() == 0 || str.indexOf(" ") == -1) { triggerSuggestionList(1); return; } //remove duplicate space, spaces in front and back before searching int num = str.trim().replaceAll(" +", " ").indexOf(" ", index); //Check for occurances of spaces, recursively if (num == -1) { //if there is no space //no need to check if it's 0 times it will assign to 1 triggerSuggestionList(counter + 1); counter = 0; return; //set to rule action } else { //there is a space counter++; determineRuleActionRegion(str, num + 1); } } //end of determineactionRegion() So basically I find for the space and determine the region (number of words typed). However, I want it to change upon the user pressing space bar &lt;space character&gt;. How may I go around with the current code? Or better yet, how would one suggest me to do it the correct way? I'm figuring out on BreakIterator for this case... To add to that, I believe my algorithm won't work for multi sentences. How should I address this problem as well. -- The source of String str is acquired from textPane.getText(0, pos + 1);, the JTextPane. Thanks in advance. Do let me know if my question is still not specific enough. -- More examples: alert tcp $EXTERNAL_NET any -&gt; $HOME_NET 22 &lt;caret&gt; return -1 (maximum of the typed text is 7 words) alert tcp 192.168.1.1 any&lt;caret&gt; return 4 (as it is still at 2nd arg) alert tcp&lt;caret&gt; return 2 (as it is still at 2nd arg) alert tcp &lt;caret&gt; return 3 alert tcp $EXTERNAL_NET any -&gt; &lt;caret&gt; return 6 It is something like shell commands. As above. Though I think it does not differ much I believe, I just …
answer count: 4

http://stackoverflow.com/comment/2617555
type: QuestionComment
comment on: http://stackoverflow.com/q/2604875
has text: I think you don't need `/` just use `classpath:applicationContext.xml`
score: 2
type: Comment

http://stackoverflow.com/a/2761303
downvote count: 0
answers question: http://stackoverflow.com/q/2761223
has comment: http://stackoverflow.com/comment/2793359
type: Answer
upvote count: 1
has body: Depending on what you are doing, it may be easier to use scipy.weave. See below for an example, it is fairly self explanatory. My experience with SWIG is that it works great, but passing around variables is a real PITA. import scipy.weave def convolve( im, filt, reshape ): height, stride = im.shape fh,fw = filt.shape im = im.reshape( height * stride ) filt = filt.reshape( fh*fw ) newIm = numpy.zeros ( (height * stride), numpy.int ) code = """ int sum=0, pos; int ys=0, fys=0; for (int y=0; y &lt; (height-(fh/2)); y++) { for (int x=0; x &lt; (stride-(fw/2)); x++) { fys=sum=0; pos=ys+x; int th = ((height-y) &lt; fh ) ? height-y : fh; int tw = ((stride-x) &lt; fw ) ? stride-x : fw; for (int fy=0; fy &lt; th; fy++) { for (int fx=0; fx &lt; tw; fx++) { sum+=im[pos+fx]*filt[fys+fx]; } fys+=fw; pos+=stride; } newIm[ys+x] = sum; } ys+=stride; } """ scipy.weave.inline(code,['height','stride','fh','fw','im','filt','newIm']) if reshape: return newIm.reshape(height,stride ) else: return newIm
score: 1

http://stackoverflow.com/q/2692745
score: 5
has title: OQL query to find all instances and sub-instances of a given class referred to from a session
has answer: http://stackoverflow.com/a/5030506
answer count: 1
has comment: http://stackoverflow.com/comment/2764487
favorite count: 0
tagged with: heap-memory
tagged with: jhat
tagged with: memory-leaks
upvote count: 5
has comment: http://stackoverflow.com/comment/2848860
type: AnsweredQuestion
downvote count: 0
accepted answer: http://stackoverflow.com/a/5030506
tagged with: java
type: Question
has body: I'm trying to use jhat/OQL to trace a memory leak in our Tomcat container. The question I want to ask is: "Show me all the instances (and sub-instances) of foo.bar.Cacheable class that are reachable from javax.servlet.http.HttpSession" I managed to come up with the following, but this doesn't show subclasses of foo.bar.Cacheable (which is important since this is infact an interface). select filter(reachables(s), "/foo.bar.Cacheable/(classof(it).name)") from javax.servlet.http.HttpSession s I tried various permutations of the concept below, but just keep getting errors ("foo" is not defined). select filter(reachables(s), classof(it) instanceof foo.bar.Cacheable) from javax.servlet.http.HttpSession s Can anyone help me out with what I'm doing wrong to pose this question through OQL?
tagged with: oql

http://stackoverflow.com/comment/79166021
has text: This will still keep in memory till all rows are written to wb
comment on: http://stackoverflow.com/a/3977963
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/2755161
has comment: http://stackoverflow.com/comment/2791755
type: Answer
has comment: http://stackoverflow.com/comment/2786394
accepted answer of: http://stackoverflow.com/q/2755133
has body: I wouldn't use the HourMinute class, unless it has some other added value. If you only need to find the closest event time after a given point in time, convert your strings to Date (or to long values representing time), and store them in some sorted collection. The conversion can be done with SimpleDateFormat. If items are added dynamically, use TreeSet&lt;Date>, together with ceiling(t) / higher(t) methods. If the set of items is not dynamic, use an array Date[], together with Arrays.binarySearch(..). Here is a (working) draft of the first approach: public class TimedEventsMgr { private TreeSet&lt;Date&gt; pointsInTime = new TreeSet&lt;Date&gt;(); private SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd hh:mm a"); //timeStr: hh:mm AM/PM public void add(String timeStr) throws ParseException{ Date time = sdf.parse("20000101 "+timeStr); pointsInTime.add(time); } public Date closestFutureTime(Date time){ Calendar c = Calendar.getInstance(); c.setTime(time); c.set(Calendar.YEAR, 2000); c.set(Calendar.MONTH, 0); //January c.set(Calendar.DATE, 1); return pointsInTime.higher(c.getTime()); } }
score: 4
has comment: http://stackoverflow.com/comment/2786435
upvote count: 4
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2755133

http://stackoverflow.com/comment/2704669
comment on: http://stackoverflow.com/a/2684400
score: 0
has text: Alright this seems like the easiest way to go if I want just a global count, thank you!
type: AnswerComment
type: Comment

http://stackoverflow.com/q/2761091
downvote count: 0
score: 1
tagged with: java
type: Question
tagged with: google-cloud-datastore
has title: Google App Engine - low-level datastore API flag?
has answer: http://stackoverflow.com/a/2761683
upvote count: 1
answer count: 1
favorite count: 0
has body: In my GAE-Java app, I'm using the low-level datastore API. Hence I don't need the GAE app instance to load any of the higher level data access libraries such as JPA, JDO, Data Nucleus, etc. Is there a flag that I can set to indicate that I don't want these libraries to be loaded? My motivation to do this is to reduce app instance startup time everywhere I can. Now I don't know if these libraries are loaded only on-demand or always. The dev environment logs messages related to data nucleus which seems to indicate that some of these libraries may be pre-loaded? I hope I'm wrong here. Thanks, Keyur
type: UnansweredQuestion
tagged with: google-app-engine

http://stackoverflow.com/a/2768076
has comment: http://stackoverflow.com/comment/19394571
has comment: http://stackoverflow.com/comment/24928449
has comment: http://stackoverflow.com/comment/135497842
upvote count: 142
has comment: http://stackoverflow.com/comment/2800875
has comment: http://stackoverflow.com/comment/25063608
has comment: http://stackoverflow.com/comment/2800985
score: 137
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2768054
accepted answer of: http://stackoverflow.com/q/2768054
has comment: http://stackoverflow.com/comment/2800887
downvote count: 5
type: Answer
has body: No, there isn't. The closest you can get is: public static &lt;T&gt; T coalesce(T ...items) { for (T i : items) if (i != null) return i; return null; } For efficient reasons, you can handle the common cases as follows: public static &lt;T&gt; T coalesce(T a, T b) { return a == null ? b : a; } public static &lt;T&gt; T coalesce(T a, T b, T c) { return a != null ? a : (b != null ? b : c); } public static &lt;T&gt; T coalesce(T a, T b, T c, T d) { return ... } The efficiency reason is that an array allocation will happen each time you invoke the ... version of the method. This could be wasteful for hand-fulls of items, which I suspect will be common usage.

http://stackoverflow.com/a/2617312
answers question: http://stackoverflow.com/q/2617287
type: Answer
has comment: http://stackoverflow.com/comment/11506976
has body: My experience is that most organizations that want to create rich GUIs still use Swing, and manually go through all the annoyances of layout managers, etc. The use of SWT is fairly limited to organizations that are using the Eclipse RCP as their platform. I'm not sure why it hasn't caught on outside this platform. It's sad to admit, but Java Swing GUIs don't generally look good unless you spend a lot of time creating a more native feel for them. Even then, they often lose out on aesthetics to equivalent programs written specifically for Windows and which use Window APIs like WinForms.
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/2630151
downvote count: 0

http://stackoverflow.com/a/10988353
downvote count: 1
has comment: http://stackoverflow.com/comment/14356254
score: -1
answers question: http://stackoverflow.com/q/2725978
upvote count: 0
has body: Another approach would be to simply have the try-catch inside the for loop with the for running a set number of times. Example: for (int i = 0; i &lt; 1000; i++) { try { // do risky stuff that might not work } catch (Exception e) { break; } // end catch } // end for loop. What happens: Either you run out of time (int i gets bigger than 1000 and the loop breaks naturally), OR what you tried didn't work this time so the catch is hit and "break" called (kicks you out of the for loop). Another way to do this is with a while loop, for example: int number = 10; boolean badStuff = false; while (!badStuff) { // do stuff you want number = number--; // reassign the number to 9, then 8, then 7, and so on. if (number = 1) { badStuff = true; // or you could skip having a boolean at all and just call break } } // end while loop As long as !badStuff is evaluated true (i.e. you declared bad stuff as false, so !badStuff would be true), the loop will continue. Inside the loop you can set "badStuff = true" inside an if statement to control when you exit. Each time the loop runs it will check !badStuff then the if-statement inside the loop. Here badStuff is a boolean (i.e. always true or false), in this case called a "flag" (wave it to trigger a change).
type: Answer

http://stackoverflow.com/comment/2724045
comment on: http://stackoverflow.com/a/2700238
type: Comment
has text: I have already put that way, like the ugly one, I was searching for a clean alternative
score: 0
type: AnswerComment

http://stackoverflow.com/a/2773033
type: Answer
has comment: http://stackoverflow.com/comment/2807496
has comment: http://stackoverflow.com/comment/2806667
has comment: http://stackoverflow.com/comment/2838927
upvote count: 13
has comment: http://stackoverflow.com/comment/2806860
has comment: http://stackoverflow.com/comment/2838557
has comment: http://stackoverflow.com/comment/2839420
has comment: http://stackoverflow.com/comment/2806783
score: 13
answers question: http://stackoverflow.com/q/2772977
has comment: http://stackoverflow.com/comment/2840290
has comment: http://stackoverflow.com/comment/2806832
has comment: http://stackoverflow.com/comment/2841613
has comment: http://stackoverflow.com/comment/91274587
has comment: http://stackoverflow.com/comment/2839472
has body: Yes, it is technically possible, as singleton is a design pattern and not a language construct that could have inheritance restrictions. I would just reimplement the public [Object] getInstance() method in the child classes (see below). And, yes, singletons can also benefit from inheritance as they may share similar but not identifical behaviours with other singletons. public class ParentSingleton { private static ParentSingleton instance; protected ParentSingleton() { } public static synchronized ParentSingleton getInstance() { if (instance == null) { instance = new ParentSingleton(); } return instance; } public int a() { // (..) } } public class ChildSingleton extends ParentSingleton { private static ChildSingleton instance; public static synchronized ParentSingleton getInstance() { if (instance == null) { instance = new ChildSingleton(); } return instance; } } EDIT: as Eyal pointed out in his comments below, the constructor in the super class had to be made protected (instead of private), otherwise it would not be visible to the child classes and the code would not even compile.
downvote count: 0
has comment: http://stackoverflow.com/comment/2806798
has comment: http://stackoverflow.com/comment/2834133
has comment: http://stackoverflow.com/comment/2806754

http://stackoverflow.com/q/2661849
tagged with: regex
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/2661857
type: Question
has comment: http://stackoverflow.com/comment/2679293
has body: I have a list of URLs of type http://www.example.com/pk/ca, http://www.example.com/pk, http://www.example.com/anthingcangoeshere/pk, and http://www.example.com/pkisnotnecessaryhere. Now, I want to find out only those URLs that ends with /pk or /pk/ and don't have anything in between .com and /pk
has comment: http://stackoverflow.com/comment/2679194
has comment: http://stackoverflow.com/comment/2679178
has title: Java - Regex problem
has comment: http://stackoverflow.com/comment/2679296
has comment: http://stackoverflow.com/comment/2679189
has answer: http://stackoverflow.com/a/2662217
has answer: http://stackoverflow.com/a/2661992
downvote count: 0
tagged with: url
has comment: http://stackoverflow.com/comment/2679193
has answer: http://stackoverflow.com/a/2662002
answer count: 4
favorite count: 0
type: UnansweredQuestion
upvote count: 1

http://stackoverflow.com/a/2686103
downvote count: 1
upvote count: 22
type: Answer
has comment: http://stackoverflow.com/comment/112156777
has body: The HashMap has no defined ordering of keys.
answers question: http://stackoverflow.com/q/2686092
score: 21

http://stackoverflow.com/a/2730340
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2730272
has body: It looks like it is defined in comsvcs.dll .
type: AcceptedAnswer
type: Answer
has comment: http://stackoverflow.com/comment/2761169
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/2730272

http://stackoverflow.com/comment/2711792
score: 1
comment on: http://stackoverflow.com/a/2679881
type: AnswerComment
type: Comment
has text: Thank you! Using the DefaultMultiValueCategoryDataset got me half way there. The other thing I had to do was use a ScatterRenderer instead of a LineAndShapeRenderer. I'm now having problems with the autorange being too narrow but I'll have to look further into that. Thank you both again for your wonderful help! :) -Christine

http://stackoverflow.com/q/2692701
has body: My manager has asked me to suggest an application server for web application development work. What are the factors that needs to be considered before we select any application server for web application development in Java J2EE development? If I select one now and IN future and I want to change to some other application server, is that minimum effort to change?
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2692863
answer count: 4
score: 3
has title: Choosing an application server for web application development
upvote count: 3
tagged with: java
tagged with: web-applications
type: Question
tagged with: weblogic
tagged with: jboss
has answer: http://stackoverflow.com/a/2694735
downvote count: 0
tagged with: application-server
favorite count: 0
has answer: http://stackoverflow.com/a/2694786
has answer: http://stackoverflow.com/a/2692949

http://stackoverflow.com/q/2665655
answer count: 6
tagged with: variables
has body: first time poster, long time reader so be gentle with me :) See the following code which works to generate me timestamps for the beginning and end of every month in a financial year. int year = 2010; // Financial year runs from Sept-Aug so earlyMonths are those where year = FY-1 and lateMonths are those where year = FY int[] earlyMonths = {8, 9, 10, 11}; // Sept to Dec int earlyYear = year -1; for (int i : earlyMonths) { month = i; Calendar cal = Calendar.getInstance(); cal.clear(); cal.set(earlyYear,month,1,0,0,0); Long start = cal.getTimeInMillis(); cal.clear(); cal.set(earlyYear,month,1); lastDayofMonth = cal.getActualMaximum(GregorianCalendar.DAY_OF_MONTH); cal.set(earlyYear,month,lastDayofMonth,23,59,59); Long end = cal.getTimeInMillis(); } int[] lateMonths = {0, 1, 2, 3, 4, 5, 6, 7}; // Jan to Aug for (int i : lateMonths) { month = i; Calendar cal = Calendar.getInstance(); cal.clear(); cal.set(year,month,1,0,0,0); Long start = cal.getTimeInMillis(); cal.clear(); cal.set(year,month,1); lastDayofMonth = cal.getActualMaximum(GregorianCalendar.DAY_OF_MONTH); cal.set(year,month,lastDayofMonth,23,59,59); Long end = cal.getTimeInMillis(); } So far so good, but in order to use these results I need these timestamps to be output to variables named by month (to be used in a prepared statement later in the code. e.g. SeptStart = sometimestamp, SeptEnd = some timestamp etc etc. I don't know if it is possible to declare new variables based on the results of each loop. Any ideas?
favorite count: 0
has answer: http://stackoverflow.com/a/2674821
has answer: http://stackoverflow.com/a/2665677
upvote count: 9
downvote count: 0
tagged with: dynamic
accepted answer: http://stackoverflow.com/a/2665681
tagged with: loops
tagged with: names
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2666018
has answer: http://stackoverflow.com/a/2665681
tagged with: java
has answer: http://stackoverflow.com/a/2665706
has title: Create variable names using a loop in Java?
type: Question
score: 9
possible better answer: http://stackoverflow.com/a/2665680
has answer: http://stackoverflow.com/a/2665680

http://stackoverflow.com/q/2636080
has comment: http://stackoverflow.com/comment/2650064
has answer: http://stackoverflow.com/a/2636205
has answer: http://stackoverflow.com/a/2636119
tagged with: java
upvote count: 7
type: Question
has body: I have a hobby opne source Java project hosted at google code (linkset). May I use a prefix "com.google.code.linkset" as a package name for this project? P.S. I dont own "org.linkset" domain :( but i like the name :)
has answer: http://stackoverflow.com/a/2636114
has comment: http://stackoverflow.com/comment/2650050
has comment: http://stackoverflow.com/comment/2650059
has title: May I use com.google.code prefix for my packages?
answer count: 6
has comment: http://stackoverflow.com/comment/2650060
has comment: http://stackoverflow.com/comment/24803597
downvote count: 0
has answer: http://stackoverflow.com/a/2637233
score: 7
has comment: http://stackoverflow.com/comment/2650035
has answer: http://stackoverflow.com/a/2637882
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/17138345

http://stackoverflow.com/a/3076312
score: 10
has comment: http://stackoverflow.com/comment/98787985
downvote count: 0
type: Answer
has body: If you are about to generate Excel 2007 (xslx) then you could adapt the approach of BigGridDemo.java as described here: http://web.archive.org/web/20110821054135/http://www.realdevelopers.com/blog/code/excel The solution is to let POI generate a container xslx as a template only and stream the actual spreadsheet data as XML into a zip output stream. Streamlining the XML generation is then up to you.
upvote count: 10
answers question: http://stackoverflow.com/q/2673751

http://stackoverflow.com/a/2724817
answers question: http://stackoverflow.com/q/2722661
score: 0
type: Answer
has body: The Apache VFS project is a java library that you can use from your program to copy files between file systems.(E.g. copy local files to FTP/SCP/HTTP.) Copying can be configured so that only files in the source that are newer than the destination are copied, reducing the amount of data sent. Links Apache VFS the file systems supported.

http://stackoverflow.com/comment/2801867
score: 5
type: AnswerComment
comment on: http://stackoverflow.com/a/2768809
type: Comment
has text: The problem with this approach is that Java will look at the compile-time type to determine which version of the `Battle` method to call. For example: `Creature c1 = new Ogre(); Creature c2 = new Wizard(); Battle(c1,c2);` would call `Battle(Creature,Creature)` and **not** `Battle(Ogre,Wizard)`.

http://stackoverflow.com/q/2707724
upvote count: 10
downvote count: 1
has answer: http://stackoverflow.com/a/2707732
score: 9
type: Question
tagged with: c#
accepted answer: http://stackoverflow.com/a/2707738
answer count: 7
has answer: http://stackoverflow.com/a/2707749
favorite count: 0
possible better answer: http://stackoverflow.com/a/2707750
has answer: http://stackoverflow.com/a/2707750
has answer: http://stackoverflow.com/a/2707747
linked to: http://stackoverflow.com/q/30905491
has body: I want to ask you why we need inner classes and why we use them ? I know how to use inner classes but I don't know why..
has answer: http://stackoverflow.com/a/2708144
type: AnsweredQuestion
tagged with: inner-classes
has answer: http://stackoverflow.com/a/18614612
tagged with: java
has answer: http://stackoverflow.com/a/2707738
has title: Why we use inner classes?

http://stackoverflow.com/comment/2753135
score: 0
type: QuestionComment
type: Comment
has text: You may want to consider using Ant or Maven instead of "Make". I only bring it up because you tagged the question beginner. If you prefer Make and know of the other options than disregard.
comment on: http://stackoverflow.com/q/2726119

http://stackoverflow.com/q/2704857
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2704944
score: 59
has answer: http://stackoverflow.com/a/41534710
has comment: http://stackoverflow.com/comment/2728488
linked to: http://stackoverflow.com/q/29751230
has answer: http://stackoverflow.com/a/42525502
upvote count: 59
tagged with: java
has answer: http://stackoverflow.com/a/2704948
has title: How to check if a given Regex is valid?
type: Question
has comment: http://stackoverflow.com/comment/2728412
has answer: http://stackoverflow.com/a/79258993
has comment: http://stackoverflow.com/comment/2729285
downvote count: 0
has answer: http://stackoverflow.com/a/72750793
has comment: http://stackoverflow.com/comment/2728526
has comment: http://stackoverflow.com/comment/2728361
has body: I have a little program allowing users to type-in some regular expressions. afterwards I like to check if this input is a valid regex or not. I'm wondering if there is a build-in method in Java, but could not find such jet. Can you give me some advice?
has answer: http://stackoverflow.com/a/2704935
has answer: http://stackoverflow.com/a/2704944
has answer: http://stackoverflow.com/a/56547552
tagged with: regex
favorite count: 0
possible better answer: http://stackoverflow.com/a/2704935
answer count: 9
has comment: http://stackoverflow.com/comment/2728374
has comment: http://stackoverflow.com/comment/2729343
has answer: http://stackoverflow.com/a/58401814

http://stackoverflow.com/q/2632419
tagged with: java
has comment: http://stackoverflow.com/comment/82744922
tagged with: eclipse
type: Question
has answer: http://stackoverflow.com/a/36980727
score: 233
has title: How do I hide .class files from the Open Resource dialog in Eclipse?
has answer: http://stackoverflow.com/a/23653428
has answer: http://stackoverflow.com/a/9667461
has answer: http://stackoverflow.com/a/62893462
has answer: http://stackoverflow.com/a/25719118
has answer: http://stackoverflow.com/a/11251249
upvote count: 233
downvote count: 0
possible better answer: http://stackoverflow.com/a/12201561
favorite count: 0
accepted answer: http://stackoverflow.com/a/2632809
has body: I won't want to have edit any working sets. I just want a way to, across all workspaces and projects, prevent .class files from ever showing in the Open Resource Dialog. Is there a way to do this?
has comment: http://stackoverflow.com/comment/85643927
answer count: 9
has answer: http://stackoverflow.com/a/2632850
has answer: http://stackoverflow.com/a/12201561
has answer: http://stackoverflow.com/a/2632809
type: AnsweredQuestion

http://stackoverflow.com/q/2706054
possible better answer: http://stackoverflow.com/a/2706214
tagged with: user-interface
downvote count: 0
accepted answer: http://stackoverflow.com/a/2706724
has answer: http://stackoverflow.com/a/2706214
favorite count: 0
upvote count: 2
has body: i'm trying to put an image as a background of my interface in java , i tried to write a class that does that and using it , but is there a simpler way to do that . here 's the code i used: import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; public class BackgroundImagePanelExample { // Set up contraints so that the user supplied component and the // background image label overlap and resize identically private static final GridBagConstraints gbc; static { gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.NORTHWEST; } /** * Wraps a Swing JComponent in a background image. Simply invokes the overloded * variant with Top/Leading alignment for background image. * * @param component - to wrap in the a background image * @param backgroundIcon - the background image (Icon) * @return the wrapping JPanel */ public static JPanel wrapInBackgroundImage(JComponent component, Icon backgroundIcon) { return wrapInBackgroundImage( component, backgroundIcon, JLabel.TOP, JLabel.LEADING); } /** * Wraps a Swing JComponent in a background image. The vertical and horizontal * alignment of background image can be specified using the alignment * contants from JLabel. * * @param component - to wrap in the a background image * @param backgroundIcon - the background image (Icon) * @param verticalAlignment - vertical alignment. See contants in JLabel. * @param horizontalAlignment - horizontal alignment. See contants in JLabel. * @return the wrapping JPanel */ public static JPanel wrapInBackgroundImage(JComponent component, Icon backgroundIcon, int ver…
tagged with: swing
has comment: http://stackoverflow.com/comment/2729708
answer count: 4
has title: Background image in java
score: 2
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2707006
has comment: http://stackoverflow.com/comment/2729749
tagged with: java
has comment: http://stackoverflow.com/comment/2730412
has comment: http://stackoverflow.com/comment/2729777
tagged with: background
has answer: http://stackoverflow.com/a/5999526
has answer: http://stackoverflow.com/a/2706724
type: Question
tagged with: image

http://stackoverflow.com/comment/2665618
type: QuestionComment
comment on: http://stackoverflow.com/q/2649573
score: 2
has text: Sun tutorial: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html Once having the grasp on that, continue here: http://java.sun.com/docs/books/tutorial/collections/index.html
type: Comment

http://stackoverflow.com/a/2727230
has body: Ok here's what I've experienced yesterday: My test (run by selenium) logs in to my application, and loads data from the DB, thus creating one hibernate Session. It then logs out. This is done once every 3 minutes. The persistance beans are created by Spring as follows: The entity manager factory is configured as follows: validate I ran the test and created a thread dump every 30 minutes, that is every 10 login/logout. If the listener is not set, I can see that session instances add up each time I login and out. The session-timeout is set to 30 minutes and I can see in the logs that the session is invalidated, so I expected the number of sessions to decrease after that time, but it still increases. The number of sessions was 30 after 1h30 minutes and kept going up afterwards. If the listener is set, then session instances count stays low. Actually, it says at one because once the test logs out, the http session invalidation actually invalidates the hibernate session and everything is GC'ed. It has been like this for the last 15 hours. Given all that, I think that missing this listener might well lead to memory leaks... Bozho: what do you think of this? By the way, I'm not an experienced SO user: should I have posted this under my question? I thought that I was answering my own question here, so I added an answer, but not sure :-)
score: 0
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2721644
type: Answer
answers question: http://stackoverflow.com/q/2721644

http://stackoverflow.com/a/2768985
has comment: http://stackoverflow.com/comment/2802107
has body: I'm not aware of that sort of counterpart to substring(), but it's not really necessary. You can't efficiently find the last index with a given value using indexOf(), so lastIndexOf() is necessary. To get what you're trying to do with lastSubstring(), you can efficiently use substring(). String str = "aaple"; str.substring(str.length() - 2, str.length() - 1).equals("e"); So, there's not really any need for lastSubstring().
has comment: http://stackoverflow.com/comment/2806077
has comment: http://stackoverflow.com/comment/2806213
downvote count: 1
has comment: http://stackoverflow.com/comment/2802057
upvote count: 0
has comment: http://stackoverflow.com/comment/2802336
type: Answer
has comment: http://stackoverflow.com/comment/2802139
has comment: http://stackoverflow.com/comment/2806335
score: -1
has comment: http://stackoverflow.com/comment/2802043
has comment: http://stackoverflow.com/comment/2804713
has comment: http://stackoverflow.com/comment/2802194
answers question: http://stackoverflow.com/q/2768931

http://stackoverflow.com/comment/2673390
has text: Does the fact that the program works on my local network mean that my router is configured for multicast?
comment on: http://stackoverflow.com/a/2656603
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/2679330
type: Question
tagged with: try-catch
has answer: http://stackoverflow.com/a/2679544
tagged with: java
has answer: http://stackoverflow.com/a/11644137
linked to: http://stackoverflow.com/q/14376924
linked to: http://stackoverflow.com/q/1692230
has comment: http://stackoverflow.com/comment/29070188
has answer: http://stackoverflow.com/a/2680784
linked to: http://stackoverflow.com/q/8728866
has answer: http://stackoverflow.com/a/9481355
has answer: http://stackoverflow.com/a/2679410
has comment: http://stackoverflow.com/comment/38538500
has answer: http://stackoverflow.com/a/2679631
downvote count: 0
has answer: http://stackoverflow.com/a/7358432
favorite count: 0
has body: Documentation for java.lang.Error says: An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch But as java.lang.Error is a subclass of java.lang.Throwable, I can catch this type of Throwable. I understand why it's not a good idea to catch this sort of exception. As far as I understand, if we decide to catch it, the catch handler should not allocate any memory by itself. Otherwise OutOfMemoryError will be thrown again. So, my question is: Are there any real world scenarios when catching java.lang.OutOfMemoryError might be a good idea? If we decide to catch java.lang.OutOfMemoryError, how can we make sure the catch handler doesn't allocate any memory by itself (any tools or best practices)?
score: 128
answer count: 14
possible better answer: http://stackoverflow.com/a/2679617
tagged with: out-of-memory
upvote count: 128
has answer: http://stackoverflow.com/a/2679617
accepted answer: http://stackoverflow.com/a/2680784
has answer: http://stackoverflow.com/a/2679906
has comment: http://stackoverflow.com/comment/2698851
has title: Catching java.lang.OutOfMemoryError?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2679380
has comment: http://stackoverflow.com/comment/60366538
has answer: http://stackoverflow.com/a/2679381
has answer: http://stackoverflow.com/a/4745520
linked to: http://stackoverflow.com/q/352780
has answer: http://stackoverflow.com/a/6185635
has answer: http://stackoverflow.com/a/29354878

http://stackoverflow.com/a/2760752
has comment: http://stackoverflow.com/comment/2792710
answers question: http://stackoverflow.com/q/2759880
has body: Although not related to your problem, you may want to check out the List Action, which attempts to handle this type of request in a more general way. Edit: Here is my simple SSCCE that shows invokeLater is not required: import java.awt.*; import java.awt.event.*; import javax.swing.*; public class ListActionTest { public static void main(String[] args) throws Exception { final JTextField textField = new JTextField(); Action displayAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { JList list = (JList)e.getSource(); System.out.println(list.getSelectedValue()); textField.setText(list.getSelectedValue().toString()); textField.requestFocusInWindow(); } }; String[] data = { "zero", "one", "two", "three", "four", "five" }; JList list = new JList( data ); ListAction la = new ListAction(list, displayAction); JFrame frame = new JFrame(); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); frame.getContentPane().add( new JScrollPane(list) ); frame.add(textField, BorderLayout.SOUTH); frame.setSize(400, 100); frame.setLocationRelativeTo( null ); frame.setVisible( true ); } }
has comment: http://stackoverflow.com/comment/2792666
score: 0
has comment: http://stackoverflow.com/comment/2794014
type: Answer

http://stackoverflow.com/a/2699664
accepted answer of: http://stackoverflow.com/q/2699494
type: Answer
answers question: http://stackoverflow.com/q/2699494
score: 2
upvote count: 2
downvote count: 0
type: AcceptedAnswer
has body: I have read about Java Reflections but till date it has been a vague concept to me. Here is a quick into to reflection in java: Structural introspection. Basic reflection deals with the introspection of object at run-time. This means that you can learn the structure of objects and classes at run-time programmatically, e.g. get the class of the object, list the methods of the class, list the fields defined in the class, etc. Reflective invocation and instantiation. With reflection you can invoke a method at run-time which is not defined at compile-time, e.g. invoke method named M on object O, where M is read in a configuration file. You can also instantiate object dynamically without knowing the class at compile-time. Annotations. Then you can move one level up in the meta levels, and play with annotations. Annotations describe other elements such as class, method and fields. Many framework rely on this. Dynamic proxy. Dynamic proxy can be generated at run-time. In this case, it's really like if you create a class dynamically at run-time. To use with care, but definitively handy and powerful in some cases. I guess you will start with structural introspection. There are links to tutorials in the other answers, but I hope this gives you an overview of what else can be done.

http://stackoverflow.com/q/2774173
has comment: http://stackoverflow.com/comment/2808259
has comment: http://stackoverflow.com/comment/2808038
has comment: http://stackoverflow.com/comment/2808286
has comment: http://stackoverflow.com/comment/2809104
has answer: http://stackoverflow.com/a/2774410
has comment: http://stackoverflow.com/comment/2809216
answer count: 3
upvote count: 1
has comment: http://stackoverflow.com/comment/2808339
has comment: http://stackoverflow.com/comment/2807981
has comment: http://stackoverflow.com/comment/2808552
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/2807919
has comment: http://stackoverflow.com/comment/2808256
has comment: http://stackoverflow.com/comment/2808382
tagged with: linked-list
has comment: http://stackoverflow.com/comment/2808045
downvote count: 0
has comment: http://stackoverflow.com/comment/2808041
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/2774434
has title: linked-list interview question
has body: This was the question asked in interview.Can anybody help me out it in implementing in java Given 2 linked lists(which need not have unique elements) find intersection point in the form of Y.(it can be anywhere--middle or tail)
type: Question
has comment: http://stackoverflow.com/comment/2808029
has comment: http://stackoverflow.com/comment/2808022
has answer: http://stackoverflow.com/a/2775044
has comment: http://stackoverflow.com/comment/2807956

http://stackoverflow.com/comment/2638462
comment on: http://stackoverflow.com/a/2618048
type: AnswerComment
score: 0
type: Comment
has text: I suppose yes but again I didn't try. Please, if you test it, share your results with the community.

http://stackoverflow.com/q/2684517
possible better answer: http://stackoverflow.com/a/2684541
has body: I just want to know where am i wrong here: import java.io.*; class Tokens{ public static void main(String[] args) { //String[] result = "this is a test".split(""); String[] result = "4543 6546 6556".split(""); boolean flag= true; String num[] = {"0","1","2","3","4","5","6","7","8","9"}; String specialChars[] = {"-","@","#","*"," "}; for (int x=1; x&lt;result.length; x++) { for (int y=0; y&lt;num.length; y++) { if ((result[x].equals(num[y]))) { flag = false; continue; } else { flag = true; } if (flag == true) break; } if (flag == false) break; } System.out.println(flag); } }
has answer: http://stackoverflow.com/a/2684541
has comment: http://stackoverflow.com/comment/2704468
answer count: 4
has answer: http://stackoverflow.com/a/2684976
favorite count: 0
has title: How to validate phone number(US format) in Java?
accepted answer: http://stackoverflow.com/a/2685040
upvote count: 1
type: AnsweredQuestion
score: 1
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/2704521
downvote count: 0
has answer: http://stackoverflow.com/a/2685180
has answer: http://stackoverflow.com/a/2685040

http://stackoverflow.com/comment/2735377
type: AnswerComment
type: Comment
has text: For the example above, myLinks would need to be final.
comment on: http://stackoverflow.com/a/2710747
score: 0

http://stackoverflow.com/q/2610068
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/5200991
tagged with: logging
has body: we are using the spymemcached memcached client but we didn't discovered how we could disable the logging system. How could we at runtime change the current logging system to something like log4j or sl4j? Notice: We could pass some VM arguments, but the problem is: we can't change our server configuration. Is it possible to pass these VM arguments at runtime? If possible, how could we do that?
tagged with: java
has title: spymemcached - is it possible to disable the logging system?
tagged with: memcached
type: Question
answer count: 2
score: 5
tagged with: spymemcached
upvote count: 5
has answer: http://stackoverflow.com/a/35315400
downvote count: 0
favorite count: 0

http://stackoverflow.com/comment/2633036
comment on: http://stackoverflow.com/a/2620609
score: 0
has text: For performance, I would move outside the pattern compilation, which can occur only once.
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2729770
type: Comment
has text: Have you considered using @NamedQueries instead of constants? They get evaluated and cached when your persistence provider starts. Keeping these queries in the source file of the entity they belong to is also good practice imo.
score: 2
type: AnswerComment
comment on: http://stackoverflow.com/a/2704955

http://stackoverflow.com/q/2687690
tagged with: jpa-2.0
favorite count: 0
has body: I'm trying the following JPQL and it fails misserably: Query query = em.createQuery("SELECT u FROM User u WHERE 'admin' MEMBER OF u.roles"); List users = query.query.getResultList(); I get the following exception: ERROR [main] PARSER.error(454) | <AST>:0:0: unexpected end of subtree java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree [SELECT u FROM com.online.data.User u WHERE 'admin' MEMBER OF u.roles] ERROR [main] PARSER.error(454) | <AST>:0:0: expecting "from", found '<ASTNULL>' ... ... Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree [SELECT u FROM com.online.data.User u WHERE 'admin' MEMBER OF u.roles] I have Spring 3.0.1.RELEASE, Hibernate 3.5.1-Final and maven to glue dependencies. User class: @Entity public class User { @Id @Column(name = "USER_ID") @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; @Column(unique = true, nullable = false) private String username; private boolean enabled; @ElementCollection private Set<String> roles = new HashSet<String>(); ... } Spring configuration: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/tx/spring-context-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"> <tx:annotation-driven transaction-manager="transactionManager" /> update …
possible better answer: http://stackoverflow.com/a/9769072
answer count: 4
type: AnsweredQuestion
tagged with: java
tagged with: hibernate
tagged with: orm
score: 9
type: Question
has answer: http://stackoverflow.com/a/9769072
accepted answer: http://stackoverflow.com/a/2688144
upvote count: 9
has answer: http://stackoverflow.com/a/2687836
has answer: http://stackoverflow.com/a/9713245
has title: JPA 2 and Hibernate 3.5.1 MEMBER OF query doesnt work
has answer: http://stackoverflow.com/a/2688144
tagged with: jpa
downvote count: 0

http://stackoverflow.com/comment/2661192
has text: That's indeed a nice oneliner (+1), but I've profiled it before, it's relatively slow and, above all, it doesn't prefix bytes < 0x10 with zeroes.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2646024

http://stackoverflow.com/comment/2815123
type: AnswerComment
has text: Somewhere i read about using the @Version with a default value of null for this. You could than check if version != null as it should get updated every write. But, the example i saw was using xml. haven't tested it myself (yet)
type: Comment
score: 2
comment on: http://stackoverflow.com/a/2780067

http://stackoverflow.com/a/2678995
upvote count: 7
has comment: http://stackoverflow.com/comment/2699131
has comment: http://stackoverflow.com/comment/2698554
type: AcceptedAnswer
downvote count: 0
has body: There is a System.setOut() method. If you are really desperate, set this to some wrapper of real stdout and do whatever in your wrapper. E.g. compare written string against something and throw if that's the errant output.
type: Answer
accepted answer of: http://stackoverflow.com/q/2678957
answers question: http://stackoverflow.com/q/2678957
score: 7

http://stackoverflow.com/comment/2718870
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2694580
has text: No, the idea here is not to create any more frameworks. We would be testing under the GUI/UI. We have Selenium for testing the GUI. If we ever found ourselves extending the JUnit framework then we would be looking to get out more than we currently need and should then be looking for other existing frameworks.
score: 1

portlet
tags question: http://stackoverflow.com/q/2689020
tags question: http://stackoverflow.com/q/2693473
type: Tag
tag name: portlet
tags question: http://stackoverflow.com/q/2785789
tags question: http://stackoverflow.com/q/2597854

http://stackoverflow.com/comment/2761596
type: AnswerComment
type: Comment
score: 6
has text: If he's shipping a desktop application it's probably advantageous not to have users install a separate database application, hence the OP has given a suggestion of JavaDB and hsqldb, both of which can be embedded in Java applications. I'm not sure how Firebird fits into that though. Of course, this is in no way a dig at Postgres, which to my mind is the obvious choice whenever a database is required: Desktop or Server.
comment on: http://stackoverflow.com/a/2733731

http://stackoverflow.com/q/2684398
tagged with: android
has body: Just to get this out in the open I am new to JAVA, KSOAP, and JSON. So I'll try to explain this the best I can. A while ago I created a webservice to be consumed by Blackberry Apps that we're built using the plug in for Visual Studio. Now the project I am working on, I want to consume the same webservice for Android devices. For the most part I have the base code for the Android app done and working. Here's my problem: I can successfully call the webservice and get a response. I know from creating the webservice that it sends a JSON response. My problem is trying to parse through the JSON response. I have found a few examples that I have been suiting to my needs however I am hung up on one thing. In the JSON each element is preceeded by "anyType" which is forcing my code to return no results (Ultimately I am binding the data to an ArrayList) Here's what I get if I "getProperty(0).toString()... anyType{Artist=anyType{TrackName=Champagne Supernova;}; Here is the code I am using to parse the JSON Object.... SoapObject gr = (SoapObject)envelope.getResponse(); String ro = gr.getProperty(0).toString(); //Added just to see structure of response Artist_Result.add(gr.toString()); if (ro.startsWith("{")) { JSONObject JSONObj = new JSONObject(ro); Iterator<String> itr = JSONObj.keys(); while (itr.hasNext()) { String key = (String)itr.next(); String value = JSONObj.getString(key); //bundleResult.putString(key, value); Artist_Result.add(value); } } else if (ro.startsWith("[")) { JSONArr = new JSONArray(ro); for (int i = 0; i < JSONArr.length(); i++) { JSONObj = (JSONObject)JSONArr.get(i); //bundleResult.putString(String.valueOf(i), JSONObj.toString()); Artist_Result.add(JSONObj.toString()); } } WebService Code: [WebMethod] [return: System.Xml.Serialization.XmlArrayItemAttribute(typeof(Artist))] public Artist[] GetArtist(string ArtistQuery) { // All the SQL Stuff Here SqlDataReader sReader; sReader = cmd.ExecuteReader(); List Artists = new List (); while (sReader.Read()) { Artist…
has title: Parsing a JSON Response from a .Net webservice
favorite count: 0
has answer: http://stackoverflow.com/a/2684820
has comment: http://stackoverflow.com/comment/2704980
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/25544153
downvote count: 0
score: 1
tagged with: java
tagged with: http://stackoverflow.com/tag/json
type: Question
has comment: http://stackoverflow.com/comment/2704472
tagged with: .net
has answer: http://stackoverflow.com/a/2714840
has comment: http://stackoverflow.com/comment/2704484
answer count: 3
upvote count: 1

http://stackoverflow.com/comment/2609515
type: AnswerComment
comment on: http://stackoverflow.com/a/2600370
has text: NetBeans UML support is deprecated, as far as i know (not included in 6.8 anymore).
type: Comment
score: 0

http://stackoverflow.com/a/2706384
downvote count: 0
type: Answer
has body: There is this method Collections.sort() which internally calls Arrays.sort(). This uses the merge sort to sort data which has the order O(nlogn). And one more information is, if the number of elements to be sorted is lesser than 7, it uses the insertion sort. As with Vector and ArrayList following are the complexities since it uses a simple array get(index) - O(1) add(Object) - O(n) insertAt(int pos, Object value) - O(n) remove(Object) - O(n) One more thing is that HashSet internally uses a HashMap only worrying about the keys of a map and the objects being ignored or unused so that there are no two different implementations. And HashMap uses the collision free or the ideal hashing by generating unique hashcodes for every object. So, the order would be ideally 1 for insertion and retrieval of data. Often in Java Collections, especially in Lists, there is this usual comparison between its two concrete implementations, the ArrayList and LinkedList. The order of the LinkedList are as follows. get(index) - O(n) add(Object) - O(1) (provided a readymade last pointer is maintained in the linked list) insertAt(int pos, Object value) - O(n) remove(Object) - O(n)
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/2706256

http://stackoverflow.com/comment/2767133
type: Comment
comment on: http://stackoverflow.com/a/2738410
has text: @ikurtz - if you're curious on what nimbus covers, search around for documentation on what a Java Look & Feel does. There's a lot out there.
type: AnswerComment
score: 0

http://stackoverflow.com/q/2661110
has body: Is it bad to write: if (b == false) //... while (b != true) //... Is it always better to instead write: if (!b) //... while (!b) //... Presumably there is no difference in performance (or is there?), but how do you weigh the explicitness, the conciseness, the clarity, the readability, etc between the two? Update To limit the subjectivity, I'd also appreciate any quotes from authoritative coding style guidelines over which is always preferable or which to use when. Note: the variable name b is just used as an example, ala foo and bar.
has answer: http://stackoverflow.com/a/32988507
has answer: http://stackoverflow.com/a/2661121
has answer: http://stackoverflow.com/a/2661119
has comment: http://stackoverflow.com/comment/12164683
score: 82
has comment: http://stackoverflow.com/comment/5933554
tagged with: coding-style
upvote count: 84
has comment: http://stackoverflow.com/comment/2678730
downvote count: 2
has answer: http://stackoverflow.com/a/2940179
has answer: http://stackoverflow.com/a/2661130
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/50061866
has comment: http://stackoverflow.com/comment/12164555
has comment: http://stackoverflow.com/comment/12816410
has answer: http://stackoverflow.com/a/67063031
tagged with: java
has comment: http://stackoverflow.com/comment/2678973
has answer: http://stackoverflow.com/a/2661122
has title: Is it bad to explicitly compare against boolean constants e.g. if (b == false) in Java?
type: Question
tagged with: boolean
has answer: http://stackoverflow.com/a/2661298
has comment: http://stackoverflow.com/comment/2678572
accepted answer: http://stackoverflow.com/a/2661121
has answer: http://stackoverflow.com/a/2661120
has answer: http://stackoverflow.com/a/2661503
has answer: http://stackoverflow.com/a/14753618
has answer: http://stackoverflow.com/a/16673583
linked to: http://stackoverflow.com/q/13763386
answer count: 16
has answer: http://stackoverflow.com/a/61075619
has answer: http://stackoverflow.com/a/2661160
possible better answer: http://stackoverflow.com/a/2661130
favorite count: 0
has answer: http://stackoverflow.com/a/2661150

http://stackoverflow.com/comment/2618818
comment on: http://stackoverflow.com/a/2608241
has text: @Michael: Thanks, fixed. I wasn't just inventing that, I wonder what language/environment it actually related to? ;-) Or was it true in 1996 or something...
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/66370312
score: 0
type: Comment
has text: Kindly suggest the alternative .
type: QuestionComment
comment on: http://stackoverflow.com/q/2746598

http://stackoverflow.com/a/2721361
score: -1
downvote count: 2
answers question: http://stackoverflow.com/q/2659192
upvote count: 1
type: Answer
has body: Another option is to just use Swing to display html. If you use JEditorPane or JTextPane and just show html. The downside is that you can't do very sophisticated html using this method. You might also consider using a browser in your app. Here are a couple of possibilities though I have not tried them: http://jrex.mozdev.org http://lobobrowser.org/java-browser.jsp http://www.webrenderer.com/
has comment: http://stackoverflow.com/comment/37206407

http://stackoverflow.com/comment/2630442
type: Comment
has text: I'm using Java -- not python. This is the one line: <page name="Appstats" url="/appstats/stats" />. I've tried /appstats and /appstats/stats. It has the same issue.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/2618473

http://stackoverflow.com/comment/57811377
type: AnswerComment
has text: @Rafi Abro - email me your code and a sample output you are expecting to get. My email thedath.oudarya@gmail.com
type: Comment
comment on: http://stackoverflow.com/a/32515408
score: 0

http://stackoverflow.com/q/2775411
tagged with: date
type: Question
has body: I need to make map where Dates are keys. 2 date objects are equals if they have the same value of getTime() method. I'm interested only in year, month and day. How can I trim unnecessary hours and minutes to get 'clear' dates?
has answer: http://stackoverflow.com/a/41024760
linked to: http://stackoverflow.com/q/38922754
downvote count: 0
answer count: 6
has answer: http://stackoverflow.com/a/40231862
favorite count: 0
has answer: http://stackoverflow.com/a/2775557
linked to: http://stackoverflow.com/q/1908387
upvote count: 11
has answer: http://stackoverflow.com/a/2775479
duplicate of: http://stackoverflow.com/q/1908387
score: 11
has answer: http://stackoverflow.com/a/2775466
has title: How to trim minutes and hours and seconds from Date object?
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2775479
tagged with: java
has answer: http://stackoverflow.com/a/2775458
accepted answer: http://stackoverflow.com/a/2775466

http://stackoverflow.com/q/2622257
accepted answer: http://stackoverflow.com/a/2622331
downvote count: 0
answer count: 3
has answer: http://stackoverflow.com/a/2622344
favorite count: 0
has answer: http://stackoverflow.com/a/2622336
score: 2
has title: Java Swing: Expanding TreeNode
tagged with: swing
type: AnsweredQuestion
tagged with: java
has body: I am working on customizing a closed source client application. It has a tree in the UI and exposed only a method to get the selected node. It returns a subclass of TreeNode. And there is no way to get a reference to the parent tree. Now i want to expand the selected node upto its leaves. Is there any way to get a reference to the JTree component from a DefaultMutableTreeNode? I am planning to use the JTree.expandPath() but I only have the reference to the treenode. I'm new to Swing and any suggestions to achieve this are welcome.
possible better answer: http://stackoverflow.com/a/2622336
type: Question
upvote count: 2
has answer: http://stackoverflow.com/a/2622331

http://stackoverflow.com/a/2746675
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2738326
has body: I have never done this with multidimensional arrays but it should be something like this (though I haven't tried it, it's just to give you an idea). In the JSP you should set the name of the input with each index, something like this: &lt;c:forEach var="row" items="${days}" varStatus="statusRow"&gt; &lt;c:forEach var="day" items="${row}" varStatus="statusCol"&gt; &lt;input type="text" name="days[${statusRow.index}][${statusCol.index}].title" value="${day.title}"/&gt; &lt;/c:forEach&gt; &lt;/c:forEach&gt; and in the controller you have to prepare days variable so the size of the array is the same as the one you get from the JSP. So you can use @ModelAttribute method to prepare the array (this method will be executed before the @RequestMapping method). @ModelAttribute("days") public getDays(){ DayInfo[][] days; //Here you have to instantiate the days to prepare it so it can be filled //You can load for example the data from the database return days; } @RequestMapping("/yourURL") public String getFormData(@ModelAttribute("days")DayInfo[][] days){ //Here in days you should have the data from the form overriding // the one from the database } Hope this helps and sorry if there is any error, though I'm writing withoug trying it.
answers question: http://stackoverflow.com/q/2738326
type: Answer
upvote count: 1
score: 1
type: AcceptedAnswer

http://stackoverflow.com/comment/2645108
type: AnswerComment
comment on: http://stackoverflow.com/a/2631657
type: Comment
score: 2
has text: Throwing an exception from inside the catch - i.e. if the exception is not recoverable - or setting the variable value in the catch clause would solve it as well.

http://stackoverflow.com/a/69159469
has comment: http://stackoverflow.com/comment/123210985
has comment: http://stackoverflow.com/comment/122526796
type: Answer
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/2736389
upvote count: 2
has body: Create your custom class like this: public class Test implements Parcelable { String message; protected Test(Parcel in) { message = in.readString(); } public static final Creator<Test> CREATOR = new Creator<Test>() { @Override public Test createFromParcel(Parcel in) { return new Test(in); } @Override public Test[] newArray(int size) { return new Test[size]; } }; public String getMessage() { return message; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(message); } Send data using Intent like this: Before starting your activity must set some data Intent intent = new Intent(context, PostDetailsActivity.class); intent.putExtra("data", (Parcelable) test); ((context)).startActivity(intent); Get data from intent like this: Test test = (Test) getIntent().getParcelableExtra("data");

http://stackoverflow.com/comment/134647896
comment on: http://stackoverflow.com/a/69930984
score: 4
type: AnswerComment
type: Comment
has text: Thank you, this is way simpler than writing a custom `ConstraintValidator` and it also needs less code. I think this should be preferred over the accepted solution for this simple use case.

http://stackoverflow.com/comment/2673638
type: Comment
has text: friends, I'm going to use http://www.setcronjob.com but I gives cron job of 5 minutes interval for free accounts :( Anyways, i'm happy with it. Thank you all for your suggestions :)
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2656747

http://stackoverflow.com/a/2723984
has comment: http://stackoverflow.com/comment/2751583
has body: What comes to mind initially is creating a ServletFilter (configured in your web.xml) to look at each request and re-route the request if it meets your specific criteria. See tutorial here.
type: Answer
answers question: http://stackoverflow.com/q/2723829
accepted answer of: http://stackoverflow.com/q/2723829
score: 0
type: AcceptedAnswer

executorservice
type: Tag
tags question: http://stackoverflow.com/q/2712232
tag name: executorservice
tags question: http://stackoverflow.com/q/2758612
tags question: http://stackoverflow.com/q/2665569
tags question: http://stackoverflow.com/q/2596916

http://stackoverflow.com/a/2632904
has body: Maybe this Dialog Focus solution will work on Ubuntu (I can't test it). It shows the focus in the text field and fast change to the button. Or you could try wrapping the requestFocusInWindow() method call in a SwingUtilities.invokeLater() to place your requrest on the end of the EDT.
score: 0
has comment: http://stackoverflow.com/comment/2686945
answers question: http://stackoverflow.com/q/2632785
type: Answer

http://stackoverflow.com/comment/2731523
comment on: http://stackoverflow.com/a/2707580
has text: @TP - you can do that. Depends on whether you need the reason for display to the user (a string would be perfect) or for programmatic reasons (e.g. a limited-value return type would be needed to determine what the program should do in case of an error based on what the reason is)
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/2618595
type: AnsweredQuestion
score: 2
tagged with: attachment
tagged with: java
has body: I want to know how can I read attachment messages without using scriplets in JSP? After getting Message object as an attribute by using request object from servlets, how can I confirm whether Message content is an instance of Multipart or not without using scriplets like: if(message.getContent() instanceOf Multipart) How can I read the content of any file by using EL in JSP? As I can't see any getRead method in inputStream subclass.
has answer: http://stackoverflow.com/a/2618612
type: Question
answer count: 2
accepted answer: http://stackoverflow.com/a/2618620
downvote count: 0
tagged with: jsp
tagged with: jakarta-mail
has answer: http://stackoverflow.com/a/2618620
possible better answer: http://stackoverflow.com/a/2618612
favorite count: 0
has title: How to read attachment messages without using scriptlets in JSP?
upvote count: 2

android-relativelayout
tags question: http://stackoverflow.com/q/2720719
type: Tag
tag name: android-relativelayout

http://stackoverflow.com/a/2622286
has body: it just means that you will get the same class out of that method that you're putting in, to save it being Object and you having to cast all the time.
downvote count: 0
answers question: http://stackoverflow.com/q/2622259
upvote count: 2
type: Answer
score: 2

http://stackoverflow.com/a/2685644
upvote count: 6
downvote count: 2
has body: A type class can be compared to the concept of 'implementing' an interface. If some data type in Haskell implements the "Show" interface, it can be used with all functions that expect a "Show" object.
score: 4
answers question: http://stackoverflow.com/q/2685626
type: Answer

http://stackoverflow.com/comment/2820387
type: Comment
has text: The args array holds the command line arguments. You need to find the place in Jcreator where it let's you provide the arguments to the program when you run it.
comment on: http://stackoverflow.com/a/2784838
type: AnswerComment
score: 0

http://stackoverflow.com/q/2627237
accepted answer: http://stackoverflow.com/a/2627776
has answer: http://stackoverflow.com/a/2627284
has comment: http://stackoverflow.com/comment/2640541
upvote count: 4
has comment: http://stackoverflow.com/comment/2640333
has comment: http://stackoverflow.com/comment/2640425
downvote count: 0
tagged with: javascript
has title: Most effective server side programming language for web development?
favorite count: 0
possible better answer: http://stackoverflow.com/a/2627263
has answer: http://stackoverflow.com/a/2627283
has answer: http://stackoverflow.com/a/2627263
has answer: http://stackoverflow.com/a/2627490
has answer: http://stackoverflow.com/a/2627375
has answer: http://stackoverflow.com/a/2627776
has comment: http://stackoverflow.com/comment/2640307
tagged with: server-side
has comment: http://stackoverflow.com/comment/2640619
score: 4
has answer: http://stackoverflow.com/a/2627287
has comment: http://stackoverflow.com/comment/2640298
tagged with: php
type: Question
answer count: 8
has answer: http://stackoverflow.com/a/2627310
type: AnsweredQuestion
has body: This is more a question of pros/cons between PHP and JAVA. Iv been doing research, and iv narrowed it down to those two. And in consideration, id like to go into mobile app dev...So thats +1 for Java. Time taken to learn the language is not an issue...Just would like to know which is the most effective between the two languages mentioned above. And on a slight note. Can Javascript work with Java? And what is the real advantage of that? All answers are appreciated, thanks in advance.
tagged with: java

http://stackoverflow.com/a/2599821
accepted answer of: http://stackoverflow.com/q/2599797
upvote count: 1
has body: make sure ID_DATEPICKER and TIME_DIALOG_ID do not have the same int value.
score: 1
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2599797
type: Answer

http://stackoverflow.com/q/2783567
has comment: http://stackoverflow.com/comment/2818805
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2784246
tagged with: java
accepted answer: http://stackoverflow.com/a/2784246
possible better answer: http://stackoverflow.com/a/2783620
has answer: http://stackoverflow.com/a/2783620
type: Question
has body: I'm trying to make a program that solves the logic wheels puzzle. I construct the root node and I try to produce the different child-nodes that are produced by making different moves of the wheels. The problem is that while I try to produce the children, the root node is overwrited,and everything is messed-up and I really don't know why. Here you can find the puzzle logic wheels. I represent the wheels as 3x3 arrays. Here is the code that implements the moves: public Node turn_right(Node aNode, int which_wheel) { Node newNode = new Node(aNode.getYellow_wheel(),aNode.getBlue_wheel(),aNode.getGreen_wheel()); int[][] yellow = new int[3][3]; int[][] blue = new int[3][3]; int[][] green = new int[3][3]; if(which_wheel==0) //turn yellow wheel of this node to right { yellow[1][0] = newNode.getYellow_wheel()[0][0]; yellow[2][0] = newNode.getYellow_wheel()[1][0]; yellow[2][1] = newNode.getYellow_wheel()[2][0]; yellow[2][2] = newNode.getYellow_wheel()[2][1]; yellow[1][2] = newNode.getYellow_wheel()[2][2]; yellow[0][2] = newNode.getYellow_wheel()[1][2]; yellow[0][1] = newNode.getYellow_wheel()[0][2]; yellow[0][0] = newNode.getYellow_wheel()[0][1]; blue = newNode.getBlue_wheel(); blue[1][0] = newNode.getYellow_wheel()[1][2]; blue[2][0] = newNode.getYellow_wheel()[2][2]; green = newNode.getGreen_wheel(); } else if(which_wheel == 1)// turn blue wheel of this node to right { blue[1][0] = newNode.getBlue_wheel()[0][0]; blue[2][0] = newNode.getBlue_wheel()[1][0]; blue[2][1] = newNode.getBlue_wheel()[2][0]; blue[2][2] = newNode.getBlue_wheel()[2][1]; blue[1][2] = newNode.getBlue_wheel()[2][2]; blue[0][2] = newNode.getBlue_wheel()[1][2]; blue[0][1] = newNode.getBlue_wheel()[0][2]; blue[0][0] = newNode.getBlue_wheel()[0][1]; yellow = newNode.getYellow_wheel(); yellow[0][2] = newNode.getBlue_wheel()[0][0]; yellow[1][2] = newNode.getBlue_wheel()[1][0]; green = newNode.getGreen_wheel(); green[1][0] = newNode.getBlue_wheel()[1][2]; green[2][0] = newNode.getBlue_wheel()[2][2]; } else if (whi…
has title: java - unwanted object overwriting
score: 0
answer count: 2
tagged with: overwrite

sha1
tags question: http://stackoverflow.com/q/2678138
tag name: sha1
type: Tag

xml-parsing
tags question: http://stackoverflow.com/q/2599919
tag name: xml-parsing
type: Tag
tags question: http://stackoverflow.com/q/2640825

http://stackoverflow.com/comment/127469638
comment on: http://stackoverflow.com/a/67920585
has text: I would encourage more, and different, experimentation. my own experiments (detailed in another answer on this same question) show that the max value is not used in Java SE versions 1.8.0, 11.0.3, 11.0.14 as well OpenJDK versions 12.0.1, 13, and 17.0.1. instead, the right-most value is used.
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/a/2655298
type: Answer
has body: public int test(double decimalAmount, int divisor) { return (int) (divisor * decimalAmount); } Obviously, this is just multiplying then truncating. Why you think you need this method?
upvote count: 3
score: 3
answers question: http://stackoverflow.com/q/2655280
downvote count: 0

eclipse
tags question: http://stackoverflow.com/q/2657619
tags question: http://stackoverflow.com/q/2644440
tag name: eclipse
tags question: http://stackoverflow.com/q/2616493
tags question: http://stackoverflow.com/q/2727669
tags question: http://stackoverflow.com/q/2600097
tags question: http://stackoverflow.com/q/2777314
tags question: http://stackoverflow.com/q/2597889
tags question: http://stackoverflow.com/q/2725563
tags question: http://stackoverflow.com/q/2768518
tags question: http://stackoverflow.com/q/2690635
tags question: http://stackoverflow.com/q/2612633
tags question: http://stackoverflow.com/q/2678488
tags question: http://stackoverflow.com/q/2716400
tags question: http://stackoverflow.com/q/2785333
tags question: http://stackoverflow.com/q/2717889
tags question: http://stackoverflow.com/q/2726182
tags question: http://stackoverflow.com/q/2750142
tags question: http://stackoverflow.com/q/2750346
tags question: http://stackoverflow.com/q/2615386
tags question: http://stackoverflow.com/q/2777377
tags question: http://stackoverflow.com/q/2724352
tags question: http://stackoverflow.com/q/2665906
tags question: http://stackoverflow.com/q/2721385
tags question: http://stackoverflow.com/q/2638016
tags question: http://stackoverflow.com/q/2687773
tags question: http://stackoverflow.com/q/2683486
tags question: http://stackoverflow.com/q/2677194
tags question: http://stackoverflow.com/q/2735539
tags question: http://stackoverflow.com/q/2616746
tags question: http://stackoverflow.com/q/2603580
tags question: http://stackoverflow.com/q/2673554
tags question: http://stackoverflow.com/q/2692643
tags question: http://stackoverflow.com/q/2757152
tags question: http://stackoverflow.com/q/2736126
tags question: http://stackoverflow.com/q/2737486
tags question: http://stackoverflow.com/q/2785053
tags question: http://stackoverflow.com/q/2637735
tags question: http://stackoverflow.com/q/2647154
tags question: http://stackoverflow.com/q/2643038
tags question: http://stackoverflow.com/q/2693108
tags question: http://stackoverflow.com/q/2599222
tags question: http://stackoverflow.com/q/2733022
tags question: http://stackoverflow.com/q/2753802
tags question: http://stackoverflow.com/q/2621996
tags question: http://stackoverflow.com/q/2758642
tags question: http://stackoverflow.com/q/2738574
tags question: http://stackoverflow.com/q/2642069
tags question: http://stackoverflow.com/q/2631778
tags question: http://stackoverflow.com/q/2719650
tags question: http://stackoverflow.com/q/2641644
tags question: http://stackoverflow.com/q/2751633
tags question: http://stackoverflow.com/q/2690022
tags question: http://stackoverflow.com/q/2650844
tags question: http://stackoverflow.com/q/2632419
tags question: http://stackoverflow.com/q/2655964
tags question: http://stackoverflow.com/q/2655836
tags question: http://stackoverflow.com/q/2599919
tags question: http://stackoverflow.com/q/2615265
tags question: http://stackoverflow.com/q/2776786
tags question: http://stackoverflow.com/q/2680334
tags question: http://stackoverflow.com/q/2644112
tags question: http://stackoverflow.com/q/2760817
tags question: http://stackoverflow.com/q/2653399
tags question: http://stackoverflow.com/q/2770543
tags question: http://stackoverflow.com/q/2682913
tags question: http://stackoverflow.com/q/2744127
tags question: http://stackoverflow.com/q/2681883
tags question: http://stackoverflow.com/q/2615781
tags question: http://stackoverflow.com/q/2636201
tags question: http://stackoverflow.com/q/2698253
tags question: http://stackoverflow.com/q/2638446
tags question: http://stackoverflow.com/q/2764140
tags question: http://stackoverflow.com/q/2782912
tags question: http://stackoverflow.com/q/2769020
tags question: http://stackoverflow.com/q/2635113
tags question: http://stackoverflow.com/q/2600474
tags question: http://stackoverflow.com/q/2739713
tags question: http://stackoverflow.com/q/2638622
tags question: http://stackoverflow.com/q/2608763

http://stackoverflow.com/comment/14106958
type: Comment
has text: Answers which just contain links are [considered bad practice](http://meta.stackexchange.com/questions/8231/are-answers-that-just-contain-links-elsewhere-really-good-answers). Please summarize the content here (don't copy/paste) so the answer can stand on its own. If you don't you run the risk of your answer being removed, especially if the link ever dies.
score: 1
comment on: http://stackoverflow.com/a/10834689
type: AnswerComment

http://stackoverflow.com/a/2729907
downvote count: 0
answers question: http://stackoverflow.com/q/2729580
type: Answer
has body: As mentioned in the comments on Roman's answer, the parameter names can be retrieved if the compiler included debugging symbols, though not through the standard Java Reflection API. Below is an example illustrating how you could obtain parameter names via the debugging symbols using the ASM bytecode library: /** * Returns a list containing one parameter name for each argument accepted * by the given constructor. If the class was compiled with debugging * symbols, the parameter names will match those provided in the Java source * code. Otherwise, a generic "arg" parameter name is generated ("arg0" for * the first argument, "arg1" for the second...). * * This method relies on the constructor's class loader to locate the * bytecode resource that defined its class. * * @param constructor * @return * @throws IOException */ public static List&lt;String&gt; getParameterNames(Constructor&lt;?&gt; constructor) throws IOException { Class&lt;?&gt; declaringClass = constructor.getDeclaringClass(); ClassLoader declaringClassLoader = declaringClass.getClassLoader(); Type declaringType = Type.getType(declaringClass); String constructorDescriptor = Type.getConstructorDescriptor(constructor); String url = declaringType.getInternalName() + ".class"; InputStream classFileInputStream = declaringClassLoader.getResourceAsStream(url); if (classFileInputStream == null) { throw new IllegalArgumentException("The constructor's class loader cannot find the bytecode that defined the constructor's class (URL: " + url + ")"); } ClassNode classNode; try { classNode = new ClassNode(); ClassReader classReader = new ClassReader(classFileInputStream); classReader.accept(classNode, 0); } finally { classFileInputStream.close(); } @SuppressWarnings("unchecked") List&lt;MethodNode&gt; methods = classNode.methods; for (MethodNode method : methods) { if (method.name.equals("&lt;init&gt;") &amp;&amp; method.desc.equals(constructorDescriptor)) { Type[] argumentTypes = Type.getArgumentTypes(method.desc); List&…
upvote count: 21
score: 21

http://stackoverflow.com/comment/2771030
type: AnswerComment
comment on: http://stackoverflow.com/a/2741654
type: Comment
has text: That's also wrong. You can have classes with the same name but in different packages. To take a real world example: `java.util.Date` and `java.sql.Date`. The default package is just convenient for small and simple one-or-maybe-two-class-sized applications as you were tought in basic tutorials. But in real world enterprise applications? No, forget about it. Forever. All the other classes ain't going to see the packageless ones.
score: 0

http://stackoverflow.com/a/34217962
downvote count: 3
upvote count: 0
answers question: http://stackoverflow.com/q/2599440
has comment: http://stackoverflow.com/comment/62925196
type: Answer
has body: you can access it outside of the class its very easy to access just take an example of singaltan class we all does the same thing make the private constructor and access the instance by static method here is the code associated to your query ClassWithPrivateConstructor.getObj().printsomething(); it will definately work because i have already tested
score: -3
has comment: http://stackoverflow.com/comment/95134680

http://stackoverflow.com/q/2645775
tagged with: java
type: Question
upvote count: 4
has answer: http://stackoverflow.com/a/2645807
has body: I would like to create extend a Java Swing application to have a look somewhat similar to an IDE such as Eclipse or Visual Studio. That’s, there would be a panel at the left that displays a tree, and a tab panel on the right that allows several elements of the tree to be opened and edited on right. For this I could easily use a BorderLayout and just use the center and left areas. However, I would also like to have the ability for the user to drag the border between these two panels, just like Eclipse and Visual Studio allow. I can think of several ways to do this, but was curious if anyone had found a particularly good way to do this, or knew of an example. I’ve googled for it, but have not found anything.
score: 4
has title: Create a Visual Studio type look using Java Swing
answer count: 2
downvote count: 0
accepted answer: http://stackoverflow.com/a/2645807
favorite count: 0
possible better answer: http://stackoverflow.com/a/2655917
tagged with: swing
has answer: http://stackoverflow.com/a/2655917
type: AnsweredQuestion

http://stackoverflow.com/a/2716932
type: Answer
has body: Look in the manual under the heading Default Initialization Procedure, where you'll find the following: The exact default initialization algorithm is defined as follows: Setting the log4j.defaultInitOverride system property to any other value than "false" will cause log4j to skip the default initialization procedure (this procedure). Set the resource string variable to the value of the log4j.configuration system property. The preferred way to specify the default initialization file is through the log4j.configuration system property. In case the system property log4j.configuration is not defined, then set the string variable resource to its default value "log4j.properties". Attempt to convert the resource variable to a URL. If the resource variable cannot be converted to a URL, for example due to a MalformedURLException, then search for the resource from the classpath by calling org.apache.log4j.helpers.Loader.getResource(resource, Logger.class) which returns a URL. Note that the string "log4j.properties" constitutes a malformed URL. See Loader.getResource(java.lang.String) for the list of searched locations. If no URL could not be found, abort default initialization. Otherwise, configure log4j from the URL. The PropertyConfigurator will be used to parse the URL to configure log4j unless the URL ends with the ".xml" extension, in which case the DOMConfigurator will be used. You can optionaly specify a custom configurator. The value of the log4j.configuratorClass system property is taken as the fully qualified class name of your custom configurator. The custom configurator you specify must implement the Configurator interface.
has comment: http://stackoverflow.com/comment/87532469
upvote count: 39
score: 37
has comment: http://stackoverflow.com/comment/32609446
has comment: http://stackoverflow.com/comment/96776200
downvote count: 2
answers question: http://stackoverflow.com/q/2716824

http://stackoverflow.com/q/2739447
has answer: http://stackoverflow.com/a/2739527
upvote count: 3
tagged with: java
has body: I need my program to send a request to a server. The problem is, the server only recognizes ös,äs und üs, but JAVA and/or Android don't know them. `How can I send a request with a String like "Hermann-Löns" without JAVA/Android "changing" the ö.... Oh and btw., "oe" isn't recognized by the server too, already tried that... thx for help! @BalausC: I changed your code to: I'm not sure if this is how you refer to the right fields... String url = "http://busspur02.aseag.de/bs.exe?SID=473A2&amp;ScreenX=1440&amp;ScreenY=900&amp;CMD=CR&amp;DatumT=30&amp;DatumM=4&amp;DatumJ=2010&amp;AbfAnk=Abf&amp;ZeitH=10&amp;ZeitM=45&amp;Intervall=60&amp;Loeschen=%28N%29eue+Suche"; String charset = "CP1252"; List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); params.add(new BasicNameValuePair("HTO", start_from)); params.add(new BasicNameValuePair("HT1", destination)); UrlEncodedFormEntity query = new UrlEncodedFormEntity(params, charset); HttpPost post = new HttpPost(url); post.setEntity(query); InputStream response = new DefaultHttpClient().execute(post).getContent(); // Now do your thing with the facebook response. I can't compile because I get an error saying: The method getContent() is undefined for the type HttpResponse If I delete getContent() is says: Type mismatch: cannot convert from HttpResponse to InputStream One more thing: I use htmlparser (http://htmlparser.sourceforge.net/) to parse the resulting website. How do I access the resulting html site to parse it? Because otherwise I would have to rewrite nearly all of my code to get the results..
tagged with: special-characters
has comment: http://stackoverflow.com/comment/2768018
type: Question
downvote count: 0
answer count: 1
tagged with: unicode
accepted answer: http://stackoverflow.com/a/2739527
score: 3
linked to: http://stackoverflow.com/q/2737789
favorite count: 0
has title: I need to use "ö","ä"."ü" in my program, but java/android won't let me
tagged with: android
has comment: http://stackoverflow.com/comment/2768839
type: AnsweredQuestion

http://stackoverflow.com/a/2619403
score: 0
has comment: http://stackoverflow.com/comment/2631760
has comment: http://stackoverflow.com/comment/2631974
has body: I don't know how to do this on Windows, but on UNIX, there is a program called expect that is designed for such a task. If you install Cygwin, you should be able to use the expect utility on Windows.
type: Answer
answers question: http://stackoverflow.com/q/2619395

http://stackoverflow.com/a/2703017
has body: Your code is just assigning hour/minute to constants. You need to call Calendar.get(int): hour = time.get(Calendar.HOUR_OF_DAY); minute = time.get(Calendar.MINUTE);
type: Answer
answers question: http://stackoverflow.com/q/2702971
upvote count: 10
accepted answer of: http://stackoverflow.com/q/2702971
score: 10
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/2739725
has comment: http://stackoverflow.com/comment/2768435
favorite count: 0
upvote count: 9
tagged with: compiler-errors
has comment: http://stackoverflow.com/comment/2768407
has comment: http://stackoverflow.com/comment/2768506
has comment: http://stackoverflow.com/comment/2768460
has comment: http://stackoverflow.com/comment/2768456
accepted answer: http://stackoverflow.com/a/2739796
has comment: http://stackoverflow.com/comment/2768445
has comment: http://stackoverflow.com/comment/60531345
answer count: 4
has comment: http://stackoverflow.com/comment/2768479
score: 2
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2768441
has comment: http://stackoverflow.com/comment/2768396
tagged with: java
possible better answer: http://stackoverflow.com/a/2739743
has answer: http://stackoverflow.com/a/2739796
has title: "Invalid assignment" error from == operator
has answer: http://stackoverflow.com/a/2739743
type: Question
has comment: http://stackoverflow.com/comment/2768428
has comment: http://stackoverflow.com/comment/2768427
has answer: http://stackoverflow.com/a/2739752
has comment: http://stackoverflow.com/comment/2769237
has answer: http://stackoverflow.com/a/2739842
downvote count: 7
has body: I was trying to write a simple method: boolean validate(MyObject o) { // propertyA &amp;&amp; propertyB are not primitive types. return o.getPropertyA() == null &amp;&amp; o.getPropertyB() == null; } And got a strange error on the == null part: Syntax error on token ==. Invalid assignment operator. Maybe my Java is rusty after a season in PLSQL. So I tried a simpler example: Integer i = 4; i == null; // compile error: Syntax error on token ==. Invalid assignment operator. Integer i2 = 4; if (i == null); //No problem How can this be? I'm using jdk160_05. To clarify: I'm not trying to assign anything, just do an &amp;&amp; operation between two boolean values. I don't want to do this: if (o.propertyA() == null &amp;&amp; o.propertyB() == null) { return true; } else { return false; }
has comment: http://stackoverflow.com/comment/136706895

http://stackoverflow.com/q/2617792
has comment: http://stackoverflow.com/comment/2630234
has answer: http://stackoverflow.com/a/2617826
has comment: http://stackoverflow.com/comment/2629815
type: AnsweredQuestion
score: 21
tagged with: java
downvote count: 3
has title: Programs that reproduces itself
upvote count: 24
type: Question
has answer: http://stackoverflow.com/a/31979884
has answer: http://stackoverflow.com/a/2617950
has comment: http://stackoverflow.com/comment/2629709
has answer: http://stackoverflow.com/a/2617813
has answer: http://stackoverflow.com/a/2619244
has answer: http://stackoverflow.com/a/2619166
tagged with: quine
has answer: http://stackoverflow.com/a/2617924
possible better answer: http://stackoverflow.com/a/2619166
has body: Is it possible to make a Java program that prints its source code to a new file, and compiles it, and runs the compiled program?
has answer: http://stackoverflow.com/a/59951896
favorite count: 0
has comment: http://stackoverflow.com/comment/2629664
answer count: 9
has answer: http://stackoverflow.com/a/2617844
accepted answer: http://stackoverflow.com/a/2617813

http://stackoverflow.com/comment/99800584
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2769018
has text: Dead link. That's why SO generally frowns on answers that are just links.

http://stackoverflow.com/q/2599776
type: Question
answer count: 1
downvote count: 0
has title: Performance side effect with static internal Util classes?
has answer: http://stackoverflow.com/a/2599789
favorite count: 0
upvote count: 1
has body: For a util class that contains a bunch of static functionality that's related to the same component, but has different purposes, I like to use static internal classes to organize the functionality, like so: class ComponentUtil { static class Layout { static int calculateX(/* ... */) { // ... } static int calculateY(/* ... */) { // ... } } static class Process { static int doThis(/* ... */) { // ... } static int doThat(/* ... */) { // ... } } } Is there any performance degradation using these internal classes vs. just having all the functionality in the Util class?
type: AnsweredQuestion
score: 1
tagged with: java
accepted answer: http://stackoverflow.com/a/2599789

http://stackoverflow.com/comment/2770611
comment on: http://stackoverflow.com/q/2741677
has text: Is this question related? http://stackoverflow.com/questions/2740852/finding-the-best-person-in-an-array
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/2675447
type: AnswerComment
comment on: http://stackoverflow.com/a/2658446
type: Comment
has text: I don't fully understand you. Each row in the table contains the name of a file, its author and I want to add the information extracted and that now is being stored in .txt files.
score: 0

http://stackoverflow.com/a/30274891
has body: In addition to all the great answers provided here, the official Java SE 7 programming guide has a pretty concise manual on using assert; with several spot-on examples of when it's a good (and, importantly, bad) idea to use assertions, and how it's different from throwing exceptions. Link
downvote count: 0
answers question: http://stackoverflow.com/q/2758224
type: Answer
score: 6
upvote count: 6
has comment: http://stackoverflow.com/comment/65530734

http://stackoverflow.com/q/2641732
answer count: 3
tagged with: eclipselink
possible better answer: http://stackoverflow.com/a/2641875
has answer: http://stackoverflow.com/a/2648711
tagged with: jpa-2.0
has title: JPA 2.0 EclipseLink Check for unique
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2641875
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/2641947
tagged with: jpa
accepted answer: http://stackoverflow.com/a/2648711
score: 0
has body: I have a collumn as unique=true.. in Exam class.... I found that because transactions are commited automaticaly so to force the commit i use em.commit() However i would like to know how to check if it is unique.Running a query isnt a solution because it may be an instert after checking because of the concurency.... Which is the best way to check for uniqness? List&lt;Exam_Normal&gt; exam_normals = exam.getExam_Normal(); exam.setExam_Normal(null); try { em.persist(exam); em.flush(); Long i = 0L; if (exam_normals != null) { for (Exam_Normal e_n : exam_normals) { i++; e_n.setItem(i); e_n.setId(exam); em.persist(e_n); } } } catch (Exception e) { System.out.print("sfalma--"); } } d

http://stackoverflow.com/comment/104157645
score: 0
type: AnswerComment
type: Comment
has text: This code keeps opening and leaking `ServerSockets` forever and only retains the *last* one that succeeded. It needs a `break` statement.
comment on: http://stackoverflow.com/a/2675376

image-manipulation
tags question: http://stackoverflow.com/q/2597872
tag name: image-manipulation
tags question: http://stackoverflow.com/q/2752174
tags question: http://stackoverflow.com/q/2783204
tags question: http://stackoverflow.com/q/2752493
type: Tag
tags question: http://stackoverflow.com/q/2690710
tags question: http://stackoverflow.com/q/2736320

http://stackoverflow.com/comment/2694767
score: 0
type: AnswerComment
has text: Ok, so I was wrong when I said it isn't the secure random generation. After a little more debugging I realized my initial test of the secure random part of this was insufficient. I had only tested the construction of new SecureRandom(). When I tested the first invocation of nextLong() on the SecureRandom, I saw that was the source of the 5 second delay.
type: Comment
comment on: http://stackoverflow.com/a/2608848

http://stackoverflow.com/q/2599394
tagged with: forms
has body: I use jQuery and AJAX to load content from links and forms into a content div. In addition I use the Address plugin to enable the back button and refresh. On the server side I use Java and Spring MVC. Since I'm using jQuery Address and AJAX the only page that is directly loaded is "index.html". Everything else is loaded into a content div, and what page to load is specified in the hash, ie. "index.html#/users/add.html" will load "users/add.html". Now, "users/add.html" contains a form for creating a new user. When the form is submitted and everything went OK, the controller redirects to "users/index.html". The problem is that jQuery Address doesn't know about the redirect, so the url will remain "index.html#/users/add.html". And this is a problem when you refresh the page and then get sent back to the form, instead of the index page. Is there a way to fix this problem? Thanks, Stian
linked to: http://stackoverflow.com/q/2628542
answer count: 3
has answer: http://stackoverflow.com/a/2606012
upvote count: 1
tagged with: jquery
favorite count: 0
has answer: http://stackoverflow.com/a/2608716
has title: jQuery Address - redirect after form submit
type: AnsweredQuestion
downvote count: 0
possible better answer: http://stackoverflow.com/a/2606012
score: 1
linked to: http://stackoverflow.com/q/199099
tagged with: java
has answer: http://stackoverflow.com/a/2676020
accepted answer: http://stackoverflow.com/a/2676020
type: Question
tagged with: deep-linking
has comment: http://stackoverflow.com/comment/2616058

http://stackoverflow.com/a/2675239
answers question: http://stackoverflow.com/q/2672966
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2672966
type: Answer
has body: You could do something with writing a job listener to recognize when the first job ends, and have it start the second. But the solution first suggested by mindas is easier - wrap both your jobs in another Job implementation, which is the one you actually schedule.
score: 0

http://stackoverflow.com/comment/10388489
score: 48
type: AnswerComment
has text: +1. I spend my 20 minutes in finding 'create project from existing source' option.
type: Comment
comment on: http://stackoverflow.com/a/6669337

http://stackoverflow.com/comment/2661415
type: Comment
has text: "how do I Add a file open and close function to the program." <-- That's the only part of your post that resembles a question. The rest sounds like a homework assignment or a business requirement that is up to you to figure out.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/2633188

http://stackoverflow.com/q/2759805
linked to: http://stackoverflow.com/q/2063467
favorite count: 0
has title: Unable to persist objects in GAE JDO
possible better answer: http://stackoverflow.com/a/2759903
has answer: http://stackoverflow.com/a/2759903
has answer: http://stackoverflow.com/a/2761961
tagged with: google-app-engine
type: AnsweredQuestion
tagged with: java
tagged with: jdo
has body: I am completely fresh to both JDO and GAE, and have been struggling to get my data layer to persist any code at all! The issues I am facing may be very simple, but I just cant seem to find any a way no matter what solution I try. Firstly the problem: (Slightly simplified, but still contains all the info necessary) My data model is as such: User: (primary key) String emailID String firstName Car: (primary key) User user (primary key) String registration String model This was the initial datamodel. I implemented a CarPK object to get a composite primary key of the User and the registration. However that ran into a variety of issues. (Which i will save for another time/question) I then changed the design as such: User: (Unchanged) Car: (primary key) String fauxPK (here fauxPK = user.getEmailID() + SEP + registration) User user String registration String model This works fine for the user, and it can insert and retrieve user objects. However when i try to insert a Car Object, i get the following error: "Cannot have a java.lang.String primary key and be a child object" Found the following helpful link about it: http://stackoverflow.com/questions/2063467/persist-list-of-objects Went to the link suggested there, that explains how to create Keys, however they keep talking about "Entity Groups" and "Entity Group Parents". But I cant seem to find any articles or sites that explain what are "Entity Group"s or an "Entity Group Parents" I could try fiddling around some more to figure out if i can store an object somehow, But I am running sort on patience and also would rather understand and implement than vice versa. So i would appreciate any docs (even if its huge) that covers all these points, and preferably has some examples that go beyond the very basic data modeling. And thanks for reading such a long post :)
type: Question
accepted answer: http://stackoverflow.com/a/2761961
score: 5
upvote count: 5
answer count: 2
downvote count: 0

http://stackoverflow.com/a/2716954
upvote count: 1
type: Answer
has body: As you just said, this seems to be a technique which is taught by the books. What I used to do, to at least have a bit of an overview about the different aspects is to separate the ui-views from ui-controllers. In your case this would mean, that you could write separated classes for Event Handling. Another helpful technique is to use private methods to separate different parts of your UI. In other words, the general Refactoring techniques might be helpful in this case as well.
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/2716897

http://stackoverflow.com/a/2636888
answers question: http://stackoverflow.com/q/2636845
type: Answer
has comment: http://stackoverflow.com/comment/2651213
downvote count: 1
score: -1
has body: public enum A { a1, a2; public enum B { b1, b2 } } and so on...
upvote count: 0

http://stackoverflow.com/q/2641254
favorite count: 0
linked to: http://stackoverflow.com/q/3244400
upvote count: 3
has answer: http://stackoverflow.com/a/2642198
tagged with: macos
has body: My Java.app broadcasts a packet on the network as soon as it starts up. Everytime I start this app, the Mac asks me do I want to allow network connections blah..blah.. Can I use info.plist or something to allow network access to this app and not bother the user who has trustingly downloaded and installed my app. Thanks
type: UnansweredQuestion
has title: Java App on Mac asking for allow network connections everytime
score: 3
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/10350015
type: Question
answer count: 2

http://stackoverflow.com/a/2682973
type: Answer
accepted answer of: http://stackoverflow.com/q/2682879
has body: This is similar to this question which has a more detailed answer. Basically transient information is lost under the hood. There isn't too much you can do about it.
score: 2
answers question: http://stackoverflow.com/q/2682879
type: AcceptedAnswer
downvote count: 0
upvote count: 2

http://stackoverflow.com/comment/132951729
has text: The code example you gave is the **gist**!
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/64888058
type: Comment

http://stackoverflow.com/q/2768697
tagged with: yaml
favorite count: 0
possible better answer: http://stackoverflow.com/a/8746617
answer count: 3
has answer: http://stackoverflow.com/a/8746617
score: 8
has answer: http://stackoverflow.com/a/2768801
has comment: http://stackoverflow.com/comment/57104275
tagged with: fixtures
downvote count: 1
tagged with: unit-testing
type: AnsweredQuestion
upvote count: 9
tagged with: java
has title: Any YAML based fixture loader for Java?
type: Question
accepted answer: http://stackoverflow.com/a/2768801
has body: I've used DbUnit but after playing about with the Play Framework recently I've found it's Fixtures.load(String yamlFilename) really useful. Anyone know of a similar tool that can be used with any Java project?
tagged with: playframework
has answer: http://stackoverflow.com/a/2908471

http://stackoverflow.com/a/2623578
type: Answer
answers question: http://stackoverflow.com/q/2622725
has comment: http://stackoverflow.com/comment/2638661
has comment: http://stackoverflow.com/comment/2636188
score: 0
has body: import java.util.Scanner; class Example{ //Checks to see if a string is consider an integer. public static boolean isInteger(String s){ if(s.isEmpty())return false; for (int i = 0; i &lt;s.length();++i){ char c = s.charAt(i); if(!Character.isDigit(c) &amp;&amp; c !='-') return false; } return true; } //Get integer. Prints out a prompt and checks if the input is an integer, if not it will keep asking. public static int getInteger(String prompt){ Scanner input = new Scanner(System.in); String in = ""; System.out.println(prompt); in = input.nextLine(); while(!isInteger(in)){ System.out.println(prompt); in = input.nextLine(); } input.close(); return Integer.parseInt(in); } public static void main(String[] args){ int [] a = new int[6]; for (int i = 0; i &lt; a.length;++i){ int tmp = getInteger("Enter integer for array_"+i+": ");//Force to read an int using the methods above. a[i] = tmp; } } }
has comment: http://stackoverflow.com/comment/2636407
upvote count: 2
downvote count: 2

http://stackoverflow.com/a/2755941
has body: You'll need to create a BeanInfo file for your components. Locate your component in the Projects window. Right click on it and choose BeanInfo Editor. Confirm that you want to create a BeanInfo. Click on the Designer tab. Choose the BeanInfo element at the top of the tree. In the property panel there are properties for color and mono icons at 16x6 and 32x32. Set these to paths to png or gif files. These are resolves as resources, so they need to be within your source tree. I generally add a "resource" package inside the package that holds my component and put the images there. Then, from Tools > Palette > Swing/AWT Components and add the components from the project. As you can see, this a bit involved, so I only use it for components I know I will reuse.
score: 4
type: AcceptedAnswer
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2755289
upvote count: 4
accepted answer of: http://stackoverflow.com/q/2755289
has comment: http://stackoverflow.com/comment/2830150

http://stackoverflow.com/a/2707354
upvote count: 6
answers question: http://stackoverflow.com/q/2707322
has body: Null is not an instance of any class. However, you can assign null to variables of any (object or array) type: // this is false boolean nope = (null instanceof String); // but you can still use it as a String String x = null; "abc".startsWith(null);
downvote count: 0
score: 6
type: Answer

http://stackoverflow.com/a/2653444
type: Answer
has body: yes, as long as there are no instance variables. method calls using only input parameters and local variables are inherently thread-safe. you might consider making the methods static too, to reflect this.
score: 0
answers question: http://stackoverflow.com/q/2653431

http://stackoverflow.com/comment/2767139
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2738629
has text: i used the above page. i have a doubt in the task parameter, what should i use so that it gets the length of the execution of the program
type: Comment

http://stackoverflow.com/a/74906350
type: Answer
has body: I read through some answers and people have missed one obvious solution to the above problem. If given we can change the structure of the class Node then we can add a boolean flag to know if it has been visited or not. This way we only traverse list once. Class Node{ Data data; Node next; boolean isVisited; } public boolean hasLoop(Node head){ if(head == null) return false; Node current = head; while(current != null){ if(current.isVisited) return true; current.isVisited = true; current = current.next; } return false; }
score: 0
answers question: http://stackoverflow.com/q/2663115

http://stackoverflow.com/comment/2685780
comment on: http://stackoverflow.com/q/2667727
has text: How does this work when you have a string that contains words with apostrophes?
score: 1
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2644168
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2644783
has body: Given function f1 which receives n String arguments, what would be considered better ,in terms of runtime performance, random key generation strategy for memcache? Our Memcache client does internal md5sum hashing on the keys it gets: public class MemcacheClient { public Object get(String key) { String md5 = Md5sum.md5(key) // Talk to memcached to get the Serialization... return memcached(md5); } } My usage scenarios are: First option public static String f1(String s1, String s2, String s3, String s4) { String key = s1 + s2 + s3 + s4; return get(key); } Second option /** * Calculate hash from Strings * * @param objects vararg list of String's * * @return calculated md5sum hash */ public static String stringHash(Object... strings) { if(strings == null) throw new NullPointerException("D'oh! Can't calculate hash for null"); MD5 md5sum = new MD5(); // if(prevHash != null) // md5sum.Update(prevHash); for(int i = 0; i &lt; strings.length; i++) { if(strings[i] != null) { md5sum.Update("_"); md5sum.Update(strings[i].toString()); // Convert to String... md5sum.Update("_"); } else { // If object is null, allow minimum entropy by hashing it's position md5sum.Update("_"); md5sum.Update(i); md5sum.Update("_"); } } return md5sum.asHex(); } public static String f1(String s1, String s2, String s3, String s4) { String key = stringHash(s1, s2, s3, s4); return get(key); } Note that the possible problem with the second option is that we are doing second md5sum (in the memcache client) on an already md5sum'ed digest result. Thanks for reading, Maxim. -- Edit Used MD5 utility source
score: 2
has title: Memcache key generation strategy
downvote count: 0
tagged with: java
tagged with: md5
has answer: http://stackoverflow.com/a/2644201
tagged with: memcached
type: Question
tagged with: algorithm
upvote count: 2
answer count: 2
favorite count: 0

http://stackoverflow.com/comment/2738818
type: Comment
has text: broke up the code and found it. it was the Resultset defined wrong. i had two initialized twice. thanks
comment on: http://stackoverflow.com/a/2713590
type: AnswerComment
score: 0

http://stackoverflow.com/comment/2820320
type: Comment
has text: J2ME does not include the JCE.
type: AnswerComment
comment on: http://stackoverflow.com/a/2780711
score: 0

http://stackoverflow.com/comment/39823421
score: 0
has text: But how do i get it to change the font for spinners and the action bar?
comment on: http://stackoverflow.com/a/16883281
type: AnswerComment
type: Comment

http://stackoverflow.com/a/2675947
has comment: http://stackoverflow.com/comment/2967516
type: Answer
upvote count: 17
downvote count: 0
answers question: http://stackoverflow.com/q/2674707
score: 17
has comment: http://stackoverflow.com/comment/121180511
has body: just to not forget the format method String s = String.format("%s%s%s%s%s", a, b, c, d, e); (%1.1s%1.1s%1.1s%1.1s%1.1s if you only want the first digit of each number...)

http://stackoverflow.com/comment/12391173
comment on: http://stackoverflow.com/a/2704455
has text: @xitrium: I think the intention for Go is that implementations should not be required to schedule co-operatively, they can pre-empt if they want. See for example https://code.google.com/p/go/issues/detail?id=543, which hasn't been closed as "nonsensical, fixing this so-called bug would contradict the Go language definition", which it should be if Go implementations are forbidden to pre-empt :-) The issue was compounded by the fact that by default Go used only a single host thread no matter how many goroutines were runnable.
type: AnswerComment
type: Comment
score: 1

http://stackoverflow.com/a/2770631
answers question: http://stackoverflow.com/q/2770321
has comment: http://stackoverflow.com/comment/2804149
score: 18
has comment: http://stackoverflow.com/comment/78059625
has body: What is a raw type and why do I often hear that they shouldn't be used in new code? A "raw type" is the use of a generic class without specifying a type argument(s) for its parameterized type(s), e.g. using List instead of List&lt;String&gt;. When generics were introduced into Java, several classes were updated to use generics. Using these class as a "raw type" (without specifying a type argument) allowed legacy code to still compile. "Raw types" are used for backwards compatibility. Their use in new code is not recommended because using the generic class with a type argument allows for stronger typing, which in turn may improve code understandability and lead to catching potential problems earlier. What is the alternative if we can't use raw types, and how is it better? The preferred alternative is to use generic classes as intended - with a suitable type argument (e.g. List&lt;String&gt;). This allows the programmer to specify types more specifically, conveys more meaning to future maintainers about the intended use of a variable or data structure, and it allows compiler to enforce better type-safety. These advantages together may improve code quality and help prevent the introduction of some coding errors. For example, for a method where the programmer wants to ensure a List variable called 'names' contains only Strings: List&lt;String&gt; names = new ArrayList&lt;String&gt;(); names.add("John"); // OK names.add(new Integer(1)); // compile error
has comment: http://stackoverflow.com/comment/2804097
upvote count: 18
type: Answer
has comment: http://stackoverflow.com/comment/2804016
downvote count: 0

http://stackoverflow.com/q/2706760
tagged with: spring-mvc
score: 2
has answer: http://stackoverflow.com/a/2706774
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2706911
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/2706911
has title: PHP Programmer wanting to learn Spring
possible better answer: http://stackoverflow.com/a/2706849
has answer: http://stackoverflow.com/a/2706849
has comment: http://stackoverflow.com/comment/2730516
downvote count: 0
has comment: http://stackoverflow.com/comment/134694817
favorite count: 0
upvote count: 2
has body: I'm a PHP programmer and I want to try creating a webapp using the Spring framework. The problem is I'm clueless and I don't know where to start. What tutorials/books/websites do you guys suggest that I should learn from? What's IoC? Do I use it alongside MVC? What components of the Spring framework should I use? How do I know what to use? Are there webapps created with Spring that I could study from? Thank you so much in advance! P.S. I've used Struts (1) about a year ago.
has answer: http://stackoverflow.com/a/2710276
tagged with: spring
answer count: 4

http://stackoverflow.com/a/2600691
type: Answer
score: 0
has body: O(n): Count the number of words Split your text word wise into list of words Create a map of word=>number_of_occurences Traverse the map and select max. 50. Divide them by total number of words to get frequency Of course some of this steps may be done at the same time or unnecessary depending on data structures you'll use.
answers question: http://stackoverflow.com/q/2600608

http://stackoverflow.com/a/2742205
type: Answer
score: 2
downvote count: 0
upvote count: 2
answers question: http://stackoverflow.com/q/2742198
has body: no. your best bet is to find a 3rdparty jar that does language parsing, and see if they have methods such as that.

http://stackoverflow.com/a/2609270
type: Answer
upvote count: 14
score: 14
has body: You are confusing dynamic invocation with dynamic binding.. The first one allows the type checker to accept programs in which you are not sure if a method will be present on an object at run-time, while dynamic binding just chooses the right implementation according to the runtime type of the object but maintaining the statically type checking. What does it mean? It means that in your example, Java will call the implementation on object B because the runtime type of the objA variable is B; and it will compile because it knows that a B is a A so the method invocation won't fail at runtime (objA will have a F implementation for sure). With dynamic invocation instead it won't check at compile time that the type of the object on which you are calling F contains that method, of course it will raise an exception if during execution the method won't be available on specified object. Just for trivia: the invokedynamic feature will be added with Java7 because many scripting languages have been written to work on top of JVM and the lack of a dynamic invocation feature forced the developers of these languages to add a middle layer between the script and the real JVM that cares about dynamic invocation using the reflection. Of course this approach causes a lot of overhead (think about Grovvy's MetaClass), that's why Sun decided to give them a help..
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2609227
answers question: http://stackoverflow.com/q/2609227

http://stackoverflow.com/q/2648877
tagged with: c++
score: 6
possible better answer: http://stackoverflow.com/a/20083960
type: AnsweredQuestion
has body: I need help passing binary data into Java. I'm trying to use jbytearray but when the data gets into Java it appears corrupt. Can somebody give me a hand? Here's a snip of some example code. First the native C++ side: printf("Building audio array copy\n"); jbyteArray rawAudioCopy = env-&gt;NewByteArray(10); jbyte toCopy[10]; printf("Filling audio array copy\n"); char theBytes[10] = {0,1,2,3,4,5,6,7,8,9}; for (int i = 0; i &lt; sizeof(theBytes); i++) { toCopy[i] = theBytes[i]; } env-&gt;SetByteArrayRegion(rawAudioCopy,0,10,toCopy); printf("Finding object callback\n"); jmethodID aMethodId = env-&gt;GetMethodID(env-&gt;GetObjectClass(obj),"handleAudio","([B)V"); if(0==aMethodId) throw MyRuntimeException("Method not found error",99); printf("Invoking the callback\n"); env-&gt;CallVoidMethod(obj,aMethodId, &amp;rawAudioCopy); and then the Java callback method: public void handleAudio(byte[] audio){ System.out.println("Audio supplied to Java [" + audio.length + "] bytes"); byte[] expectedAudio = {0,1,2,3,4,5,6,7,8,9}; for (int i = 0; i &lt; audio.length; i++) { if(audio[i]!= expectedAudio[i]) System.err.println("Expected byte " + expectedAudio[i] + " at byte " + i + " but got byte " + audio[i]); else System.out.print('.'); } System.out.println("Audio passed back accordingly!"); } I get the following output when the callback is invoked: library loaded! Audio supplied to Java [-2019659176] bytes Audio passed back accordingly!
tagged with: java-native-interface
tagged with: java
has title: JNI Stream binary data from C++ to Java
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/2665089
downvote count: 0
has answer: http://stackoverflow.com/a/20083960
favorite count: 0
has answer: http://stackoverflow.com/a/2653123
accepted answer: http://stackoverflow.com/a/2653123
upvote count: 6

http://stackoverflow.com/q/2751387
tagged with: java
downvote count: 3
type: Question
has title: Can anybody give me a complete list of data structure supported in Java(not in util package)?
tagged with: data-structures
score: -3
upvote count: 0
has answer: http://stackoverflow.com/a/2751411
favorite count: 0
has comment: http://stackoverflow.com/comment/2781837
has body: I want to know what kinds of data structure in Java and not in the util package? For example: Hashmap, Collection, Set. Please give me a list of them as many as possible. Thank you OK, let me change a way to ask something: Except in util package, is there any data structures already implemented in JAVA, and if need to use them, we could import them into our class, without constructing by ourselves.
has answer: http://stackoverflow.com/a/2751558
has answer: http://stackoverflow.com/a/2751429
type: UnansweredQuestion
answer count: 4
has answer: http://stackoverflow.com/a/2751435

http://stackoverflow.com/q/2651646
has answer: http://stackoverflow.com/a/2655708
type: Question
tagged with: hibernate-search
answer count: 2
downvote count: 0
tagged with: lucene
has body: I'm using Hibernate Search (which uses Lucene) for searching some Data I have indexed in a directory. It works fine but I need to do a reverse search. By reverse search I mean that I have a list of queries stored in my database I need to check which one of these queries match with a Data object each time Data Object is created. I need it to alert the user when a Data Object matches with a Query he has created. So I need to index this single Data Object which has just been created and see which queries of my list has this object as a result. I've seen Lucene MemoryIndex Class to create an index in memory so I can do something like this example for every query in a list (though iterating in a Java list of queries would not be very efficient): //Iterating over my list&lt;Query&gt; MemoryIndex index = new MemoryIndex(); //Add all fields index.addField("myField", "myFieldData", analyzer); ... QueryParser parser = new QueryParser("myField", analyzer); float score = index.search(query); if (score &gt; 0.0f) { System.out.println("it's a match"); } else { System.out.println("no match found"); } The problem here is that this Data Class has several Hibernate Search Annotations @Field,@IndexedEmbedded,... which indicated how fields should be indexed, so when I invoke index() method on the FullTextEntityManager instance it uses this information to index the object in the directory. Is there a similar way to index it in memory using this information? Is there a more efficient way of doing this reverse search?
favorite count: 0
has answer: http://stackoverflow.com/a/4172198
has title: Reverse search in Hibernate Search
upvote count: 3
accepted answer: http://stackoverflow.com/a/4172198
type: AnsweredQuestion
score: 3
possible better answer: http://stackoverflow.com/a/2655708
tagged with: java
tagged with: hibernate

http://stackoverflow.com/q/2771248
has body: I'm building a Java IDE and am trying to implement autocompletion or intellisense. After looking around for something that will do most of the work for me (not reinventing the wheel etc) I've pulled the code for Eclipse JDT core and am trying to figure out how to implement it in my own IDE. I'm obviously working under the assumption that this is possible. If anyone knows a lot about Eclipse JDT Core, implementing intellisense, or other fun things that would help me accomplish my goal and would like to weigh in, I would appreciate it! Thanks!
tagged with: intellisense
type: Question
has comment: http://stackoverflow.com/comment/2804798
answer count: 1
downvote count: 0
favorite count: 0
has title: Integrating Eclipse JDT Core into a new editor
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2771272
score: 1
tagged with: java
tagged with: eclipse-jdt
upvote count: 1
tagged with: eclipse

http://stackoverflow.com/a/2709145
has body: You don't need to. You can call methods on the outer class normally within the inner class. When you compile it, the compiler will automatically generate a hidden field that contains a reference to the outer class. To reference this variable yourself, you can write A.this. (A.this is the compiler-generated field and is equivalent to your a field)
answers question: http://stackoverflow.com/q/2709131
type: Answer
accepted answer of: http://stackoverflow.com/q/2709131
upvote count: 10
type: AcceptedAnswer
downvote count: 0
score: 10

http://stackoverflow.com/comment/2762030
score: 0
has text: Exactly the same question was asked a week or two ago. Regularly, actually. I just can't find it :) The answer at least boils down to "no, live with it". There are ways to make it shorter/different, but not faster.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/2734119

http://stackoverflow.com/a/2781218
score: 1
downvote count: 0
has body: The database isn't automagically efficient either; you actually need to configure a database (by putting indices on relevant columns) for it to be able to do searches efficiently. In a similar way you can optimize your code for speed. If you need to do a lot of lookups based on a few criteria you could make dedicated collections for that. Similar to an index on a database. You'd do that by not only inserting your User into a Users list, but by putting that same user in for instance a Map keyed on Role: public void addUser(User user) { users.add(user); // your index if (!usersByRole.containsKey(user.getRole()) { usersByRole.put(user.getRole(), new ArrayList&lt;User&gt;()); } usersByRole.get(user.getRole()).add(user); } public List&lt;User&gt; findByRole(String role) { if (!usersByRole.containsKey(role)) { return Collectsions.emptyList(); } return Collections.unmodifieableList(usersByRole.get(role)); }
upvote count: 1
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2781100
answers question: http://stackoverflow.com/q/2781100
type: Answer

http://stackoverflow.com/comment/65214634
comment on: http://stackoverflow.com/a/38911375
type: Comment
has text: @ZZCoder Point of views such as yours yield questions OP asked. There is no contract that *any `FileOutputStream` implementation should not override `flush` and should not buffer.*
score: 0
type: AnswerComment

http://stackoverflow.com/comment/2639710
comment on: http://stackoverflow.com/q/2626640
has text: Basically, if I have a String, "bridge", it turns it into "bergid". I take the first character of the String and concatenate it with the last character. Then I take the second character and concatenate it with the second to last character and so on. The results of these individual concatenations are concatenated together.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/2639614
downvote count: 0
score: 4
has body: Is the value in the Coldfusion ThisKey: &lt;cfset ThisKey = "a-24byte-key-string-here"&gt; The exact same string that is returned from the java generateKey() function? I believe they need to be to be the same string for the generated encrypted text to be the same. To use a fixed key like that in CF, you may need to follow this from the CF technote on strong encryption: You may want to generate your own key for two reasons: You want to match the details of other encryption software. You want to increase the resistance to cracking of your encrypted data by pattern-oriented cryptanalysis techniques. For example, to create a 32-byte key to use with the AES algorithm with the hex value: 8738fed68e7677d374e0946c8f7bd3bb4f50f23717f9f3667b2419483959039c you would use the ColdFusion functions BinaryDecode and ToBase64 to create the key: &lt;cfset myKey = ToBase64(BinaryDecode("8738fed68e7677d374e0946c8f7bd3bb4f50f23717f9f3667b2419483959039c","Hex")&gt; &lt;cfset encrypted =Encrypt(myString, myKey, "AES")&gt; EDIT: Just realized that the key (as you mentioned in your comment) is base64, so if the "generateKey" method in Java looks like: private static Key generateKey() throws Exception { final byte[] decodedKey = new BASE64Decoder().decodeBuffer(KEY_VALUE); final Key key = new SecretKeySpec(decodedKey, _AES); return key; } You should be golden.
has comment: http://stackoverflow.com/comment/2654471
type: Answer
upvote count: 4
accepted answer of: http://stackoverflow.com/q/2638967
answers question: http://stackoverflow.com/q/2638967
type: AcceptedAnswer

http://stackoverflow.com/a/2777860
has body: The size of an array in Java can't be changed once the array is created. The following links should help you with transferring the existing items to a new array :-) See: System.arraycopy and Array.copyOf(*).
score: 3
has comment: http://stackoverflow.com/comment/2812559
downvote count: 0
has comment: http://stackoverflow.com/comment/2818346
type: Answer
upvote count: 3
answers question: http://stackoverflow.com/q/2777762

http://stackoverflow.com/a/2687871
type: Answer
has body: Your game model can have more than one view: a GUI view, a console view, a status view, etc. Typically each view arranges to listen for changes in the model, and it then queries the model for the information it needs to render it's particular view. This simple game was designed specifically to illustrate the concepts. The section named "Design" elaborates in more detail. Addendum: This outline corresponds roughly to this architecture, symbolized below. public class MVCOutline { public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { //@Override public void run() { new MVCOutline().create(); } }); } private void create() { JFrame f = new JFrame("MVC Outline"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new MainPanel()); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); } } class MainPanel extends JPanel { public MainPanel() { super(new BorderLayout()); Model model = new Model(); View view = new View(model); Control control = new Control(model, view); this.add(view, BorderLayout.CENTER); this.add(control, BorderLayout.WEST); } } class Control extends JPanel implements ... { private Model model; private View view; public Control(Model model, View view) { this.model = model; this.view = view; } } class View extends JPanel implements Observer { private Model model; public View(Model model) { this.model = model; model.addObserver(this); } public void update(Observable o, Object arg) { // update GUI based on model } } class Model extends Observable { public void next() { this.notifyObservers(...); } }
has comment: http://stackoverflow.com/comment/8107540
answers question: http://stackoverflow.com/q/2687345
score: 17
has comment: http://stackoverflow.com/comment/2715077
has comment: http://stackoverflow.com/comment/74747507
has comment: http://stackoverflow.com/comment/2710906
has comment: http://stackoverflow.com/comment/74751936
downvote count: 1
upvote count: 18
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/95253527
accepted answer of: http://stackoverflow.com/q/2687345
has comment: http://stackoverflow.com/comment/95253986

http://stackoverflow.com/q/2784477
upvote count: 2
tagged with: jetty
tagged with: maven
answer count: 1
has title: Incremental build with NetBeans and Maven for jetty hot deployment
has comment: http://stackoverflow.com/comment/11941449
linked to: http://stackoverflow.com/q/2756891
tagged with: java
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/2822155
score: 2
has answer: http://stackoverflow.com/a/12187096
has body: After my unsuccessful attempt to run Tomcat with hot deployment from NetBeans with Maven, I've tried jetty. The jetty-maven-plugin doc gave me an important hint: The plugin will automatically ensure the classes are rebuilt and up-to-date before deployment. If you change the source of a class and your IDE automatically compiles it in the background, the plug-in will pick up the changed class. If I look at $myproject/target/classes/... in the projects directory, I can see that NetBeans doesn't compile and refresh the class file on saving. I need to build the project explicitly to update the file and than jetty picks up the change. (The plug-in param "scanIntervalSeconds" is set to 1.) How can I tell NetBeans to compile on save and update the class file so that jetty can pick up the change? Provisional solution: "Project Properties > Build > Compile > Compile On Save: For both application and test execution". NetBeans warns me that the result is not the same as with a usal compiler run but it works so far.
downvote count: 0
favorite count: 0
type: Question
tagged with: maven-jetty-plugin
has comment: http://stackoverflow.com/comment/2819803
tagged with: netbeans

http://stackoverflow.com/comment/2758839
comment on: http://stackoverflow.com/q/2731295
has text: From your edit, I'm not sure what you want anymore? This code belongs inside the loop surely?
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2628379
has answer: http://stackoverflow.com/a/2628562
has comment: http://stackoverflow.com/comment/2641428
tagged with: anagram
downvote count: 0
has title: Finding anagaram(s) of dictionary words
favorite count: 0
possible better answer: http://stackoverflow.com/a/2628425
has answer: http://stackoverflow.com/a/2628425
answer count: 5
has answer: http://stackoverflow.com/a/2628426
has body: How can I take an input word (or sequence of letters) and output a word from a dictionary that contains exactly those letters? Does java has an English dictionary class (list of words) that I can use, or are there open source implementations of this? How can I optimize my code if this needs to be done repeatedly?
upvote count: 7
has answer: http://stackoverflow.com/a/2628517
type: Question
has answer: http://stackoverflow.com/a/2628487
type: AnsweredQuestion
tagged with: algorithm
accepted answer: http://stackoverflow.com/a/2628426
score: 7
tagged with: java

http://stackoverflow.com/a/2757241
score: 1
upvote count: 1
has body: I got the answer myself: In the Edit Variables frame it is possible to specify the "Text / reqular expression for java expression type".
type: AcceptedAnswer
type: Answer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2756830
answers question: http://stackoverflow.com/q/2756830

http://stackoverflow.com/comment/2652692
type: AnswerComment
type: Comment
has text: Rather than kill the previous instance, it may be better to kill the new instance, after notifying the original instance that it should "maximize". It could be as simple as writing to the socket the first instance has open.
comment on: http://stackoverflow.com/a/2638106
score: 0

http://stackoverflow.com/comment/28733952
type: Comment
has text: I think LinkedList wont suits here since it has to iterate to reach an element with particular index. But add/remove is faster.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2663098

http://stackoverflow.com/comment/2686578
type: QuestionComment
type: Comment
has text: The format will only be in the way it is specified above. No spaces, dashes, etc. When the code gets to the area I am testing it has been scrubbed.
comment on: http://stackoverflow.com/q/2668307
score: 0

http://stackoverflow.com/a/2697165
has comment: http://stackoverflow.com/comment/4559512
type: Answer
accepted answer of: http://stackoverflow.com/q/2691160
upvote count: 25
has comment: http://stackoverflow.com/comment/122566169
answers question: http://stackoverflow.com/q/2691160
has comment: http://stackoverflow.com/comment/4548544
has body: Auto-answer T_T Two days of hitting my head against the code for this... Looks like it is not a problem of the code. I was using Weblogic with it and Weblogic captures the requests with the "authorization" header, so it doesn't get to my authentication-manager. I tried it with glassfish, and it works perfectly. Searching for some info, I found an useful entry in the next blog: http://yplakosh.blogspot.com/2009/05/how-to-fix-basic-authentication-issue.html Adding the next line in the config.xml from my Weblogic server(&lt;security-configuration&gt; section): &lt;enforce-valid-basic-auth-credentials&gt;false&lt;/enforce-valid-basic-auth-credentials&gt; Weblogic will not catch the basic authentication credentials again, so it will be your authentication-manager who will handle it. I hope it can save some time to anyone :-)
score: 25
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/2623442
type: Answer
score: 1
has body: I don't know about sqlite, but Preferences is a a good way to store information about your JFrame.
upvote count: 1
answers question: http://stackoverflow.com/q/2622995
downvote count: 0

http://stackoverflow.com/comment/2807628
score: 1
has text: To answer your second question - no. A map is if you want (key -> value) as defined by @Bruno Rothgiesser's excellent answer. A set is for non-duplicate elements. If you want duplicates and not key->value, I'd check out a java.util.List implementation. Check out the Collection tutorial for a definitive guide: http://java.sun.com/docs/books/tutorial/collections/index.html
type: AnswerComment
comment on: http://stackoverflow.com/a/2773861
type: Comment

http://stackoverflow.com/a/2692847
answers question: http://stackoverflow.com/q/2692772
score: 2
downvote count: 0
upvote count: 2
has comment: http://stackoverflow.com/comment/2715564
has body: I don't do Grails, but since it runs on top of the Servlet API, you may find this answer (a steering in the right direction) useful as well. First, get a handle of the ServletContext. Normally you would use the GenericServlet-inherited getServletContext() method for this. Then make use of the ServletContext#getRealPath() method to convert a relative web path to an absolute local disk file system path (because that's the only which java.io.File reliably understands). String absolutePath = getServletContext().getRealPath("albums/1"); File file = new File (absolutePath); // ... If you use relative paths in java.io.File stuff, then it will become relative to the current working directory which depends on the way how you startup the server and which indeed may be Tomcat/bin as you experienced yourself. That said, there's another major problem with this approach: if you create folders in an exploded webapp, they will get lost whenever you redeploy the webapp or even restart the server! Rather create folders outside the webapp's context, in a fixed path somewhere else at the disk file system. Or if you want better portability (but poorer metadata information), then consider storing it in a database instead.
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2692772
type: Answer

http://stackoverflow.com/comment/2735273
has text: Doesn't the `-Xloggc:file` option send everything to a file? http://java.sun.com/javase/6/docs/technotes/tools/windows/java.html
type: Comment
comment on: http://stackoverflow.com/q/2710498
score: 1
type: QuestionComment

file-diffs
tags question: http://stackoverflow.com/q/2784797
type: Tag
tag name: file-diffs

http://stackoverflow.com/comment/2768341
comment on: http://stackoverflow.com/a/2734259
has text: I was afraid of that, I guess objects of class A would be useless now. Thankyou :)
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/2768960
has body: Wouldn't that just be String string = "aaple"; string.subString(string.length() - 1, string.length()); ?
score: 0
has comment: http://stackoverflow.com/comment/2802012
type: Answer
answers question: http://stackoverflow.com/q/2768931

http://stackoverflow.com/comment/2647005
has text: Right. I was using JDK 1.5 on RHEL. However, my best bet is that JOPtionPane has an internal FocusManager that is causing Tom's setting to be overridden. JOptionPane May not be a good way to initiate a dialog with this behavior.
score: 0
comment on: http://stackoverflow.com/q/2632785
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/2790567
has text: @yogsma: aren't you undervaluing SQL? Joins? Functions? Procedures? The average DB is undoubtely much more efficient in this job. In Java you would need to get hold of all the data in memory and then preferably need 2~5 times more free space in the memory than the data actually large is, else you will face constantly `OutOfMemoryErrors`. I would still consult some SQL Ninja (or ask here) if it is really, *really* not possible in pure SQL. Just to be sure.
type: Comment
score: 3
comment on: http://stackoverflow.com/a/2758656
type: AnswerComment

http://stackoverflow.com/a/2726106
has body: You shouldn't do any Swing stuff outside of the event dispatch thread. To access this, you need to create a Runnable with your code in run, and then pass that off to SwingUtilities.invokeNow() or SwingUtilities.invokeLater(). The problem is that we need a delay in your JProgressBar checking to avoid jamming up the Swing thread. To do this, we'll need a Timer which will call invokeNow or later in its own Runnable. Have a look at http://www.javapractices.com/topic/TopicAction.do?Id=160 for more details.
score: 0
type: Answer
answers question: http://stackoverflow.com/q/2726091

http://stackoverflow.com/a/2635676
accepted answer of: http://stackoverflow.com/q/2635355
type: Answer
answers question: http://stackoverflow.com/q/2635355
has body: I believe the sort icon comes from the look and feel. For example, in the Windows look and feel, the WindowsTableHeaderUI looks up the following to draw the appropriate icon. For ascending: UIManager.getIcon("Table.ascendingSortIcon"); For descending: UIManager.getIcon("Table.descendingSortIcon"); While the BasicLookAndFeel registers a value for these properties (so there is likely to be something there if you use a similar call), as @Michael Borgwardt notes (by drawing a conclusion from his answer), there is no guarantee of this since any given look and feel might choose to forego the UIManager and draw their own graphics. Still, it might be worthwhile trying it to see if it does what you want.
score: 12
upvote count: 12
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2657082

http://stackoverflow.com/a/18197329
answers question: http://stackoverflow.com/q/2605747
upvote count: 1
has body: I used the Assembly Plugin like khmarbaise suggested, but to get it to work I needed to use an Ant-style exclude to make sure that no files or directories crept into the archive: &lt;excludes&gt; &lt;exclude&gt;**/*&lt;/exclude&gt; &lt;/excludes&gt;
type: Answer
downvote count: 0
score: 1

http://stackoverflow.com/q/2693373
tagged with: java-ee-6
downvote count: 0
has title: Am I using EJBs properly?
linked to: http://stackoverflow.com/q/1847040
favorite count: 0
tagged with: ejb-3.0
upvote count: 2
has body: I am using a JEE6 stack including JPA 2.0, JSF 2.0, EJB 3.1 etc. The way my architecture is setup is the following: I have JPA annotated DAOs using hibernate as my JPA provider. I have JSF Managed beans which correspond to my facelet/xhtml pages. I have EJBs that handle all of my database requests. My XHTML pages have JSF EL which make calls to my Managed beans. My managed beans contain references to my DAO entities which are managed by EJBs. For example, I have a user entity which is mapped to a db table. I have a user EJB which handles all CRUD operations that return Users. I have a page that edits a user. The highlevel workflow would be: navigate to user edit page -> EL calls a method located in the managed bean that loads a user. The method calls userEJB.loadUser(user) from the EJB to get the user from the database. The user is edited and submit -> a function is called in the managed bean which calls a function in the EJB to save the user. etc. I am running into issues accessing my data within my JSF pages using EJBs. I am having a lot of problems with lazy initialization errors, which I believe is due to how I have set things up. For example, I have a Client entity that has a List of users which are lazily loaded. In order to get a client I call a method in my EJB which goes to the database, finds a client and returns it. Later on i wish to access this clients list of users, in order to do so i have to go back to the EJB by calling some sort of method in order to load those users (since they are lazily loaded). This means that I have to create a method such as public List&lt;User&gt; getUserListByClient(Client c) { c = em.merge(c); return c.getUserList(); } The only purpose of this method is to load the users (and I'm not even positive this approach is good or works). If i was doing session management myself, I would like just leave the session open for the entire request and access the property directly, this would be fine as the session would be open anyway, …
has answer: http://stackoverflow.com/a/2704838
score: 2
type: AnsweredQuestion
tagged with: jsf
tagged with: java
type: Question
answer count: 2
accepted answer: http://stackoverflow.com/a/2704838
possible better answer: http://stackoverflow.com/a/2693520
has answer: http://stackoverflow.com/a/2693520

http://stackoverflow.com/a/2604283
answers question: http://stackoverflow.com/q/2604005
upvote count: 2
type: Answer
score: 2
downvote count: 0
has body: Simple event listeners (as used in Java AWT) require that events are handled immediately, within the same virtual machine, and typically within the same thread. JMS (for instance using ActiveMQ) allows events to be handled at a later time (optionally buffering messages in persistent storage), and in other virtual machines / threads. That flexibility comes at the price of additional complexity and lower efficiency.
accepted answer of: http://stackoverflow.com/q/2604005
type: AcceptedAnswer

http://stackoverflow.com/q/2755142
type: AnsweredQuestion
tagged with: oop
tagged with: java
type: Question
score: 9
tagged with: c#
upvote count: 9
has answer: http://stackoverflow.com/a/2755147
has answer: http://stackoverflow.com/a/2755148
has answer: http://stackoverflow.com/a/2755182
answer count: 6
has answer: http://stackoverflow.com/a/2755181
has answer: http://stackoverflow.com/a/2755152
has answer: http://stackoverflow.com/a/2755246
possible better answer: http://stackoverflow.com/a/2755148
tagged with: singleton
downvote count: 0
favorite count: 0
has title: Singletons and constants
accepted answer: http://stackoverflow.com/a/2755181
has body: I am making a program which makes use of a couple of constants. At first, each time I needed to use a constant, I'd define it as //C# private static readonly int MyConstant = xxx; //Java private static final int MyConstant = xxx; in the class where I'd need it. After some time, I started to realise that some constants would be needed in more than one class. At this time, I had 3 choises: To define them in the different classes that needed it. This leads to repetition. If by some reason later I need to change one of them, I'd have to check in all classes to replace them everywhere. To define a static class/singleton with all the constants as public. If I needed a constant X in ClassA, ClassB and ClassC, I could just define it in ClassA as public, and then have ClassB and ClassC refer to them. This solution doesn't seem that good to me as it introduces even more dependencies as the classes already have between them. I ended up implementing my code with the second option. Is that the best alternative? I feel I am probably missing some other better alternative. What worries me about using the singleton here is that it is nowhere clear to a user of the class that this class is using the singleton. Maybe I could create a ConstantsClass that held all the constants needed and then I'd pass it in the constructor to the classes that'd need it? Thanks edit: I'm using this mostly for complex types, not ints and strings. At least in the C# case that makes a difference as it means I can't use the const keyword.

http://stackoverflow.com/comment/39836434
score: 0
type: Comment
has text: I tried that but its still the same. im putting the `FontsOverride.setDefaultFont` in the mainactivity.java file. is it suppose to be somewhere else for the actionbar?
comment on: http://stackoverflow.com/a/16883281
type: AnswerComment

http://stackoverflow.com/a/14354870
has body: I have not tried to persist this but you can try following http://marekhalmo.blogspot.sk/2012/09/cool-java-enums.html I would stick to enums.
answers question: http://stackoverflow.com/q/2750208
score: 0
type: Answer

http://stackoverflow.com/a/43907171
has body: The Hashset internally uses HashMap. If you see the internal implementation the values inserted in HashSet are stored as keys in the HashMap and the value is a Dummy object of Object class. Difference between HashMap vs HashSet is:- HashMap contains key value pairs and each value can be accessed by key where as HashSet needs to be iterated everytime as there is no get method. HashMap implements Map interface and allows one null value as a key and multiple null values as values, whereas HashSet implements Set interface, allows only one null value and no duplicated values.(Remeber one null key is allowed in HashMap key hence one null value in HashSet as HashSet implemements HashMap internally). HashSet and HashMap do not maintain the order of insertion while iterating.
downvote count: 2
score: 9
answers question: http://stackoverflow.com/q/2773824
type: Answer
upvote count: 11

autofac
tag name: autofac
type: Tag
tags question: http://stackoverflow.com/q/2775958

http://stackoverflow.com/q/2626208
tagged with: file-upload
favorite count: 0
tagged with: ruby
accepted answer: http://stackoverflow.com/a/2626240
type: Question
upvote count: 2
tagged with: translation
tagged with: php
answer count: 1
tagged with: java
has title: How to access uploaded files in Ruby
has answer: http://stackoverflow.com/a/2626240
has body: I am trying use a Java Uploader in a ROR app (for its ease of uploading entire directories). The selected uploader comes with some PHP code that saves the files to the server. I am trying to translate this code to Ruby, but am stumped on this point: PHP has a very convenient superglobal – $_FILES – that contains a hash of all files uploaded to the current script via the HTTP POST method. It appears Ruby does not have a similar resource. Lacking that, what is the best way to access and save the uploaded files? I am using the JavaPowUpload uploader ( http://www.element-it.com/OnlineHelpJavaPowUpload/index.html ).
score: 2
type: AnsweredQuestion
downvote count: 0

corba
tags question: http://stackoverflow.com/q/2703607
tags question: http://stackoverflow.com/q/2657736
tags question: http://stackoverflow.com/q/2726006
tags question: http://stackoverflow.com/q/2633790
type: Tag
tags question: http://stackoverflow.com/q/2720731
tag name: corba
tags question: http://stackoverflow.com/q/2620079

http://stackoverflow.com/a/2742517
upvote count: 7
has body: ... and if declaring a base class abstract is not an option you can always throw an UnsupportedOperationException class BaseClass { void mustOverride() { throw new UnsupportedOperationException("Must implement"); } } But this is not a compile-time check of course...
downvote count: 0
answers question: http://stackoverflow.com/q/2742463
score: 7
type: Answer

http://stackoverflow.com/a/2721001
has comment: http://stackoverflow.com/comment/2747612
has comment: http://stackoverflow.com/comment/2747091
has body: Is there a DeserializerBeanFactory or something similar? Never heard of one, and frankly I wouldn't want my initialization to be controlled by opaque (to mere humans) serialized objects. But if you really think this is a good idea (ahem), it should not be difficult to create a custom BeanFactory that worked that way.
answers question: http://stackoverflow.com/q/2720929
score: 0
type: Answer

http://stackoverflow.com/q/2627889
downvote count: 0
linked to: http://stackoverflow.com/q/410236
favorite count: 0
has body: I am using this code to check that array is present in the HashMap: public class Test { public static void main(String[] arg) { HashMap&lt;int[], String&gt; map = new HashMap&lt;int[], String&gt;(); map.put(new int[]{1, 2}, "sun"); System.out.println(map.containsKey((new int[]{1, 2}))); } } But this prints False. How can I check that array is present in the HashMap?
has answer: http://stackoverflow.com/a/2627907
has answer: http://stackoverflow.com/a/2627979
possible better answer: http://stackoverflow.com/a/2627906
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2627970
tagged with: java
score: 24
upvote count: 24
linked to: http://stackoverflow.com/q/1894377
type: Question
has answer: http://stackoverflow.com/a/2627908
answer count: 8
tagged with: hashmap
has answer: http://stackoverflow.com/a/2627970
linked to: http://stackoverflow.com/q/27581
linked to: http://stackoverflow.com/q/8777257
has answer: http://stackoverflow.com/a/2627899
has answer: http://stackoverflow.com/a/69083516
tagged with: arrays
has answer: http://stackoverflow.com/a/2627913
has title: Java HashMap with Int Array
has answer: http://stackoverflow.com/a/2627906

http://stackoverflow.com/q/2620687
tagged with: client-server
upvote count: 7
has body: I need to separate our application into a light-weight gui application and a business logic application. This won't be a client/server setup as such, as the 'server' component will only have one client. The other limitation in the application is that it has only one entry/exit point. Therefore if we were to use RMI, it would only ever be on one function. All form data is already wrapped up into a string and passed through one transport area. Should I just use Java Sockets to enhance this application, or go with RMI? Or some other Java technology? I made a previous post outlining the requirements of our application, however it went unanswered. https://stackoverflow.com/questions/2604528/terminal-panel-pc-single-server-solution-client-server-or-rdp Cheers.
has comment: http://stackoverflow.com/comment/2632999
favorite count: 0
has title: Java: Sockets or RMI?
has comment: http://stackoverflow.com/comment/2640326
has comment: http://stackoverflow.com/comment/2632982
answer count: 4
accepted answer: http://stackoverflow.com/a/2620726
has answer: http://stackoverflow.com/a/2621101
downvote count: 0
has answer: http://stackoverflow.com/a/2620724
tagged with: sockets
has answer: http://stackoverflow.com/a/2620726
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2620724
has answer: http://stackoverflow.com/a/2621028
tagged with: rmi
tagged with: java
score: 7
has comment: http://stackoverflow.com/comment/2633350
has comment: http://stackoverflow.com/comment/2633038
type: Question
has comment: http://stackoverflow.com/comment/2632996
has comment: http://stackoverflow.com/comment/2633025

http://stackoverflow.com/comment/2789256
type: AnswerComment
comment on: http://stackoverflow.com/a/2757759
score: 0
type: Comment
has text: @John: Personally, I prefer Ivy and Ant, but the principals should be the same. Dependent on which environment I'm building for, I copy different properties file and rename it to for example application.properties. Then my Spring application context that imports the PropertyPlaceholderConfigurer only knows about application.properties. If this is copied from test.properties or production.properties is unkown for the Spring container. It's only my test contexts that knows about the test properties for my JUnit tests.

http://stackoverflow.com/q/2745777
downvote count: 0
possible better answer: http://stackoverflow.com/a/2745856
has answer: http://stackoverflow.com/a/2745830
favorite count: 0
answer count: 4
tagged with: c++
tagged with: geometry
has body: I have a small contest problem in which is given a set of points, in 2D, that form a triangle. This triangle may be subject to an arbitrary rotation, may be subject to an arbitrary translation (both in the 2D plane) and may be subject to a reflection on a mirror, but its dimensions were kept unchanged. Then, they give me a set of points in the plane, and I have to find 3 points that form my triangle after one or more of those geometric operations. Example: 5 15 8 5 20 10 6 5 17 5 20 20 5 10 5 15 20 15 10 Output: 5 17 10 5 15 20 I bet it's supposed to apply some known algorithm, but I don't know which. The most common are: convex hull, sweep plane, triangulation, etc. Can someone give a tip? I don't need the code, only a push, please!
has answer: http://stackoverflow.com/a/2747253
tagged with: computational-geometry
upvote count: 1
type: AnsweredQuestion
tagged with: algorithm
has comment: http://stackoverflow.com/comment/2775120
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/2745856
type: Question
accepted answer: http://stackoverflow.com/a/2747253
has title: Computational geometry: find where the triangle is after rotation, translation or reflection on a mirror
has answer: http://stackoverflow.com/a/2745918

http://stackoverflow.com/a/24111032
upvote count: 3
has comment: http://stackoverflow.com/comment/54740020
score: 3
downvote count: 0
has comment: http://stackoverflow.com/comment/54726353
type: Answer
answers question: http://stackoverflow.com/q/2760289
has body: Take a look at stagemonitor. It is an open source java web application performance monitoring library capable of multi-tenancy. It captures response time metrics, JVM metrics, request details and more. The overhead is very low. It uses the great timeseries database graphite that automatically downsamples historical datapoints which leads to a low storage overhead. Here is a screenshot. You can find more on the project site. Note: I am the developer of stagemonitor

http://stackoverflow.com/a/2624465
answers question: http://stackoverflow.com/q/2622748
type: Answer
score: 3
upvote count: 3
has body: Most likely, value is a java.util.List. So you would access it like: System.out.println(((List&lt;?&gt;) request.get("arguments")).get(0)); But for more convenient access, perhaps have a look at Jackson, and specifically its Tree Model: JsonNode root = new ObjectMapper().readTree(source); System.out.println(root.get("arguments").get(0)); Jackson can of course bind to a regular Map too, which would be done like: Map&lt;?,?&gt; map = new ObjectMapper().readValue(source, Map.class); But accessing Maps is a bit less convenient due to casts, and inability to gracefully handle nulls.
has comment: http://stackoverflow.com/comment/17816069
downvote count: 0
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2622748

http://stackoverflow.com/a/34575422
type: Answer
answers question: http://stackoverflow.com/q/2727500
score: 0
has body: In the case of log4j,It provide a middle ware service where you can manage logging levels like DEBUG,INFO,ERROR etc. And you can enable and disable logging.But in the case of System.out.println() you have to manage every thing.

http://stackoverflow.com/a/2659278
has comment: http://stackoverflow.com/comment/2676330
has comment: http://stackoverflow.com/comment/2676337
has body: Create your own subclass of the one you want, and override the add method so that it checks if the new object will fit, and fails if not calls super.add() (and the constructors). If you want it to block when inserting if full, it is a different matter.
has comment: http://stackoverflow.com/comment/2676325
accepted answer of: http://stackoverflow.com/q/2659267
has comment: http://stackoverflow.com/comment/2676355
answers question: http://stackoverflow.com/q/2659267
type: Answer
has comment: http://stackoverflow.com/comment/2676376
score: 3
upvote count: 3
has comment: http://stackoverflow.com/comment/2676809
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/2795189
has text: Ah crap I deleted the ItemListener code I tried just now. I'll try again. EDIT: Nope, didn't work.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2762857

http://stackoverflow.com/q/2642777
favorite count: 0
has comment: http://stackoverflow.com/comment/80476382
has answer: http://stackoverflow.com/a/17526301
linked to: http://stackoverflow.com/q/7822381
tagged with: apache-httpclient-4.x
has comment: http://stackoverflow.com/comment/48112833
possible better answer: http://stackoverflow.com/a/6378872
linked to: http://stackoverflow.com/q/6457471
linked to: http://stackoverflow.com/q/2603691
has answer: http://stackoverflow.com/a/11951889
has answer: http://stackoverflow.com/a/16022833
accepted answer: http://stackoverflow.com/a/4837230
upvote count: 441
has answer: http://stackoverflow.com/a/6378872
has answer: http://stackoverflow.com/a/5297100
has answer: http://stackoverflow.com/a/20228162
has answer: http://stackoverflow.com/a/10614035
has answer: http://stackoverflow.com/a/7665711
linked to: http://stackoverflow.com/q/995514
answer count: 22
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/6825226
linked to: http://stackoverflow.com/q/1219208
linked to: http://stackoverflow.com/q/22457986
tagged with: java
linked to: http://stackoverflow.com/q/5909308
tagged with: certificate
has answer: http://stackoverflow.com/a/9246319
has answer: http://stackoverflow.com/a/37530625
has comment: http://stackoverflow.com/comment/27991720
has answer: http://stackoverflow.com/a/5493452
tagged with: https
downvote count: 7
has answer: http://stackoverflow.com/a/67050581
type: Question
has title: Trusting all certificates using HttpClient over HTTPS
tagged with: ssl
has answer: http://stackoverflow.com/a/50316726
has comment: http://stackoverflow.com/comment/10321905
has answer: http://stackoverflow.com/a/16204945
has answer: http://stackoverflow.com/a/4837230
has body: Recently posted a question regarding the HttpClient over Https (found here). I've made some headway, but I've run into new issues. As with my last problem, I can't seem to find an example anywhere that works for me. Basically, I want my client to accept any certificate (because I'm only ever pointing to one server) but I keep getting a javax.net.ssl.SSLException: Not trusted server certificate exception. So this is what I have: public void connect() throws A_WHOLE_BUNCH_OF_EXCEPTIONS { HttpPost post = new HttpPost(new URI(PROD_URL)); post.setEntity(new StringEntity(BODY)); KeyStore trusted = KeyStore.getInstance("BKS"); trusted.load(null, "".toCharArray()); SSLSocketFactory sslf = new SSLSocketFactory(trusted); sslf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme ("https", sslf, 443)); SingleClientConnManager cm = new SingleClientConnManager(post.getParams(), schemeRegistry); HttpClient client = new DefaultHttpClient(cm, post.getParams()); HttpResponse result = client.execute(post); } And here's the error I'm getting: W/System.err( 901): javax.net.ssl.SSLException: Not trusted server certificate W/System.err( 901): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:360) W/System.err( 901): at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:92) W/System.err( 901): at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:321) W/System.err( 901): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:129) W/System.err( 901): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164) W/System.err( 901): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119) W/System.err( 901): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDir…
has answer: http://stackoverflow.com/a/38636563
has answer: http://stackoverflow.com/a/28318375
score: 434
has answer: http://stackoverflow.com/a/8142813
has answer: http://stackoverflow.com/a/18848086
has answer: http://stackoverflow.com/a/55721889
has answer: http://stackoverflow.com/a/40714946
has answer: http://stackoverflow.com/a/13812958
linked to: http://stackoverflow.com/q/2899079

http://stackoverflow.com/q/2741402
has title: JPA @TableGenerator shared between multiple entities
accepted answer: http://stackoverflow.com/a/2742220
answer count: 1
tagged with: jpa
downvote count: 0
has body: I have a 'dog' Entitiy with an @Id and a @TableGenerator ... @TableGenerator(table = "seq", name = "dog_gen", pkColumnName = "seq_name", valueColumnName="seq_val") @Id @GeneratedValue(strategy = GenerationType.TABLE, generator = "dog_gen") private Long id; ... Is there a way to reuse the same table generator (dog_gen) in other entity? I want to keep the same id sequence in two independent Entities, say dog=1, dog=2, dog=3, cat=4, cat=5, dog=6 and so on... Both entities don't share a common superclass to implement some kind of inheritance with the id property. If I add the @GeneratedValue( generator="dog_gen") on my cat entity, omitting the @TableGenerator declaration throws an Exception saying it can't find the generator when starting the context. Caused by: org.hibernate.AnnotationException: Unknown Id.generator: dog_gen at org.hibernate.cfg.BinderHelper.makeIdGenerator(BinderHelper.java:413) at org.hibernate.cfg.AnnotationBinder.bindId(AnnotationBinder.java:1795) at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1229) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:733) at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:498) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:277)
has answer: http://stackoverflow.com/a/2742220
favorite count: 0
type: AnsweredQuestion
score: 7
tagged with: java
tagged with: hibernate
tagged with: orm
upvote count: 7
type: Question

http://stackoverflow.com/comment/107195872
comment on: http://stackoverflow.com/a/2777297
score: 0
has text: Your otherwise good answer is marred by several examples that won't compile, such as `List<? extends Number> foo3 = new ArrayList<Number>;` and `Collections.copy(new ArrayList<Number>(), new ArrayList<Integer());`.
type: AnswerComment
type: Comment

http://stackoverflow.com/a/2638517
has comment: http://stackoverflow.com/comment/2661831
answers question: http://stackoverflow.com/q/2638389
score: 0
has body: I'm not sure how it's working in standalone mode, but the "" element in your Spring context allows the use "@Resource" annotations. Look at the Spring doc for more information.
type: Answer
has comment: http://stackoverflow.com/comment/2652893

http://stackoverflow.com/a/2670405
score: 3
answers question: http://stackoverflow.com/q/2670312
upvote count: 3
type: Answer
has body: I would stick with the user's home directory for saving preferences. Alternatively, you can use the Preferences API. With the preferences API, you can store both application and user preferences. The downside is that the implementation is in control of where those files get stored. By default, in Windows it uses the registry. import java.util.prefs.Preferences; // System node Preferences systemPrefs = Preferences.systemNodeForPackage(YourClass.class); // User node Preferences userPrefs = Preferences.userNodeForPackage(YourClass.class); systemPrefs.put("My Preference", "A string"); String myPreference = systemPrefs.get("My Preference"); userPrefs.putInt("A number", 1); int aNumber = userPrefs.getInt("A number");
downvote count: 0

http://stackoverflow.com/comment/2878150
score: 0
type: Comment
has text: A pity there isn't a `Content-Length` header to provide more hints.
type: AnswerComment
comment on: http://stackoverflow.com/a/2678397

http://stackoverflow.com/a/2708645
type: Answer
accepted answer of: http://stackoverflow.com/q/2708621
has body: At this point, speed isn't important (insert premature-optimization comment ;). What matters is how quickly you can understand what the code does, which is to call a method dicePool times. The first method allocates an array of size dicePool and iterates through its values, which happens to run the loop body dicePool times (I'll pretend you meant int instead of Integer to avoid the unrelated autoboxing issue). This is potentially inefficient for the computer running the code, but more importantly it's inefficient for the human reading the code as it's conceptually distant from what you wanted to accomplish. Specifically, you force the reader to think about the new array you've just made, AND the value of the variable a, which will be 0 for every iteration of the loop, even though neither of those are related to your end goal. Any Java programmer looking at the second method will realize that you're executing the loop body dicePool times with i 'counting up' to dicePool. While the latter part isn't especially important, the beginning is exactly what you meant to do. Using this common Java idiom minimizes the unrelated things a reader needs to think about, so it's the best choice. When in doubt, go with simplicity. :D
answers question: http://stackoverflow.com/q/2708621
upvote count: 12
has comment: http://stackoverflow.com/comment/2732714
type: AcceptedAnswer
downvote count: 0
score: 12
has comment: http://stackoverflow.com/comment/2732879

http://stackoverflow.com/a/2734565
upvote count: 1
downvote count: 0
answers question: http://stackoverflow.com/q/2734318
type: Answer
has body: It's "Easier click listeners" section here http://android-developers.blogspot.com/2009/10/ui-framework-changes-in-android-16.html
score: 1

http://stackoverflow.com/a/20771871
has body: Using j-text-utils you may print to console a table like: And it as simple as: TextTable tt = new TextTable(columnNames, data); tt.printTable(); The API also allows sorting and row numbering ...
score: 43
type: Answer
has comment: http://stackoverflow.com/comment/123781863
answers question: http://stackoverflow.com/q/2745206
has comment: http://stackoverflow.com/comment/33040962
upvote count: 43
downvote count: 0

http://stackoverflow.com/q/2660827
answer count: 3
possible better answer: http://stackoverflow.com/a/2660843
has answer: http://stackoverflow.com/a/22188697
downvote count: 1
tagged with: covariance
tagged with: generics
has comment: http://stackoverflow.com/comment/2678181
has title: java generics covariance
favorite count: 0
has answer: http://stackoverflow.com/a/2660843
has comment: http://stackoverflow.com/comment/30233810
has answer: http://stackoverflow.com/a/2660850
accepted answer: http://stackoverflow.com/a/2660850
upvote count: 27
has comment: http://stackoverflow.com/comment/2678093
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/42538187
tagged with: java
has body: I am having trouble understanding the following article: http://www.ibm.com/developerworks/java/library/j-jtp01255.html Under, Generics are not covariant the author states, Because ln is a List, adding a Float to it seems perfectly legal. But if ln were aliased with li, then it would break the type-safety promise implicit in the definition of li -- that it is a list of integers, which is why generic types cannot be covariant. I can't understand the part where it says "if ln were aliased with li". What does the author means by alias?(reference?). The code snippet above the quoted line seems to illustrate WHAT is illegal in java and not WHY. It would be very helpful to me if somebody could explain with an example. Thanks in advance.
type: Question
has comment: http://stackoverflow.com/comment/2678130
score: 26
tagged with: alias

http://stackoverflow.com/comment/2813876
score: 0
has text: @srinannapa--cannot find symbol. symbol: class Clonable :(
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2779111

http://stackoverflow.com/a/2624669
accepted answer of: http://stackoverflow.com/q/2624610
answers question: http://stackoverflow.com/q/2624610
score: 5
has comment: http://stackoverflow.com/comment/87961949
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2637605
upvote count: 5
type: Answer
has comment: http://stackoverflow.com/comment/2637394
has comment: http://stackoverflow.com/comment/2637505
has body: Try this: Date estTime = new Date(utcTime.getTime() + TimeZone.getTimeZone("EST").getRawOffset()); Where utcTime is Date object of UTC time (if you already have the long value - just use it)
downvote count: 0

http://stackoverflow.com/a/2705186
type: Answer
has comment: http://stackoverflow.com/comment/2730655
score: 0
has comment: http://stackoverflow.com/comment/2728727
has body: Try defining a bunch of functions with the same name that take a different type for the default, and let the compiler figure it out. Java really ties your hands when working with types, especially primitive types. public function int getPreference( String key , int missing ) { return sharedPreferences.getInt( key , missing ); } public function boolean getPreference( String key , boolean missing ) { return sharedPreferences.getBoolean( key , missing ); } public function String getPreference( String key , String missing ) { return sharedPreferences.getString( key , missing ); } Edit: If you are trying to get an object (not primitive) regardless of the type, you can use: public function Object getPreference( String key , Object missing ) { return sharedpreferences.contains( key ) ? sharedPreferences.getAll().get( key ) : missing; } If you are trying to get a specific type like int regardless of what is stored, you can use: public function int getPreference( String key , int missing ) { int result = missing; Object value = sharedpreferences.contains( key ) ? sharedPreferences.getAll().get( key ) : null; if ( value instanceof Integer ) result = ((Integer)value).intValue(); if ( value instanceof Boolean ) result = ((Boolean)value).booleanValue() ? 1 : 0; // repeat for every other primitive wrapper type you care about return result; } If you are trying to get a result only if it is a certain type, you can use something like: public function Object getPreference( Class inRequire , String key , Object missing ) { Object value = sharedpreferences.contains( key ) ? sharedPreferences.getAll().get( key ) : null; if ( !( value instanceof inRequire ) ) { value = null; } return ( value == null ) ? missing : value; }
answers question: http://stackoverflow.com/q/2705091
has comment: http://stackoverflow.com/comment/2732485

http://stackoverflow.com/comment/90325614
has text: I have been investigating this same topic for other purposes and I found the following references to be really good. - [Prefer polymorphism over instanceof and downcasting](http://www.artima.com/interfacedesign/PreferPoly.html) - [instanceof versus getClass in equals Methods](http://www.artima.com/intv/bloch17.html) (Interview with Josh Bloch) - [Polymorphism and Interfaces](http://www.artima.com/objectsandjava/webuscript/PolymorphismInterfaces1.html) (see section about When to use instanceof)
score: 1
comment on: http://stackoverflow.com/q/2750714
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/100894586
score: 13
type: AnswerComment
comment on: http://stackoverflow.com/a/2673864
type: Comment
has text: Coming from C# to Java it is quite often a step down in a lot of ways

http://stackoverflow.com/q/2778672
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/2813348
has body: I want to merge two Resultset Object into third one. If you have any idea then reply.. vipul
tagged with: java
has title: java problem about ResultSet
type: Question
has answer: http://stackoverflow.com/a/2778717
score: 0
answer count: 2
has answer: http://stackoverflow.com/a/2778692

http://stackoverflow.com/comment/14137871
comment on: http://stackoverflow.com/a/2610508
score: 0
type: Comment
has text: That's why people are writing software that is not portable to another system.
type: AnswerComment

http://stackoverflow.com/comment/63120942
score: 13
type: AnswerComment
comment on: http://stackoverflow.com/a/5313383
has text: "Utility-Classes" are very difficult to reason about, the bad thing is that sooner or later everything starts 'looking like' an utility (yeah I'm referring to that "util" package that is bloated, untouchable and poorly tested), and your test cases will need more work (to mock static utils is HARD). Prefer objects first.
type: Comment

http://stackoverflow.com/q/2740909
has answer: http://stackoverflow.com/a/2740949
answer count: 3
favorite count: 0
has comment: http://stackoverflow.com/comment/2770037
accepted answer: http://stackoverflow.com/a/2740949
has answer: http://stackoverflow.com/a/2741044
has comment: http://stackoverflow.com/comment/2769935
type: AnsweredQuestion
score: 3
upvote count: 3
tagged with: java
possible better answer: http://stackoverflow.com/a/2741044
has answer: http://stackoverflow.com/a/2741113
type: Question
has title: Java: moving ball with angle?
downvote count: 0
has body: I have started to learn game physics and I am trying to move a ball with an angle. But it does not change its angle. Java coordinate system is a little different and I think my problem is there. Here is my code. This is for calculating x and y speed: scale_X= Math.sin(angle); scale_Y=Math.cos(angle); velosity_X=(speed*scale_X); velosity_Y=(speed*scale_Y); This is for moving ball in run() function: ball.posX =ball.posX+(int)velosity_X; ball.posY=ball.posY+(int)velosity_Y; I used (int)velosity_X and (int)velosity_Y because in ball class I draw object g.drawOval(posX, posX, width, height); and here g.drawOval requires int. I dont know if it is a problem or not. Also if I use angle 30 it goes +X and +Y but if I use angle 35 it goes -X and -Y. I did not figure out how to work coordinate system in Java.

http://stackoverflow.com/comment/26537719
type: AnswerComment
type: Comment
has text: LineMetrics does not what I want... I've looked into it a hundred times. Can I use LineMetrics to get the width of a String?
comment on: http://stackoverflow.com/a/14729798
score: 4

http://stackoverflow.com/q/2768528
has title: JBoss, exploded jar vs compact jar
tagged with: ejb
tagged with: java
tagged with: jboss
answer count: 2
downvote count: 0
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2768562
has body: I am working on Java 1.6, JBoss 5.1, EJB 3, and Hibernate 2. Every time I deploy the ear, if the jar is a compact one (non-exploded), application doesn't work. However when I explode the jar and then add it to the ear, the app works fine. Tried restarting Jboss, doesn't help. The ear refers to numerous external jars; would the order of loading the jars be an issue? How can I make JBoss load external jars followed by the app jars? Thx. WM.
tagged with: deployment
has comment: http://stackoverflow.com/comment/2801413
score: 2
upvote count: 2
has answer: http://stackoverflow.com/a/2768593
has comment: http://stackoverflow.com/comment/2801528
type: Question

http://stackoverflow.com/q/2704965
linked to: http://stackoverflow.com/q/560956
upvote count: 2
answer count: 3
has body: I have an array of bytes. I want to simulate corrupt data by changing one bit, two, and three bits. How do I do this?
favorite count: 0
has title: Changing bits in an array of bytes
accepted answer: http://stackoverflow.com/a/2705017
has answer: http://stackoverflow.com/a/2705026
score: 2
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2728531
downvote count: 0
has answer: http://stackoverflow.com/a/2704993
tagged with: java
tagged with: bit-manipulation
has answer: http://stackoverflow.com/a/2705017
type: Question
possible better answer: http://stackoverflow.com/a/2704993

http://stackoverflow.com/comment/24448914
has text: Sawyer, the fact that you can mix HTML to scala code doesn't say that you have to. Using snippets in a smart way will separate HTML and Scala code. But hey, keep up using your control tags ;)
type: Comment
comment on: http://stackoverflow.com/a/2687600
score: 0
type: AnswerComment

http://stackoverflow.com/a/42970627
type: Answer
answers question: http://stackoverflow.com/q/2617920
has body: You need both setBackground(), setContentAreaFilled(false), setOpaque(true) on your button.
score: 0

http://stackoverflow.com/comment/2632996
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2620687
has text: I think you have answered the question yourself. If it is lightweight and single user and you are comfortable with RMI, then you should just go with it.

http://stackoverflow.com/comment/2671739
has text: Thanks Dmitry, I'm using Genonimo instead of Glassfish for the J2EE server. I've set up the data source correctly. Here's my persistence.xml: org.apache.openjpa.persistence.PersistenceProviderImpl myDatasource com.skomarcorp.Schedule . Can you explain the difference between using @PersistenceContext and EntityManagerFactory and why one is better than the other?
type: Comment
comment on: http://stackoverflow.com/a/2645334
type: AnswerComment
score: 0

http://stackoverflow.com/a/7404476
type: Answer
score: 3
upvote count: 3
has body: I had this issue when logging.properties has .level=INFO as well. The problem turned out to be that one of my shared libraries has a logging.properties in it as well (and this set .level=FINEST). I fixed the issue by editing catalina.properties and making sure a directory containing logging.properties was first in the shared.loader classpath.
downvote count: 0
answers question: http://stackoverflow.com/q/2654698

http://stackoverflow.com/q/2770543
type: Question
tagged with: debugging
possible better answer: http://stackoverflow.com/a/2770577
tagged with: java
tagged with: eclipse
has answer: http://stackoverflow.com/a/2777066
has answer: http://stackoverflow.com/a/2770638
accepted answer: http://stackoverflow.com/a/2770640
has comment: http://stackoverflow.com/comment/2803909
downvote count: 0
has title: A debbugging test, suggestions needed
favorite count: 0
has body: I am having a debugging test, as part of an interview.. I thought if any one can help with the approach, when I am faced with a large code base and have to find bugs inside that within an hour or two.This is going to be Core java based app (I guess) on Eclipse 3.2+
has answer: http://stackoverflow.com/a/2770577
has answer: http://stackoverflow.com/a/2770640
answer count: 4
score: 2
has comment: http://stackoverflow.com/comment/2803963
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2803951
upvote count: 2

http://stackoverflow.com/q/2716256
score: 0
answer count: 2
has body: ChatGUI im using 2 JEditorPane to transfer text from one to another. once i have transfered the data i do the following: JEditorPane.setText(null); JEditorPane.setCaretPosition(0); but as you can see from the attached image the return action makes the prompt appear a row down. how can i fix this? EDIT: does the following seem correct to you? if so then why is caret not positioning itself to chracter 0 position? private class MyKeyAdapter extends KeyAdapter { @Override public void keyPressed(KeyEvent ke) { int kc = ke.getKeyCode(); if (kc == ke.VK_ENTER) { System.out.println(editorPaneHistory.getText()); System.out.println(editorPaneHomeText.getText()); editorPaneHistory.setText(editorPaneHomeText.getText()); //JEditorPane - editorPaneHistory //JEditorPane - editorPaneHomeText editorPaneHomeText.setText(null); editorPaneHomeText.setCaretPosition(0); } } }
tagged with: jeditorpane
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2718324
has comment: http://stackoverflow.com/comment/2742079
tagged with: java
has comment: http://stackoverflow.com/comment/2742051
accepted answer: http://stackoverflow.com/a/2716798
possible better answer: http://stackoverflow.com/a/2718324
type: Question
has comment: http://stackoverflow.com/comment/2742173
has title: Java JEditorPane
has answer: http://stackoverflow.com/a/2716798

http://stackoverflow.com/a/2684447
upvote count: 1
has comment: http://stackoverflow.com/comment/2710019
has comment: http://stackoverflow.com/comment/2721475
type: AcceptedAnswer
downvote count: 0
has body: David, thanks for taking the time to write this up. I'm a C# programmer, so my Java skills are a bit vague these days. Because of this, I decided to port your code over and test it myself. I found some interesting differences and similarities, which are pretty much worth the price of admission as far as I'm concerned. Among the major differences are: I didn't have to implement TryGet because it's built into Dictionary. In order to use the native TryGet, instead of inserting nulls to simulate misses, I simply omitted those values. This still means that v = map[k] would have set v to null, so I think it's a proper porting. In hindsight, I could have inserted the nulls and changed (_map.TryGetValue(key, out value)) to (_map.TryGetValue(key, out value) &amp;&amp; value != null)), but I'm glad I didn't. I want to be exceedingly fair. So, to keep the code as compact and maintainable as possible, I used lambda calculus notation, which let me define the callbacks painlessly. This hides much of the complexity of setting up anonymous delegates, and allows me to use closures seamlessly. Ironically, the implementation of Lookup uses TryGet internally. Instead of declaring a new type of Dictionary, I used an extension method to graft Lookup onto the standard dictionary, much simplifying the code. With apologies for the less-than-professional quality of the code, here it is: using System; using System.Collections.Generic; using System.Linq; namespace ConsoleApplication1 { static class CallbackDictionary { public static void Lookup&lt;K, V&gt;(this Dictionary&lt;K, V&gt; map, K key, Action&lt;K, V&gt; found, Action&lt;K&gt; missed) { V v; if (map.TryGetValue(key, out v)) found(key, v); else missed(key); } } class TryGetExample { private Dictionary&lt;string, string&gt; _map; private List&lt;string&gt; _found; private List&lt;string&gt; _missing; public TryGetExample(Dictionary&lt;string, string&gt; map) { _map = map; _found = new List&lt;string&gt;(_map.Count); _missing = new List…
type: Answer
accepted answer of: http://stackoverflow.com/q/2681415
has comment: http://stackoverflow.com/comment/2709979
answers question: http://stackoverflow.com/q/2681415
score: 1

http://stackoverflow.com/q/2768032
has answer: http://stackoverflow.com/a/2768053
has title: Using interfaces in java
has answer: http://stackoverflow.com/a/2768049
downvote count: 0
has body: Suppose there in an interface Displaceable and a class Circle which implements Displaceable. Displaceable has a method named move() which of course is implemented in Circle. What would happen in the following scenario? Circle a = new Circle(..); Displaceable b = a; b.move() Would the object refer to the Circle's move method?
favorite count: 0
accepted answer: http://stackoverflow.com/a/2768053
answer count: 4
type: AnsweredQuestion
score: 3
possible better answer: http://stackoverflow.com/a/2768150
upvote count: 3
tagged with: java
has answer: http://stackoverflow.com/a/2768150
type: Question
has answer: http://stackoverflow.com/a/2768073

http://stackoverflow.com/q/2626981
has comment: http://stackoverflow.com/comment/2648598
tagged with: security
downvote count: 0
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/4749262
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/502218
score: 1
tagged with: java
has title: Restricting dynamically loaded classes and jars based on a security policy
has body: I would like to dynamically load a set of jars or classes (i.e. plugins loaded at runtime). At the same time, I would like to restrict what these plugins are able to do in the JVM. For a test case, I would like to restrict them to pretty much everything (right now I'm just allowing one System.getProperty value to be read). I am currently using a security policy file, but I'm having difficulty specifying a policy for one folder or package in my codeBase, but not another. Here is how my policy looks now: grant codeBase "file:/home/max/programming/java/plugin/plugins/" { permission java.util.PropertyPermission "java.version", "read"; }; grant codeBase "file:/home/max/programming/java/plugin/api/" { permission java.security.AllPermission; }; Where (for testing purposes), all files in the plugins package and folder are restricted, but the classes in the api folder are not. Is this possible? Do I have to create a custom class loader? Is there a better way to go about doing this? Thanks.
upvote count: 1
accepted answer: http://stackoverflow.com/a/4749262
has comment: http://stackoverflow.com/comment/2648038
type: Question
has comment: http://stackoverflow.com/comment/2647195

http://stackoverflow.com/comment/2615502
has text: Thank you, Darin. But i want to know why the lazy field isn't so lazy as i want :) But, of cource, I'll use you suggestion, if I don't find the another way to solve the problem.
comment on: http://stackoverflow.com/a/2605497
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/16105221
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2755768
has text: Incredible! Looks much better than separate method just for recursive calls.

wav
tags question: http://stackoverflow.com/q/2709508
tag name: wav
type: Tag

dynamic
tags question: http://stackoverflow.com/q/2706258
tag name: dynamic
tags question: http://stackoverflow.com/q/2749778
tags question: http://stackoverflow.com/q/2665655
tags question: http://stackoverflow.com/q/2641386
tags question: http://stackoverflow.com/q/2711067
tags question: http://stackoverflow.com/q/2609227
tags question: http://stackoverflow.com/q/2699327
type: Tag

http://stackoverflow.com/a/2652819
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2669275
type: Answer
has body: Because static members of a class are created and initialized (during class loading) before any instance of the class is ever created - they can be accessed without creating an instance of the class as well. Non-static members are created per-instance and thus wait until an instance is created to be initialized for that instance.
has comment: http://stackoverflow.com/comment/2669284
accepted answer of: http://stackoverflow.com/q/2652801
has comment: http://stackoverflow.com/comment/2669073
upvote count: 17
answers question: http://stackoverflow.com/q/2652801
score: 17

http://stackoverflow.com/comment/2627088
type: AnswerComment
has text: Well, according to my understanding the type of the ?: result is established upfront and independantly of the evaluation of the condition. So what is the type of false?1.0f:null, which is used as the third value in F2? If it was the null type, then F2 should not NPE. If it was float, neither, nor if it was Float.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2615573

http://stackoverflow.com/q/2761481
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2761524
tagged with: java
tagged with: concurrency
type: Question
score: 0
answer count: 2
accepted answer: http://stackoverflow.com/a/2761524
has comment: http://stackoverflow.com/comment/2793524
has body: I created a Java LinkedBlockingQueue like new LinkedBlockingQueue(1) to limit the size of the queue to 1. However, in my testing, this seems to be ignored and there is often several things in the queue at any given time. Why is this?
possible better answer: http://stackoverflow.com/a/33819331
has title: LinkedBlockingQueue limit ignored?
has answer: http://stackoverflow.com/a/33819331

http://stackoverflow.com/comment/2733873
type: QuestionComment
comment on: http://stackoverflow.com/q/2709496
score: 0
has text: You must specify layout_width and layout_height for every element. Is this your problem or have you simplified your code for purposes of posting here?
type: Comment

http://stackoverflow.com/comment/42134303
type: Comment
score: 2
has text: @TusharPandey: I think that happens only for the project's own source folders, which are always exported.
type: AnswerComment
comment on: http://stackoverflow.com/a/2737532

http://stackoverflow.com/comment/2650610
comment on: http://stackoverflow.com/q/2636056
has text: The problem is the second `?` (the one after the character group). Since the input seems to XML, the quotes aren't optional anyway, so removing it is not a problem and it makes the regex work.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2760817
has title: including pre-built java classes into an android project
type: AnsweredQuestion
score: 1
tagged with: java
tagged with: eclipse
accepted answer: http://stackoverflow.com/a/2761171
type: Question
downvote count: 0
has body: i'm trying to include a maven java project into my android project. the maven project is the greader-unofficial project which allows developers access to google reader accounts, and handles all of the http transactions and URI/URL building, making grabbing feeds and items from google reader transparent to the developer. the project is available here: http://code.google.com/p/greader-unofficial/ the code is originally written for the standard jdk and uses classes from java.net that are not a part of the standard Android SDK. i actually tried to manually resolve all dependencies and ran into a problem when i got as far as including com.sun.syndication pieces required by the class be.lechtitseb.google.reader.api.util.AtomUtil.java... some of the classes in java.net that are in the standard jdk (i'm using 1.6) are not in the Android SDK. in addition, resolving all of these dependencies manually is just ridiculous when i'm compiling a maven project that should be pretty simple. however, i can use maven to compile the sources with no issue. how can i include this maven project, which is dependent on the complete jdk, into my android project in such a way that it will compile so that i can access the GoogleReader class from my android project? and for the record, i don't have the expertise to rewrite this entire api to work with the standard Android SDK.
possible better answer: http://stackoverflow.com/a/4376336
has answer: http://stackoverflow.com/a/4376336
answer count: 3
favorite count: 0
has answer: http://stackoverflow.com/a/2761171
has answer: http://stackoverflow.com/a/2762039
tagged with: android
tagged with: maven
upvote count: 1

http://stackoverflow.com/comment/2691131
type: AnswerComment
comment on: http://stackoverflow.com/a/2672325
type: Comment
has text: The object it is contained in isn't a Component, it just stored a JButton object, along with other data. getParent therefore won't return the Object that contains the JButton. Any other way you know to have a button reference something, or to override the JButton's ActionListener functinos, that provide a "source"?
score: 0

http://stackoverflow.com/a/2692027
downvote count: 0
has body: You could try some kind of quoting: For example: @Column(name="`IHINV#`") or @Column(name="'IHINV#'") Another option would be to dig in to source code Hibernate dialect for DB2 and see if it contains anything helpful. Of course, the easiest way would be to remove the hash from column name if possible.
type: Answer
answers question: http://stackoverflow.com/q/2691957
score: 2
upvote count: 2

http://stackoverflow.com/comment/2699678
has text: See comment on other answer, but basically, I'm not actually using Strings, I'm using a different data type. Strings were for illustrative purposes.
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/2680037

http://stackoverflow.com/q/2687773
has body: I'm trying to use the SmugFig SmugMug API on Android. It was designed for J2SE I would imagine, so I'm not sure it will even work on Android, but I figured it was worth trying as opposed to trying to create my own API. When I load the project though, I get the following error: Conversion to Dalvik format failed: Unable to execute dex: null It doesn't say what package it fails on, just "Android Packaging Problem", but it did not do this before I added SmugFig and it's dependency JARS to the build path. Where should I look? Or does this mainly me that it just won't work with those libraries?
has answer: http://stackoverflow.com/a/2774826
has answer: http://stackoverflow.com/a/9324028
tagged with: android
has answer: http://stackoverflow.com/a/16077527
has answer: http://stackoverflow.com/a/6149229
favorite count: 0
has answer: http://stackoverflow.com/a/12313623
tagged with: dalvik
score: 33
type: Question
has answer: http://stackoverflow.com/a/4409317
has title: Android: Conversion to Dalvik format failed: Unable to execute dex: null
has comment: http://stackoverflow.com/comment/4763728
has answer: http://stackoverflow.com/a/4371172
has answer: http://stackoverflow.com/a/6518744
has answer: http://stackoverflow.com/a/26744082
has answer: http://stackoverflow.com/a/7304435
answer count: 14
tagged with: java
tagged with: eclipse
has answer: http://stackoverflow.com/a/4372504
has answer: http://stackoverflow.com/a/15083566
upvote count: 33
has answer: http://stackoverflow.com/a/3178804
downvote count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/16276384

http://stackoverflow.com/comment/2811865
type: Comment
score: 1
has text: It helps to remember that it just plain _isn't your job_ as a programmer to do these kinds of nano-optimizations. You don't have the level of control required to do it. It's the VM's job.
comment on: http://stackoverflow.com/a/2772057
type: AnswerComment

http://stackoverflow.com/q/2781312
answer count: 2
accepted answer: http://stackoverflow.com/a/2899694
tagged with: facebook
has title: why my website display in FB Login window After Login through facebook?
type: AnsweredQuestion
has body: I am Integrating Face book application with Our Website. My Website is in Java's [Google Web Toolkit] Framework 2.0.1 When we press FB-connect connect then FB's Login window comes, after that user enters email &amp; pwd. When user clicks FB's connect button then Our website display in that Login window. Authentication and Connect Url is Proper http://localhost:8090/websitename/ How to solve this problem ? Where I did mistake ? Is there any solution? When I did same thing in GWT's development/Hosted mode with Authentication and Connect url http:/127.0.0.1:8888/ then works properly. Then why It create Probelm in localhost? :-/
tagged with: java
has answer: http://stackoverflow.com/a/2899694
type: Question
tagged with: gwt
possible better answer: http://stackoverflow.com/a/2781448
has answer: http://stackoverflow.com/a/2781448
score: 0

http://stackoverflow.com/comment/2698497
has text: That link looks good. Did it answer your question?
comment on: http://stackoverflow.com/q/2678812
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/2682051
type: Comment
score: 0
has text: Put it on the entity class. And you said you don't use hbm.xml, not orm.xml. I somehow assumed you are using JPA xml files (because beans.xml isn't the default name in spring).
type: AnswerComment
comment on: http://stackoverflow.com/a/2662312

http://stackoverflow.com/a/2774434
has body: http://java.sun.com/docs/books/tutorial/collections/interfaces/set.html I don't have a good example at the moment, but I believe he's referring to this: "The intersection of two sets is the set containing only the elements common to both sets." Where 'sets' can also be Lists, etc. Java has built in methods for this. Say you have a List list, you would do something like this: list.removeAll(list2); or list.retainAll(list2); retainAll will you give you the 'intersection', removeAll gives you the difference between the two lists.
has comment: http://stackoverflow.com/comment/2808376
downvote count: 0
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/2808248
upvote count: 2
answers question: http://stackoverflow.com/q/2774173

http://stackoverflow.com/a/2661386
has body: This isn't unique to Java. Many systems default to the system time zone. After all, what else can they do? Time zones are a thorny issues, particularly when the application needs to deal with several time zones. That's why sites such as this one put everything in UTC. As for your situation, it's hard to comment because the description is rather vague but it sounds like this is your error. If you save a date (without time zone) in one place at GMT+2 and then load it another at GMT then you've done something wrong.
has comment: http://stackoverflow.com/comment/2678676
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2678791
upvote count: 8
has comment: http://stackoverflow.com/comment/2678720
type: Answer
answers question: http://stackoverflow.com/q/2661374
score: 8
accepted answer of: http://stackoverflow.com/q/2661374
has comment: http://stackoverflow.com/comment/2678764

http://stackoverflow.com/a/2758173
has body: Glassfish v3 is a slow starter (~30 secs), but its hotdeployments are fast. It happens in less than a second, regardless of what you've edited: JSP files or Java classes. At least, that was my experience in combination with Eclipse and the Glassfish Eclipse plugin. Things which may matter a lot. And as a bonus, you've the opportunity to play with the awesome Java EE 6 API. Tomcat 6.0 is quick starter, in ~3 secs it's up and running. Hotdeploys of JSP files is acceptable, after ~3 seconds you can F5 to see the new one in browser. But hotdeploys of Java classes is sometimes troublesome. Sometimes it isn't picked up at all, or sometimes it takes too long that it's actually faster to manually restart Tomcat (which however takes "only" 3 seconds). Take your pick. I'm just using both.
upvote count: 3
type: AcceptedAnswer
type: Answer
score: 3
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2758037
answers question: http://stackoverflow.com/q/2758037

http://stackoverflow.com/q/2652654
favorite count: 0
tagged with: http://stackoverflow.com/tag/xml
type: UnansweredQuestion
score: 3
upvote count: 3
tagged with: java
has answer: http://stackoverflow.com/a/5312133
type: Question
has answer: http://stackoverflow.com/a/3139360
has title: how to create xml file for izpack?
answer count: 2
tagged with: izpack
linked to: http://stackoverflow.com/q/7598073
downvote count: 0
has body: I want to create my java application into a software. Then make it as an installer(setup). Also i made the java application into an executable jar. I am using IzPack for create installer. But i dont know create xml file for IzPack to add in it. If anybody know means, send me the procedure with example. Thanks in advance.

http://stackoverflow.com/q/2656326
answer count: 2
has answer: http://stackoverflow.com/a/2656353
type: AnsweredQuestion
score: 0
tagged with: java
tagged with: hibernate
accepted answer: http://stackoverflow.com/a/2656353
possible better answer: http://stackoverflow.com/a/2656346
type: Question
has title: How to use DAOs with hibernate/jpa?
has answer: http://stackoverflow.com/a/2656346
tagged with: data-access-layer
has body: Assuming the DAO structure and component interaction described below, how should DAOs be used with persistence layers like hibernate and toplink? What methods should/shouldn't they contain? Would it be bad practice to move the code from the DAO directly to the service? For example, let's say that for every model we have a DAO (that may or may not implement a base interface) that looks something like the following: public class BasicDao&lt;T&gt; { public List&lt;T&gt; list() { ... } public &lt;T&gt; retrieve() { ... } public void save() { ... } public void delete() { ... } } Component interaction pattern is -- service > DAO > model

http://stackoverflow.com/a/2706147
accepted answer of: http://stackoverflow.com/q/2706100
answers question: http://stackoverflow.com/q/2706100
has comment: http://stackoverflow.com/comment/2730097
type: AcceptedAnswer
has body: There are several areas where you need to check that character encoding is being correctly done as some default to UTF-8 and others do not (for example, iso-8859-1). Check: JDBC driver Java Virtual Machine (can only parse latin-based and unicode - can run native2ascii to convert non-latin characters to unicode) Database encoding Tomcat/JBoss, etc (server) browser operating system It's a pain in the neck to have to check all of this stuff, but someone's gotta do it. I recommend setting everything to UTF-8 as that is generally what people agree on To me it sounds like the JVM or your JDBC driver could be the source of the problem
downvote count: 0
type: Answer
upvote count: 2
score: 2

http://stackoverflow.com/q/2632451
favorite count: 0
linked to: http://stackoverflow.com/q/2609969
possible better answer: http://stackoverflow.com/a/2632480
has answer: http://stackoverflow.com/a/2632480
has body: I have a context loader class which loads an XML file with info on which components to show or hide on a page. On the JSP pages, within the 'rendered' attribute for a subView,, I would like to make a call to ContextLoader.displayPageComponent(String pageId, String componentId) which returns a boolean. Does this work in JSF? If not, is there another way to achieve the same?
has comment: http://stackoverflow.com/comment/2648245
has title: How to render or hide a jsf subview based on a method call (which returns boolean)?
score: 2
type: AnsweredQuestion
tagged with: jsf
upvote count: 2
accepted answer: http://stackoverflow.com/a/2637490
type: Question
linked to: http://stackoverflow.com/q/2378826
tagged with: java
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/2637490

tomcat
tags question: http://stackoverflow.com/q/2735524
tags question: http://stackoverflow.com/q/2741954
tags question: http://stackoverflow.com/q/2631644
tags question: http://stackoverflow.com/q/2643357
tags question: http://stackoverflow.com/q/2663204
tags question: http://stackoverflow.com/q/2770382
tags question: http://stackoverflow.com/q/2763331
tags question: http://stackoverflow.com/q/2644339
tags question: http://stackoverflow.com/q/2757043
tags question: http://stackoverflow.com/q/2627692
tags question: http://stackoverflow.com/q/2756891
tags question: http://stackoverflow.com/q/2636432
tags question: http://stackoverflow.com/q/2668698
tags question: http://stackoverflow.com/q/2698296
tags question: http://stackoverflow.com/q/2656565
tags question: http://stackoverflow.com/q/2653322
tags question: http://stackoverflow.com/q/2641338
tags question: http://stackoverflow.com/q/2647745
tags question: http://stackoverflow.com/q/2645975
tags question: http://stackoverflow.com/q/2720305
tags question: http://stackoverflow.com/q/2692772
tags question: http://stackoverflow.com/q/2725495
tags question: http://stackoverflow.com/q/2645298
tags question: http://stackoverflow.com/q/2649632
tags question: http://stackoverflow.com/q/2661224
tags question: http://stackoverflow.com/q/2618507
tags question: http://stackoverflow.com/q/2723564
tags question: http://stackoverflow.com/q/2730354
tags question: http://stackoverflow.com/q/2753464
tags question: http://stackoverflow.com/q/2751300
tag name: tomcat
tags question: http://stackoverflow.com/q/2739983
tags question: http://stackoverflow.com/q/2606249
tags question: http://stackoverflow.com/q/2736420
tags question: http://stackoverflow.com/q/2763956
tags question: http://stackoverflow.com/q/2764636
tags question: http://stackoverflow.com/q/2768518
tags question: http://stackoverflow.com/q/2659839
tags question: http://stackoverflow.com/q/2694127
tags question: http://stackoverflow.com/q/2664424
tags question: http://stackoverflow.com/q/2657515
tags question: http://stackoverflow.com/q/2739821
tags question: http://stackoverflow.com/q/2752576
tags question: http://stackoverflow.com/q/2666817
tags question: http://stackoverflow.com/q/2724352
tags question: http://stackoverflow.com/q/2702647
tags question: http://stackoverflow.com/q/2604977
tags question: http://stackoverflow.com/q/2779984
tags question: http://stackoverflow.com/q/2760867
tags question: http://stackoverflow.com/q/2718786
type: Tag
tags question: http://stackoverflow.com/q/2638389
tags question: http://stackoverflow.com/q/2781057
tags question: http://stackoverflow.com/q/2763454
tags question: http://stackoverflow.com/q/2720275
tags question: http://stackoverflow.com/q/2607842
tags question: http://stackoverflow.com/q/2642696
tags question: http://stackoverflow.com/q/2705309
tags question: http://stackoverflow.com/q/2761618
tags question: http://stackoverflow.com/q/2636399
tags question: http://stackoverflow.com/q/2696783
tags question: http://stackoverflow.com/q/2671336
tags question: http://stackoverflow.com/q/2718742
tags question: http://stackoverflow.com/q/2630437

http://stackoverflow.com/a/2622649
downvote count: 0
score: 7
has comment: http://stackoverflow.com/comment/2635567
has comment: http://stackoverflow.com/comment/3732797
has comment: http://stackoverflow.com/comment/2635598
type: Answer
has comment: http://stackoverflow.com/comment/2635552
answers question: http://stackoverflow.com/q/2622591
upvote count: 7
has body: While I too think that it's legitimate, I'd like to add that such an Iterator (or more precisely: an Iterable producing such an Iterator) would not play well with the enhanced for-loop (a.k.a for-each-loop): for (Object o : myIterable) { ... } Since the code inside an enhanced for loop has no direct access to the iterator, it couldn't call remove() on the iterator. So to end the looping it would have to do one of the following: Get access to the internal List of the Iterator and remove objects directly, possibly provoking a ConcurrentModificationException use break to exit the loop "use" an Exception to exit the loop use return to leave the loop All but the last of those alternatives aren't exactly the best way to leave an enhanced for-loop. The "normal" for-loop (or any other loop together with an explicit Iterator variable) would work just fine, of course: for (Iterator it = getIterator(); it.hasNext();) { Object o = it.next() ... }

http://stackoverflow.com/comment/50119915
comment on: http://stackoverflow.com/a/7676650
has text: thomas: I'm also facing same issue. How did you resolve the issue?
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/101838388
comment on: http://stackoverflow.com/a/2723914
type: Comment
score: 1
has text: @Syntactic: Actually [most filesystems do track this information](https://en.wikipedia.org/wiki/Comparison_of_file_systems#Metadata). Exceptions include ext<=3 and Reiser. FAT, NTFS, HFS, ZFS, and ext4 support it. But it has been slow to propagate through all the layers of Linux and the libraries and commands to make it universally used.
type: AnswerComment

http://stackoverflow.com/comment/2762670
comment on: http://stackoverflow.com/a/2734605
score: 0
type: AnswerComment
has text: @TofuBeer: Yes, sorry, I bungled the link; fixed in the answer, too.
type: Comment

http://stackoverflow.com/comment/2774398
type: Comment
has text: It was all security manager-related, the issues we had. That said it was a colleague on my team who had the battle with it, he's now left the company so I can't give you any specifics. Seeing your question though, and having never heard of such problems outside of packaged-tomcat-on-ubuntu is what set off the big red siren for me, and using an independent install has been seamless.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2736287

http://stackoverflow.com/q/2688960
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/2690944
answer count: 1
tagged with: binary-data
has comment: http://stackoverflow.com/comment/6841969
score: 0
tagged with: rest
has body: I want to create Restful service which can accept binary data. I've implemented javax.xml.ws.Provider interface, but i can't get content of request. If I use javax.xml.ws.Dispatch then its send only XML data, but I need transfer binary data. Please give some solution, but I don't prefer to use JAX-RS or Restlets. Thanks.
tagged with: service
type: UnansweredQuestion
has title: REST service with binary data

http://stackoverflow.com/comment/47630322
comment on: http://stackoverflow.com/a/16883281
type: Comment
has text: @Hugo read the bit about Android 5. If that's not suitable, you might be better off asking another question, because not many people will see your comment.
type: AnswerComment
score: 0

http://stackoverflow.com/comment/2616904
type: QuestionComment
comment on: http://stackoverflow.com/q/2606523
has text: "This makes Java developer lazy in implementing memory management" this is complete garbage. You can be just as lazy in C++ when you don't understand what you're doing. Competent developers in Java are capable of managing memory (by preventing leaks) just as well, it just isn't explicitly.
score: 4
type: Comment

http://stackoverflow.com/a/2774682
type: Answer
has body: You can find if the JRE is 32 or 64 bit by looking at the "os.arch" system property
downvote count: 0
answers question: http://stackoverflow.com/q/2774467
score: 1
upvote count: 1

http://stackoverflow.com/a/2767513
answers question: http://stackoverflow.com/q/2767340
type: AcceptedAnswer
score: 18
upvote count: 18
type: Answer
has body: The command is "Add Javadoc Comment", or "Generate Element Comment" (Alt+Shift+J), and it is dependent on the one element currently selected. It cannot be applied to a all file. So if you select the all class through the project explorer view, you won't be able to generate all the missing comments from there. But from the Project Explorer, as Vitalii Fedorenko mentions in the comments, it works (just tested it): you should expand a class in the Package Explorer, select all elements and press Alt+Shift+J
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2767340
has comment: http://stackoverflow.com/comment/2800185

http://stackoverflow.com/a/2747779
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/2787141
has comment: http://stackoverflow.com/comment/2787524
accepted answer of: http://stackoverflow.com/q/2747663
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2747663
type: Answer
has body: You might set up a RESTful web service on the Java back-end. On the iPhone, package ("serialize") the data into an HTTP POST request however you want (e.g. JSON, XML, etc.) and send the request to the web service. For example, a JSON object might look something like: { "coordinates": [ { "x" : "100", "y" : "200" } , { "x" : "20", "y" : "40" } ] } The web service responds to the POST request by unserializing this JSON data into a Java-specific data container, such as an ArrayList&lt;Point&gt; collection. ASIHTTPRequest makes the iPhone side of this setup pretty easy, with its ASIFormDataRequest class. Java has JAX-WS that facilitates setting up RESTful services. There are numerous JSON encoding and decoding frameworks and libraries for Objective-C and Java in the aforementioned link.

http://stackoverflow.com/q/2620415
type: Question
tagged with: jakarta-ee
has title: Ejb lookup failing on WAS7.0 with NamingException
has answer: http://stackoverflow.com/a/3836578
score: 0
tagged with: websphere
has body: I have an application developed on RAD using WAS 6.0. I migrated the code to WID 7.0. After making some changes in the EJB modules(Had to remove the bnd.xmi file from each ejb module to deploy the application on Application Server)the application is running fine, but the EJB modules give the following error: NamingException has Occured While Getting Local Home javax.naming.NameNotFoundException:nullName ejb/com/igcc not found in context "local:". I am not able to figure out what changes do it need to make to run the application on WID. Any help is appreciated. Thanks, Ayush
answer count: 1
type: UnansweredQuestion
tagged with: java
tagged with: ejb-2.x

jspinner
tags question: http://stackoverflow.com/q/2738319
type: Tag
tag name: jspinner
tags question: http://stackoverflow.com/q/2724063

http://stackoverflow.com/a/2782368
downvote count: 0
has body: I think you mean this: import java.util.Arrays; ArrayList&lt;String&gt; veri1 = new ArrayList&lt;String&gt;(); String[] veri2 = {"Fatih", "Ferhat", "Furkan"}; veri1.addAll(Arrays.asList(veri2);
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/2781666
score: 1

http://stackoverflow.com/comment/2633413
score: 0
has text: @Martijn: A short in Java is still signed, though.
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/2621017

http://stackoverflow.com/a/48192967
downvote count: 0
answers question: http://stackoverflow.com/q/2768054
type: Answer
has body: You can try this: public static &lt;T&gt; T coalesce(T... t) { return Stream.of(t).filter(Objects::nonNull).findFirst().orElse(null); } Based on this response
upvote count: 9
score: 9

http://stackoverflow.com/comment/118125499
score: 0
type: AnswerComment
type: Comment
has text: @MuhammadAsaduzzaman you found the solution for this problem?
comment on: http://stackoverflow.com/a/2784272

http://stackoverflow.com/a/2759135
score: 5
upvote count: 5
has body: One of the important performance benefit of ConcurrentLinkedQueue comes from the fact that you don't worry about the tail when you update the head, and vice versa, right? This means basically that 2 threads can poll/offer at the same time without interfering (if the queue size wasn't 0, that is). This weren't the case if you had a counter. Even if it was a AtomicInteger which has good concurrency, you will still have increased possibility of having failed CAS operations because now you have this "hot spot" that you update every time you do poll/offer. Not entirely sure if the authors mean this when they say "asynchronous nature", but I think this is the biggest reason they don't have a counter like you suggested.
downvote count: 0
has comment: http://stackoverflow.com/comment/2790879
type: Answer
has comment: http://stackoverflow.com/comment/2791112
answers question: http://stackoverflow.com/q/2758966

http://stackoverflow.com/q/2650168
has title: Building vs. Compiling (Java)
linked to: http://stackoverflow.com/q/2310261
has body: Thinking that the answer to this is pretty obvious but here it goes: When I am working on a small project for school (in java) I compile it. On my coop we are using ant to build our project. I think that compiling is a subset of building. Is this correct? What is the difference between building and compiling? Related: What is the difference between compiling and building?
type: Question
answer count: 8
tagged with: build
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2650423
possible better answer: http://stackoverflow.com/a/2650263
tagged with: java
has answer: http://stackoverflow.com/a/39421424
has answer: http://stackoverflow.com/a/2650423
has answer: http://stackoverflow.com/a/2650199
has answer: http://stackoverflow.com/a/2650197
downvote count: 0
tagged with: compilation
favorite count: 0
has answer: http://stackoverflow.com/a/2650263
has answer: http://stackoverflow.com/a/59263712
upvote count: 173
score: 173
has answer: http://stackoverflow.com/a/2650192
has answer: http://stackoverflow.com/a/2650188

http://stackoverflow.com/a/2615777
has body: Writing code with empty catch blocks is very bad practice. Don't get in the habit of doing that. Although suihock captured the root cause of your problem, if you had printed the exception in the catch block: } catch (Exception e) { System.out.println("Got an exception: " + e.getMessage()); } ... you would have immediately found the cause of your problem.
upvote count: 3
answers question: http://stackoverflow.com/q/2615757
score: 3
downvote count: 0
type: Answer

http://stackoverflow.com/a/2659022
accepted answer of: http://stackoverflow.com/q/2659000
upvote count: 57
has comment: http://stackoverflow.com/comment/2676097
score: 56
type: Answer
has comment: http://stackoverflow.com/comment/33317021
downvote count: 1
answers question: http://stackoverflow.com/q/2659000
has body: You need to cast the URLConnection to HttpURLConnection and instruct it to not follow the redirects by setting HttpURLConnection#setInstanceFollowRedirects() to false. You can also set it globally by HttpURLConnection#setFollowRedirects(). You only need to handle redirects yourself then. Check the response code by HttpURLConnection#getResponseCode(), grab the Location header by URLConnection#getHeaderField() and then fire a new HTTP request on it.
has comment: http://stackoverflow.com/comment/2676111
has comment: http://stackoverflow.com/comment/6281588
type: AcceptedAnswer

http://stackoverflow.com/q/2685297
has body: I want to split and get rid of the comma's in a string like this that are entered into a textfield: 1,2,3,4,5,6 and then display them in a different textfield like this: 123456 here is what i have tried. String text = jTextField1.getText(); String[] tokens = text.split(","); jTextField3.setText(tokens.toString());
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2685311
has answer: http://stackoverflow.com/a/2685350
has answer: http://stackoverflow.com/a/2685314
answer count: 4
has title: How do I split text by "," and get rid of the "," in java?
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/2685313
score: 0

http://stackoverflow.com/comment/43723070
type: Comment
score: 7
type: AnswerComment
comment on: http://stackoverflow.com/a/2728140
has text: @dbemerlin Actually, they say you should lowercase the later letters only if the acronym is 3 or more letters, 2 letter acronyms are to remain capitalised, hence the .net class libraries has the `System.Net.IPAddress` class: http://msdn.microsoft.com/en-us/library/system.net.ipaddress%28v=vs.110%29.aspx (Also, I'm amazed nobody spotted this sooner, that class has existed since .Net framework 1.1)

http://stackoverflow.com/comment/2812497
score: 0
type: Comment
has text: Thanks too much, I've commented this conclusion at my blog: http://m-hewedy.blogspot.com/2010/05/beware-your-text-editor-encodes-your.html
type: AnswerComment
comment on: http://stackoverflow.com/a/2777482

http://stackoverflow.com/q/2707605
has comment: http://stackoverflow.com/comment/2731614
possible better answer: http://stackoverflow.com/a/2707611
has title: Java ArrayList Middle
has answer: http://stackoverflow.com/a/2707846
has comment: http://stackoverflow.com/comment/2731539
favorite count: 0
has answer: http://stackoverflow.com/a/2707611
accepted answer: http://stackoverflow.com/a/2707821
has comment: http://stackoverflow.com/comment/2731544
score: -3
tagged with: collections
downvote count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2707821
tagged with: java
type: Question
has body: How to find the middle of an ArrayList ?
tagged with: arraylist
answer count: 3
upvote count: 1

http://stackoverflow.com/a/2641272
type: Answer
score: 2
has body: A stack overflow error is caused by infinite recursion, that is, a method calling itself too many times. Your second code example doesn't seem to use recursion at all, so I don't think a stack overflow error is possible.
answers question: http://stackoverflow.com/q/2641262
downvote count: 0
upvote count: 2

http://stackoverflow.com/comment/122526796
comment on: http://stackoverflow.com/a/69159469
score: 1
type: AnswerComment
type: Comment
has text: Please use `Parcelable`, it's about 10x faster to pass through process boundaries than Serializable.

http://stackoverflow.com/comment/2804798
has text: XText might not help you *directly* but can offer some clues about the implementation of autocompletion in an Editor.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2771248

http://stackoverflow.com/q/2744909
tagged with: graphics2d
has body: This is the code I have, it actually works, not perfectly but it does, the problem is that the resized thumbnails are not pasting on the white Drawn rectangle, breaking the images aspect ratio, here is the code, could someone suggest me a fix for it, please? Thank you import java.awt.Color; import java.awt.Graphics2D; import java.awt.Image; import java.awt.RenderingHints; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import javax.imageio.ImageIO; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public class ImageScalerImageIoImpl implements ImageScaler { private static final String OUTPUT_FORMAT_ID = "jpeg"; // Re-scaling image public byte[] scaleImage(byte[] originalImage, int targetWidth, int targetHeight) { try { InputStream imageStream = new BufferedInputStream( new ByteArrayInputStream(originalImage)); Image image = (Image) ImageIO.read(imageStream); int thumbWidth = targetWidth; int thumbHeight = targetHeight; // Make sure the aspect ratio is maintained, so the image is not skewed double thumbRatio = (double)thumbWidth / (double)thumbHeight; int imageWidth = image.getWidth(null); int imageHeight = image.getHeight(null); double imageRatio = (double)imageWidth / (double)imageHeight; if (thumbRatio &lt; imageRatio) { thumbHeight = (int)(thumbWidth / imageRatio); } else { thumbWidth = (int)(thumbHeight * imageRatio); } // Draw the scaled image BufferedImage thumbImage = new BufferedImage(thumbWidth, thumbHeight, BufferedImage.TYPE_INT_RGB); System.out.println("Thumb width Buffered: " + thumbWidth + " || Thumb height Buffered: " + thumbHeight); Graphics2D graphics2D = thumbImage.createGraphics(); // Use of BILNEAR filtering to enable smooth scaling graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATI…
accepted answer: http://stackoverflow.com/a/2745182
favorite count: 0
tagged with: javax.imageio
type: Question
type: AnsweredQuestion
tagged with: java
score: 10
has answer: http://stackoverflow.com/a/2745182
has title: Java: Detecting image format, resize (scale) and save as JPEG
tagged with: image
upvote count: 10
answer count: 1
downvote count: 0
tagged with: resize

image
tags question: http://stackoverflow.com/q/2687522
tags question: http://stackoverflow.com/q/2662654
tags question: http://stackoverflow.com/q/2712371
tags question: http://stackoverflow.com/q/2713480
tags question: http://stackoverflow.com/q/2706054
tags question: http://stackoverflow.com/q/2637110
tags question: http://stackoverflow.com/q/2653954
tags question: http://stackoverflow.com/q/2772598
tags question: http://stackoverflow.com/q/2785053
tags question: http://stackoverflow.com/q/2755752
tags question: http://stackoverflow.com/q/2658505
tags question: http://stackoverflow.com/q/2735808
tags question: http://stackoverflow.com/q/2740059
tags question: http://stackoverflow.com/q/2704157
tags question: http://stackoverflow.com/q/2657827
tags question: http://stackoverflow.com/q/2684123
tags question: http://stackoverflow.com/q/2706310
tags question: http://stackoverflow.com/q/2690710
tags question: http://stackoverflow.com/q/2704050
tags question: http://stackoverflow.com/q/2682364
tags question: http://stackoverflow.com/q/2712099
tags question: http://stackoverflow.com/q/2711894
tags question: http://stackoverflow.com/q/2641386
tags question: http://stackoverflow.com/q/2597872
tags question: http://stackoverflow.com/q/2617962
tag name: image
tags question: http://stackoverflow.com/q/2629381
tags question: http://stackoverflow.com/q/2637323
tags question: http://stackoverflow.com/q/2631368
tags question: http://stackoverflow.com/q/2684866
tags question: http://stackoverflow.com/q/2600897
type: Tag
tags question: http://stackoverflow.com/q/2744909
tags question: http://stackoverflow.com/q/2636113

http://stackoverflow.com/q/2649322
type: AnsweredQuestion
tagged with: ioexception
score: 7
tagged with: java
has answer: http://stackoverflow.com/a/2649374
has body: All, I am trying to ensure that a file I have open with BufferedReader is closed when I catch an IOException, but it appears as if my BufferedReader object is out of scope in the catch block. public static ArrayList readFiletoArrayList(String fileName, ArrayList fileArrayList) { fileArrayList.removeAll(fileArrayList); try { //open the file for reading BufferedReader fileIn = new BufferedReader(new FileReader(fileName)); // add line by line to array list, until end of file is reached // when buffered reader returns null (todo). while(true){ fileArrayList.add(fileIn.readLine()); } }catch(IOException e){ fileArrayList.removeAll(fileArrayList); fileIn.close(); return fileArrayList; //returned empty. Dealt with in calling code. } } Netbeans complains that it "cannot find symbol fileIn" in the catch block, but I want to ensure that in the case of an IOException that the Reader gets closed. How can I do that without the ugliness of a second try/catch construct around the first? Any tips or pointers as to best practise in this situation is appreciated,
type: Question
tagged with: try-catch
has answer: http://stackoverflow.com/a/2649336
tagged with: bufferedreader
has answer: http://stackoverflow.com/a/2649342
linked to: http://stackoverflow.com/q/3044510
tagged with: exception
has title: How do I close a file after catching an IOException in java?
has answer: http://stackoverflow.com/a/2649330
linked to: http://stackoverflow.com/q/16363642
answer count: 7
possible better answer: http://stackoverflow.com/a/2649335
accepted answer: http://stackoverflow.com/a/2649342
has answer: http://stackoverflow.com/a/2649335
favorite count: 0
upvote count: 8
has answer: http://stackoverflow.com/a/2649364
has answer: http://stackoverflow.com/a/17734143
downvote count: 1

http://stackoverflow.com/q/2631791
has answer: http://stackoverflow.com/a/2631860
possible better answer: http://stackoverflow.com/a/2631853
has body: I prefer to have the exception handling logic further up in the call stack, near the main method. I like this approach... However, I created a thread where some of its method calls inside run() may throw exceptions. I would really like to see if there is a way that these exceptions can be thrown back up to the parent thread? The best I could think of is setting a variable inside the object that implements Runnable. This variable is a string that contains the Error Message, which then uses a class loader to correctly re-create the same exception in the parent thread. What I would like to know, is there a less messy way of getting what I want here? (to be able to make sure that any exception thrown in a child thread is handled with the same exception handling logic as though it was running in the main thread/code re-use).
upvote count: 11
favorite count: 0
tagged with: multithreading
has comment: http://stackoverflow.com/comment/2645190
score: 11
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2645176
tagged with: java
has answer: http://stackoverflow.com/a/2631835
has title: Java: Handling exceptions in child threads
type: Question
downvote count: 0
has answer: http://stackoverflow.com/a/2631853
answer count: 3
accepted answer: http://stackoverflow.com/a/2631835
tagged with: exception

http://stackoverflow.com/comment/18628764
has text: You are the 'java maverick', right? That would make your statement, "Found a good explanation and example at..." a dishonest attempt to conceal that you are linking to your own website. Your link does not seem to be important for the answer, anyway. I'm removing it, to avoid the answer being deleted as spam. Please read the FAQ on Self-Promotion before posting any more links to your website. also note that it is quite fine for you to put your website link in your profile.
type: AnswerComment
comment on: http://stackoverflow.com/a/13590687
type: Comment
score: 13

http://stackoverflow.com/a/2618049
accepted answer of: http://stackoverflow.com/q/2604965
type: Answer
has body: Without any knowledge of your specific scene and what sort of objects you are rendering, the 27 cubes sounds like the "correct but not optimal" way of doing it. However, if you cant think of anything else, you can at least perform frustum culling on your camera first, which means finding out which of the 27 cubes are currently inside the cameras field of view. Then you never have to draw more than 6 of these cubes, plus the current cube you are in. Even less if you have a narrow field of view. That is assuming that you can only see a maximum of 1 cube into the distance... Otherwise you will have to do rendering to texture.
score: 0
answers question: http://stackoverflow.com/q/2604965
type: AcceptedAnswer

http://stackoverflow.com/comment/2754334
type: Comment
type: QuestionComment
has text: this is completely wrong and so is bkkbrad's answer. It's actually quite frightening to see so many people completely wrong on that one (+1 only to bkail's answer). A Java *char* does **not**, I repeat **A JAVA CHAR DOES NOT** represent a character anymore since Java 1.4 / Unicode 3.1. *String.value(char)* and wrapping "char"* and whatnots are all methods from the nineties. The world moved on and it's been a very long time that Unicode has more than 65 536 codepoints. Use "int", get "char" out of your mind because Java char is broken beyond repair. ♩ ♩ ♩ ♩
score: 3
comment on: http://stackoverflow.com/q/2726071

http://stackoverflow.com/a/2762191
has comment: http://stackoverflow.com/comment/2794364
upvote count: 2
has body: I need pass by reference To be strictly precise, Java does not have pass by reference. There's only one passing mechanism in Java, and that's pass by value. In the case of objects, the thing that's being passed is not the object itself, which lives on the heap. It's the reference to the object that's passed by value. It might sound like a nitpick, but it's an important one. I don't see what this has to do with refactoring. If you need to create new types just to be returned, by all means do so. I'd bet that you really don't have an object model that reflects the problem at hand, which is why you have this refactoring problem. Doesn't sound very object-oriented to me, especially after reading your edit.
has comment: http://stackoverflow.com/comment/2794424
answers question: http://stackoverflow.com/q/2762171
type: Answer
has comment: http://stackoverflow.com/comment/2794393
has comment: http://stackoverflow.com/comment/2794366
downvote count: 0
has comment: http://stackoverflow.com/comment/2794401
score: 2
has comment: http://stackoverflow.com/comment/2794527

http://stackoverflow.com/comment/14356254
type: AnswerComment
comment on: http://stackoverflow.com/a/10988353
has text: I think that precisely breaks the good practice of not using exceptions for control flow stated in polygenelubricants answer. Don't you think?
type: Comment
score: 3

http://stackoverflow.com/a/2694600
downvote count: 0
answers question: http://stackoverflow.com/q/2694566
has comment: http://stackoverflow.com/comment/2716507
score: 2
has body: You're trying to invoke an instance method on the class it self. You should do: Random rand = new Random(); int a = 0 ; while (!done) { int a = rand.nextInt(10) ; .... Instead As I told you here stackoverflow.com/questions/2694470/whats-wrong...
upvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/56135151
has comment: http://stackoverflow.com/comment/2716338
has comment: http://stackoverflow.com/comment/56164105

http://stackoverflow.com/q/2699750
favorite count: 0
has comment: http://stackoverflow.com/comment/2723728
answer count: 0
type: UnansweredQuestion
has body: I have two entities: "Parent" & "Child" Child is mapped in Parent like this: Code: <column name="CHILD_ID" precision="10" scale="0" not-null="true" /> and Child has an Enum type mapped like this: Code: <column name="TOY_TYPE" length="100" /> org.demo.ToyType mapped as a "String" in CHILD.TOY_TYPE column Everything works fine but I cannot do this: Code: DetachedCriteria dc = DetachedCriteria.forClass(Parent.class); dc.add(Restrictions.and( Restrictions.eq("child.id", childId), Restrictions.eq("child.toyType", ToyType.CAR))); dc.setProjection(Projections.rowCount()); int count = DataAccessUtils.intResult(getHibernateTemplate(). findByCriteria(dc)); because I got: nested exception is org.hibernate.QueryException: could not resolve property: child.toyType of: org.demo.Parent so it looks like it cannot solve: parent->child->toyType probably because ToyType has not an own "Entity", but it is embedded. Is there any workaround for it? I need to continue using DetachedCriteria as it will be "decorated" in other places of the code. So I'm wondering if I can solve that always using DetachedCriteria. Thanks, Rand
has title: Enum mapping and criteria
upvote count: 1
tagged with: enums
tagged with: criteria
tagged with: java
tagged with: hibernate
tagged with: detachedcriteria
type: Question
downvote count: 0
has comment: http://stackoverflow.com/comment/2727247
score: 1

http://stackoverflow.com/comment/2791396
has text: @FarmBoy They depend on your app server and its configuration. What app server are you using?
comment on: http://stackoverflow.com/a/2759542
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2687539
type: Comment
has text: Are you sure it is a problem of "understanding" (unrecognized XML entities) and not just "display" (application font missing certain Unicode code-points)? If it is the former, the answer is to clean the XML before reading it in; if it is the latter, your problem can be solved by choosing (or bundling) another font with more code-points.
type: QuestionComment
comment on: http://stackoverflow.com/q/2650259
score: 3

http://stackoverflow.com/a/2627760
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/2627739
has body: The former respects your locale settings (which seems to use comma for thousand separator).
downvote count: 0
type: Answer

http://stackoverflow.com/comment/2716572
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/2693780
type: Comment
has text: Then try remote services via separate APKs. Or content providers via separate APKs. Or broadcast `Intents` via separate APKs. Or modify the firmware and build your own device with your own libraries in it. The `PlatformLibrary` is for modifying the operating system, through C/C++ and JNI, which is precisely what your question's subject says you do not want.

http://stackoverflow.com/comment/2665968
score: 0
type: AnswerComment
has text: @GregS you're probably right. Feniix, would you let us know your results? and/or what was the solution you use?
type: Comment
comment on: http://stackoverflow.com/a/2642107

http://stackoverflow.com/comment/2656605
type: AnswerComment
has text: @Zeratul How are they packaged exactly?
type: Comment
comment on: http://stackoverflow.com/a/2641802
score: 0

http://stackoverflow.com/q/2690147
tagged with: python
answer count: 4
score: 8
has title: What is it in Java standard library that Python's lacks?
type: UnansweredQuestion
has body: I hear that the Java standard library is larger than that of Python. That makes me curious about what is missing in Python's?
has answer: http://stackoverflow.com/a/2690202
has comment: http://stackoverflow.com/comment/2711321
has comment: http://stackoverflow.com/comment/2712203
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/2711547
has comment: http://stackoverflow.com/comment/2711519
downvote count: 0
has answer: http://stackoverflow.com/a/2690215
favorite count: 0
has comment: http://stackoverflow.com/comment/2711533
has answer: http://stackoverflow.com/a/2690259
upvote count: 8
has comment: http://stackoverflow.com/comment/2712706
has answer: http://stackoverflow.com/a/2690159

http://stackoverflow.com/comment/2761173
has text: @Carl: Still no luck ... the problem remains. I still wonder what the Java exec does different than I do on console (especially after your adjustment).
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2715906

http://stackoverflow.com/comment/4619666
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/3858471
has text: @Chris : you can still have web.xml but do not define the async servlet into it and let annotation kick in for this servlet. However I have not explored on possibility of asyncSupported=true attribute in web.xml

http://stackoverflow.com/q/2713019
tagged with: android
type: AnsweredQuestion
score: 3
has comment: http://stackoverflow.com/comment/2737903
downvote count: 0
tagged with: java
linked to: http://stackoverflow.com/q/476111
tagged with: blackberry
type: Question
has answer: http://stackoverflow.com/a/2713057
accepted answer: http://stackoverflow.com/a/2713057
has answer: http://stackoverflow.com/a/2720567
has title: Is there any language other than Java that will work as ubiquitous on mobile?
tagged with: mobile
has body: I'm trying to write a rogue-like game for my blackberry and hopefully any other phone that supports some sort of JVM. Because I use Java in my job I'm looking to write the game in another language but I cannot find a language that will work on multiple phones. Am I stuck with Java?
linked to: http://stackoverflow.com/q/318887
tagged with: programming-languages
upvote count: 3
has answer: http://stackoverflow.com/a/2718760
possible better answer: http://stackoverflow.com/a/2713052
has answer: http://stackoverflow.com/a/2713052
favorite count: 0
answer count: 5
has answer: http://stackoverflow.com/a/2718774

http://stackoverflow.com/comment/84276982
score: 0
comment on: http://stackoverflow.com/a/20056245
type: Comment
has text: The problem of usage of Event Bus is when target Activity is recreated due to rotation for example. In this case target Activity has not access to passed object because this object was consumed from the bus by earlier call.
type: AnswerComment

http://stackoverflow.com/a/2681057
answers question: http://stackoverflow.com/q/2681029
has body: Enums are good if the only hold static data and very minimal logical (preferably no logic at all). If your objects are meant to have different behaviors depending on their kind, it's usually a good idea to implement them as subclasses. As others mentioned, you're very likely to add attributes to your objects and these attributes won't make sense for all kinds. Eg. a color attribute makes sense for a weapon but not for a spell. In that case weapon and spell should not be in the same enum.
downvote count: 0
upvote count: 8
type: Answer
score: 8

http://stackoverflow.com/a/2768857
answers question: http://stackoverflow.com/q/2767695
has comment: http://stackoverflow.com/comment/2802131
downvote count: 0
has comment: http://stackoverflow.com/comment/2801939
has body: Best option to this common problem: Absolute path for the location outside the jar/war. The the app itself can be deployed anywhere, but the host should have a common file area such as "/common/files/someApplication" Better yet is to have a configuration to specify (during build or at runtime) which path to use. E.g. dev build would use "/dev/myprojects/someApplication" Not as good solution: Deploy as exploded war file. Read and write is not a problem, but now you've cause a deployment dependency.
type: Answer
score: 1
upvote count: 1

http://stackoverflow.com/a/2615989
answers question: http://stackoverflow.com/q/2615939
has comment: http://stackoverflow.com/comment/3819228
type: Answer
score: 3
upvote count: 3
downvote count: 0
has body: I'm pretty sure you have to. You can always convert to Blob/ShortBlob for storage only and convert it back into a byte[] immediately after you restore it.

http://stackoverflow.com/a/2785669
has comment: http://stackoverflow.com/comment/2823939
type: Answer
has comment: http://stackoverflow.com/comment/2821220
score: 2
has comment: http://stackoverflow.com/comment/2821807
upvote count: 2
has comment: http://stackoverflow.com/comment/2830707
has comment: http://stackoverflow.com/comment/2821304
has body: Now, the problem that I have been observing is that this part of the code, is slowing down considerably as soon as the list has objects more than 10000.I understand arraylist is doing a o(N) search. The algorithm you posted is actually worse than O(N) Iterating through the input list lstEntities - O(N) within this loop, you are calling ArrayList.indexOf(T) which has to scan the list - O(N) again You algorithm is actually O(N^2) since you are potentially scanning the list twice within a loop. It sounds like you what you want to do is actually two operations: From the input List, remove any duplicates When you find duplicates, "merge" the entities. You can do this by scanning the list just once, rather than in nested loops. I would recommend breaking up your Entity to move the fields that "identify" an Entity into another type, such as ID, or at the very least add a getID() method which can return these fields grouped into a single type. This way you can easily build a Map between the two types to be able to merge entities with "duplicate" identities. This might look something like this: Map&lt;ID, Entity&gt; map = new HashMap&lt;ID, Entity&gt;(inputList.size()); for (Entity e : inputList) { Entity existing = map.get(e.getID()); if (existing == null) { //not in map, add it map.put(e.getID(), e); } else { existing.merge(e); } } Iterating through the list is O(n) while HashMap.get(K) is a constant-time operation.
has comment: http://stackoverflow.com/comment/2821315
accepted answer of: http://stackoverflow.com/q/2785486
answers question: http://stackoverflow.com/q/2785486
has comment: http://stackoverflow.com/comment/2821607
has comment: http://stackoverflow.com/comment/2828868
has comment: http://stackoverflow.com/comment/2821177
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2848932
downvote count: 0

http://stackoverflow.com/comment/2657829
type: AnswerComment
has text: Positioning pointer to last node would need iteration anyways as its a singly linked list
type: Comment
comment on: http://stackoverflow.com/a/2642886
score: 0

http://stackoverflow.com/q/2647407
duplicate of: http://stackoverflow.com/q/1915166
accepted answer: http://stackoverflow.com/a/2647613
downvote count: 0
has title: SQL (Java, h2): What's the best way to retrieve the unique ID of the single item I just inserted into my database?
score: 13
type: AnsweredQuestion
tagged with: sql
tagged with: jdbc
linked to: http://stackoverflow.com/q/1376218
favorite count: 0
type: Question
has answer: http://stackoverflow.com/a/2647436
answer count: 2
has answer: http://stackoverflow.com/a/2647613
tagged with: unique-id
upvote count: 13
has body: My current method is this: SELECT TOP 1 ID FROM DATAENTRY ORDER BY ID DESC This assumes the latest inserted item always has the highest unique ID (primary key, autoincrementing). Something smells wrong here. Alternatives?
possible better answer: http://stackoverflow.com/a/2647436
linked to: http://stackoverflow.com/q/1915166
tagged with: java
tagged with: h2
has comment: http://stackoverflow.com/comment/50902032

http://stackoverflow.com/comment/2796540
comment on: http://stackoverflow.com/q/2764031
score: 0
type: Comment
type: QuestionComment
has text: You must be leaving something out. @ isn't a special character neither in HTML nor in Java strings.

http://stackoverflow.com/a/2691451
type: Answer
score: 2
has body: Your toolchain is supposed to generate both a .JAR file and a .JAD file. As per the J2ME specifications, phones don't always have to allow the installation of the .JAR file. You should deploy the .JAD file instead and make sure the .JAR is in an accessible location (handset storage or mobile network). The .JAD file is supposed to contain the location of the .JAR file so the handset MIDlet installer can retrieve it. EDIT: There are a number of reasons why a phone would refuse to install a .JAD file. It could be just plain wrong and not compliant with the MIDP specifications. It could be signed by a certificate the phone doesn't like It could use the wrong version of the J2ME configuration or profile. It could contain permissions that the phone doesn't recognize ... The best way to have your question answered would be to add the content of the .JAD file, the content of the manifest file packaged inside the .JAR file and the brand and model name of the handset you are trying to install your application on.
answers question: http://stackoverflow.com/q/2691177
has comment: http://stackoverflow.com/comment/2712651
downvote count: 0
upvote count: 2

http://stackoverflow.com/comment/2627342
comment on: http://stackoverflow.com/q/2615745
score: 0
has text: I wrote the above code.i have a textbox but it has empty but when it fills with text then I want to show an alert but not executed. is there any opinion
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/2650105
has text: You need to escape the quotes: `String regex = "(?<=lastStop=[\"']?)[^\"']*";`
score: 0
comment on: http://stackoverflow.com/a/2636069
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2764901
comment on: http://stackoverflow.com/q/2736698
has text: Is it absolutely necessary to change how the values are stored? If you have sufficient abstraction, then you can just change the access strategy and not have to change the data structure at all.
score: 1
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2780986
has body: I want to create a global custom session validator for my restlet. One sessionkey will be passed through the header and using that the session is validated . IS there any way to do that globally instead of putting the same code in every resource class ?
type: UnansweredQuestion
tagged with: web-services
tagged with: java
type: Question
tagged with: restlet
score: 0
has answer: http://stackoverflow.com/a/5730291
has title: Creating a global custom session validator in restlet
answer count: 1

http://stackoverflow.com/comment/2807666
has text: @justk: yes, you can get two keys in one bucket, and then equals() is used to distinguish between them. That's why it's essential that hashCode() and equals() are compatible.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2773861
type: Comment

http://stackoverflow.com/comment/110028427
type: Comment
has text: LocalDate has a method to get DayOfWeek. Check that out.
comment on: http://stackoverflow.com/a/23932946
score: 0
type: AnswerComment

http://stackoverflow.com/a/3011368
answers question: http://stackoverflow.com/q/2622591
has body: Actually, an Iterator comes from an Iterable, not a Collection, whatever the JavaDoc API says. The latter extends the former, and that's why it can generate an Iterator as well, but it's perfectly reasonably for an Iterable not to be a Collection. In fact, there are even a few Java classes which implement Iterable but not Collection. Now, as for expectations... of course an infinite iterator must not be made available without a clear indication that this happens to be the case. But, sometimes, expectations can be deceiving. For instance, one might expect an InputStream to always come to an end, but that really isn't a requirement of it. Likewise, an Iterator returning lines read from such a stream might never end.
type: Answer
score: 3
upvote count: 3
downvote count: 0

http://stackoverflow.com/a/2779164
score: 4
has comment: http://stackoverflow.com/comment/2814168
has comment: http://stackoverflow.com/comment/2814094
has comment: http://stackoverflow.com/comment/2814046
has comment: http://stackoverflow.com/comment/2814160
has comment: http://stackoverflow.com/comment/2814065
type: Answer
has comment: http://stackoverflow.com/comment/2814148
upvote count: 4
has comment: http://stackoverflow.com/comment/2814118
has comment: http://stackoverflow.com/comment/2814051
has comment: http://stackoverflow.com/comment/2814110
has comment: http://stackoverflow.com/comment/2814072
has body: The solution is simple: make Term immutable. Effective Java 2nd Edition, Item 15: Minimize mutability: Immutable objects are simple. Immutable objects can be shared freely. Immutable objects make great building blocks for other objects. Classes should be immutable unless there's a very good reason to make them mutable. If a class cannot be made immutable, limit its mutability as much as possible. Make every field final unless there is a compelling reason to make it non-final Something as simple and small as Term really should be made immutable. It's a much better overall design, and you wouldn't have to worry about things like you were asking in your question. See also What is meant by immutable? This advice becomes even more compelling since the other answers are suggesting that you use clone(). Effective Java 2nd Edition, Item 11: Override clone judiciously Because of the many shortcomings, some expert programmers simply choose to never override the clone method and never invoke it except, perhaps, to copy arrays. From an interview with author Josh Bloch: If you've read the item about cloning in my book, especially if you read between the lines, you will know that I think clone is deeply broken. DO NOT make Term implements Cloneable. Make it immutable instead. See also How to properly override clone method? Why people are so afraid of using clone() (on collection and JDK classes) ?
answers question: http://stackoverflow.com/q/2779067
has comment: http://stackoverflow.com/comment/2813946
downvote count: 0

http://stackoverflow.com/a/2646067
downvote count: 0
has body: setValue(BigInteger.valueOf(123L));
answers question: http://stackoverflow.com/q/2646049
upvote count: 3
type: Answer
score: 3

http://stackoverflow.com/a/2752020
score: 5
has body: I'm working on a SOAP service using JAXWS. I'd like to be able to have users log-in and in my service know which user is issuing a command. In other words, have some session handling. Conventional Web services are stateless in nature, there is no session handling in web services (which has by the say nothing to do with identifying the caller). If you want to require your users to be authenticated to call a service, the traditional approach is to: Expose an "authentication" web service (passing user credentials) that returns an authentication token. Have the users call this authentication first. Have the users pass the token in a custom header on subsequent calls of "business" web services. On the server side: Reject any call that doesn't contain a valid token. Invalidate tokens after some time of inactivity You can implement a custom solution for this approach (this is a highly interoperable solution). Or you can use WS-Security/UsernameTokens that provides something similar out of the box. WS-Security is a standard (Metro implements it), it isn't "framework" specific.
type: AcceptedAnswer
upvote count: 5
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2751949
type: Answer
has comment: http://stackoverflow.com/comment/2782829
answers question: http://stackoverflow.com/q/2751949

http://stackoverflow.com/a/2759201
has comment: http://stackoverflow.com/comment/2811375
answers question: http://stackoverflow.com/q/2758971
has comment: http://stackoverflow.com/comment/112912613
score: 0
type: Answer
has body: The only way to do this without your loop would be: Object array[] = new Object[list.size() + 1]; Object oldValues[] = list.toArray(); Object chk = new Object(); array[0] = chk; System.arrayCopy(oldValues, 0, array, 1, oldValues.length); System.arrayCopy is a bit faster than looping (not too much, but faster nevertheless), although the performance boost would probably be mitigated by the toArray, depending on the implementation of your List. All in all, what you have is a decent approach as long as List.get(int) is an acceptable cost. (If it's O(n), you'll end up with O(n^2) for your operation, which is suboptimal when Frank's solution is O(n).)

http://stackoverflow.com/a/2608435
has comment: http://stackoverflow.com/comment/76668499
type: Answer
upvote count: 16
answers question: http://stackoverflow.com/q/2608394
score: 16
accepted answer of: http://stackoverflow.com/q/2608394
has comment: http://stackoverflow.com/comment/136480514
has comment: http://stackoverflow.com/comment/2618676
type: AcceptedAnswer
downvote count: 0
has body: It's a fairly elaborate algorithm, detailed in JLS 15.12. But the part that is relevant here is 15.12.2, which says "the most specific one is chosen." Both the Object and String overloads are "accessible and applicable" (the String is applicable because a null literal is a reference of all types), and the String is more specific. EDIT: Corrected section, per Syntactic.

http://stackoverflow.com/a/2597812
score: 88
has comment: http://stackoverflow.com/comment/18409714
downvote count: 1
answers question: http://stackoverflow.com/q/2597271
type: Answer
has body: You can try @Rule annotation. Here is the example from the docs: public static class UsesExternalResource { Server myServer = new Server(); @Rule public ExternalResource resource = new ExternalResource() { @Override protected void before() throws Throwable { myServer.connect(); }; @Override protected void after() { myServer.disconnect(); }; }; @Test public void testFoo() { new Client().run(myServer); } } You just need to create FileResource class extending ExternalResource. Full Example import static org.junit.Assert.*; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExternalResource; public class TestSomething { @Rule public ResourceFile res = new ResourceFile("/res.txt"); @Test public void test() throws Exception { assertTrue(res.getContent().length() &gt; 0); assertTrue(res.getFile().exists()); } } import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.Charset; import org.junit.rules.ExternalResource; public class ResourceFile extends ExternalResource { String res; File file = null; InputStream stream; public ResourceFile(String res) { this.res = res; } public File getFile() throws IOException { if (file == null) { createFile(); } return file; } public InputStream getInputStream() { return stream; } public InputStream createInputStream() { return getClass().getResourceAsStream(res); } public String getContent() throws IOException { return getContent("utf-8"); } public String getContent(String charSet) throws IOException { InputStreamReader reader = new InputStreamReader(createInputStream(), Charset.forName(charSet)); char[] tmp = new char[4096]; StringBuilder b = new StringBuilder(); try { while (true) { int len = reader.read(tmp); if (len &lt; 0) { break; } b.append(tmp, 0, len); } reader.close(); } finally { reader.close(); } return b.toString(); } @Override protected void…
upvote count: 89

http://stackoverflow.com/comment/64335451
type: Comment
comment on: http://stackoverflow.com/a/2629393
score: 0
type: AnswerComment
has text: "The references however still point to that object, despite its movement within memory." - I am extremely new at this, but is it possible that the reference you speak of can be another pointer?

http://stackoverflow.com/a/2741616
answers question: http://stackoverflow.com/q/2734767
type: Answer
score: 0
has body: One thing to realize is that in JavaScript you're always dealing with an event pump: some browser event happens, or a timer expires, and then a chunk of JavaScript gets executed. With that execution model in mind, you don't really want to think of having a periodic batch and send process going on - what you want to do instead is batch together all the calls that happen in one event pump (the chunk of javascript executing in response to one event from the browser) and send them off. This is done by changing your rpc code so that every call queues up calls with parameters and callback functions into a global array, and if it's queueing up the first call it also schedules with setTimeout(..., 0) a function that will send off everything in the queue and clear the array. Start with that and then you can experiment later with other execution models, like firing off the first request right when you get it and sending everything else in a batch after the current event pump is done.
has comment: http://stackoverflow.com/comment/2776328

http://stackoverflow.com/comment/2697612
type: Comment
has text: +1, this question sounds like a free claim, it doesn't provide any fact or data.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/2678262

http://stackoverflow.com/comment/2614749
type: Comment
score: 1
comment on: http://stackoverflow.com/q/2604875
has text: Please, please use *code* blocks to set aside pieces of code.
type: QuestionComment

http://stackoverflow.com/a/2727408
has comment: http://stackoverflow.com/comment/2755939
score: 0
answers question: http://stackoverflow.com/q/2727353
type: Answer
has comment: http://stackoverflow.com/comment/2755181
has comment: http://stackoverflow.com/comment/2755124
has body: My view is that is when you are working with a managed runtime, such as Java or .NET you really should not (and it's good!) concern yourself with things like your particular question. Only because you are completely disconnected from the underlying operating system and its native APIs. All you have to know is that you call Closable.close() in your finally block and your resource will always be freed.

http://stackoverflow.com/q/2662677
type: Question
score: 9
answer count: 1
has comment: http://stackoverflow.com/comment/2680451
has title: JPA 2.0, hibernate 3.5, jars & persistence.xml location
tagged with: jpa-2.0
upvote count: 9
has body: I'm building a desktop application using hibernate 3.5 &amp; JPA 2.0. I have 2 jars, the lib, which defines every entity and DAO, packages looks like this : org.my.package.models org.my.package.models.dao org.my.package.models.utils In org.my.package.utils I defined my hibernate utility class for getting EM &amp; EMF instances, which means the lib is bound to a Persistence Unit name but that's not a problem for now (anyway you can recommend me a better way to manage that) the second jar is built as follow: org.my.package.app META-INF is defined on the root of the project which means in my jar I can find this directories directly in the root: META-INF/ META-INF/persistence.xml org/ org/my/ ... org/my/package/app/Main.class When I run the app, hibernate doesn't managed to find persistence.xml it throws an exception something like "package or class for PersistenceUnitName not found". SLF4J: The requested version 1.5.11 by your slf4j binding is not compatible with [1.5.5, 1.5.6, 1.5.7, 1.5.8] SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details. 3 [main] INFO org.hibernate.cfg.annotations.Version - Hibernate Annotations 3.5.0-Final 25 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.5.0-Final 28 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found 33 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist 41 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling 153 [main] INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.2.0.Final 160 [main] INFO org.hibernate.ejb.Version - Hibernate EntityManager 3.5.0-Final Exception in thread "main" java.lang.ExceptionInInitializerError at Main.main(Main.java:171) Caused by: javax.persistence.PersistenceException: [PersistenceUnit: PMMPU] class or package not found at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1316) at org.hibernate.ejb.Ejb3Configuration.…
has comment: http://stackoverflow.com/comment/2682075
favorite count: 0
downvote count: 0
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2680444
tagged with: java
tagged with: hibernate
has answer: http://stackoverflow.com/a/2663213
tagged with: orm
accepted answer: http://stackoverflow.com/a/2663213
tagged with: persistence.xml

http://stackoverflow.com/comment/2734535
has text: @Rich That'd be a damn good coding competition for SO :)
type: Comment
score: 1
type: QuestionComment
comment on: http://stackoverflow.com/q/2710015

http://stackoverflow.com/comment/2670890
has text: Would serialization (Arrays in Java are serializable) work? See e.g. http://www.rgagnon.com/javadetails/java-0470.html
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2654145
score: 0

bytecode-manipulation
type: Tag
tags question: http://stackoverflow.com/q/2773892
tag name: bytecode-manipulation
tags question: http://stackoverflow.com/q/2697657

http://stackoverflow.com/a/2602084
has comment: http://stackoverflow.com/comment/39375449
has comment: http://stackoverflow.com/comment/29824350
downvote count: 0
has comment: http://stackoverflow.com/comment/2623200
answers question: http://stackoverflow.com/q/2599864
upvote count: 1
has body: Q1: Mark the field with @Transient. This is really a JPA question more than a Roo question. Q2: You can define the field in the roo shell, but I don't believe there is a transient option in the Roo shell. You have to Mark the field with the @Transient option after you generate it with the roo shell. BTW Roo rocks.
type: Answer
score: 1

http://stackoverflow.com/comment/2763440
score: 1
comment on: http://stackoverflow.com/q/2735323
has text: This is actually a general Java question.
type: QuestionComment
type: Comment

http://stackoverflow.com/a/2691717
has comment: http://stackoverflow.com/comment/2719394
has body: As far as I know there is no exactly such feature in Java. JVM doesn't know about debugger if it is not attached. For .Net this is Windows who does some favor in this aspect. However, there is assert that is intended for such usage. It will raise java.lang.AssertionError that is not an Exception and thus shouldn't be handled by usual catches. If your debugger is set up to handle unhandled exceptions (or rather Throwables) it will catch such case.
type: Answer
upvote count: 1
score: 1
accepted answer of: http://stackoverflow.com/q/2691539
answers question: http://stackoverflow.com/q/2691539
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2719981

http://stackoverflow.com/q/2765540
has answer: http://stackoverflow.com/a/2765578
favorite count: 0
has answer: http://stackoverflow.com/a/2767290
answer count: 4
has body: How can I modify this run method to not only print the srting in the output window, but also write to a file for example outfile.txt in project directory. Also each string should be on a separate line in the file. So I have already created a file in the project directory called outfile.txt A the moment the code is print fine on window but not printing in the text file here is the code # public void run() throws IOException { Scanner sc = new Scanner(System.in); boolean cont = true; while (cont) { System.out.println("Enter text"); String s = sc.nextLine(); if ("*".equals(s)) { cont = false; } else { String result = shorthand(s); System.out.println(result); PrintWriter pw = new PrintWriter("outfile.txt"); pw.println(result); } } }
type: UnansweredQuestion
upvote count: 1
has title: Write to a file in java
type: Question
has answer: http://stackoverflow.com/a/2765584
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/2765577
downvote count: 0

spring
tags question: http://stackoverflow.com/q/2684171
tags question: http://stackoverflow.com/q/2653958
tags question: http://stackoverflow.com/q/2671336
tags question: http://stackoverflow.com/q/2689625
tags question: http://stackoverflow.com/q/2688276
tags question: http://stackoverflow.com/q/2724341
tags question: http://stackoverflow.com/q/2669932
tags question: http://stackoverflow.com/q/2689989
tags question: http://stackoverflow.com/q/2724855
tags question: http://stackoverflow.com/q/2624724
tags question: http://stackoverflow.com/q/2738706
tags question: http://stackoverflow.com/q/2663051
tags question: http://stackoverflow.com/q/2706630
tags question: http://stackoverflow.com/q/2681364
tags question: http://stackoverflow.com/q/2635752
tags question: http://stackoverflow.com/q/2639729
tags question: http://stackoverflow.com/q/2769467
tags question: http://stackoverflow.com/q/2635406
tags question: http://stackoverflow.com/q/2721644
tags question: http://stackoverflow.com/q/2644330
tags question: http://stackoverflow.com/q/2744875
tags question: http://stackoverflow.com/q/2654124
tags question: http://stackoverflow.com/q/2684885
tags question: http://stackoverflow.com/q/2699107
tags question: http://stackoverflow.com/q/2763646
tags question: http://stackoverflow.com/q/2623542
tags question: http://stackoverflow.com/q/2660485
tags question: http://stackoverflow.com/q/2649632
tags question: http://stackoverflow.com/q/2661224
tags question: http://stackoverflow.com/q/2766190
tags question: http://stackoverflow.com/q/2753464
tags question: http://stackoverflow.com/q/2732280
type: Tag
tags question: http://stackoverflow.com/q/2745471
tags question: http://stackoverflow.com/q/2624015
tags question: http://stackoverflow.com/q/2739983
tags question: http://stackoverflow.com/q/2621319
tags question: http://stackoverflow.com/q/2751733
tags question: http://stackoverflow.com/q/2662450
tags question: http://stackoverflow.com/q/2673678
tags question: http://stackoverflow.com/q/2727271
tags question: http://stackoverflow.com/q/2624177
tags question: http://stackoverflow.com/q/2723899
tags question: http://stackoverflow.com/q/2604931
tags question: http://stackoverflow.com/q/2636432
tags question: http://stackoverflow.com/q/2753387
tags question: http://stackoverflow.com/q/2727780
tags question: http://stackoverflow.com/q/2737420
tags question: http://stackoverflow.com/q/2647057
tags question: http://stackoverflow.com/q/2668997
tags question: http://stackoverflow.com/q/2705649
tags question: http://stackoverflow.com/q/2759188
tags question: http://stackoverflow.com/q/2662013
tags question: http://stackoverflow.com/q/2605976
tags question: http://stackoverflow.com/q/2634669
tags question: http://stackoverflow.com/q/2763956
tags question: http://stackoverflow.com/q/2652092
tags question: http://stackoverflow.com/q/2641338
tags question: http://stackoverflow.com/q/2706100
tags question: http://stackoverflow.com/q/2763279
tags question: http://stackoverflow.com/q/2604875
tags question: http://stackoverflow.com/q/2659839
tags question: http://stackoverflow.com/q/2781573
tags question: http://stackoverflow.com/q/2655784
tags question: http://stackoverflow.com/q/2753928
tags question: http://stackoverflow.com/q/2690146
tags question: http://stackoverflow.com/q/2751603
tags question: http://stackoverflow.com/q/2773660
tags question: http://stackoverflow.com/q/2614989
tags question: http://stackoverflow.com/q/2730354
tags question: http://stackoverflow.com/q/2720929
tags question: http://stackoverflow.com/q/2657432
tags question: http://stackoverflow.com/q/2729521
tags question: http://stackoverflow.com/q/2733947
tags question: http://stackoverflow.com/q/2679918
tags question: http://stackoverflow.com/q/2713033
tags question: http://stackoverflow.com/q/2674697
tags question: http://stackoverflow.com/q/2620226
tags question: http://stackoverflow.com/q/2694105
tags question: http://stackoverflow.com/q/2760582

http://stackoverflow.com/comment/2753543
has text: Thanks Jason, I'll take a look at the Run Configurations dialog. I was unable to create a second heap dump file for a different process, which would seem to contradict this naming scheme.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2726328

http://stackoverflow.com/comment/99201814
has text: @StephenC ... but only when needed, i.e. probably just in a few classes. This new "logging facade" is after all just a thin shim that can even be code-duplicated. (Maybe slf4j has this facility now? I haven't seriously coded in some time)
type: Comment
comment on: http://stackoverflow.com/a/7829534
type: AnswerComment
score: 0

http://stackoverflow.com/comment/2616994
comment on: http://stackoverflow.com/q/2605287
score: 0
type: Comment
type: QuestionComment
has text: Yes. And I think it's high time to learn CSS. @anandhinaveen: don't focus too much on JSF source code while doing CSS. CSS doesn't see anything from JSF source code. Rightclick page in webbrowser and view HTML source. That's what CSS (and Javascript) sees. You can find here a good CSS tutorial/reference: http://www.w3schools.com/css/default.asp You can use Firebug and/or WDT to save a lot of work in editing/testing/debugging CSS.

http://stackoverflow.com/a/2609274
answers question: http://stackoverflow.com/q/2609227
score: 1
has body: In your example the correct method is called because polymorphically the instance of B appears like an instance of A. The method can be located by examining the runtime type of the object; that is, B; as opposed to the compile-time type of the object reference, A. The other important part is the signature of method - these must always match (polymorphically of course). This differs from dynamic languages because in those there is essentially no compile-time for the object - and everything must be resolved at runtime.
upvote count: 1
type: Answer
downvote count: 0

http://stackoverflow.com/comment/2741949
comment on: http://stackoverflow.com/a/2716113
has text: Thank you ring bearer, will look into this further.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/2614989
tagged with: eclipselink
tagged with: jpa
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2615014
accepted answer: http://stackoverflow.com/a/2615014
tagged with: spring
possible better answer: http://stackoverflow.com/a/2615085
upvote count: 5
tagged with: classloader
type: AnsweredQuestion
has title: Brainstorming: Weird JPA problem, possibly classpath or jar versioning problem?
tagged with: java
has answer: http://stackoverflow.com/a/2615085
type: Question
has body: I'm seeing a weird error message and am looking for some ideas as to what the problem could be. I'm sort of new to using the JPA. I have an application where I'm using Spring's Entity Manager Factory (LocalContainerEntityManagerFactoryBean), EclipseLink as my ORM provider, connected to a MySQL DB and built with Maven. I'm not sure if any of this matters..... When I deploy this application to Glassfish, the application works as expected. The problem is, I've created a set of stand alone unit tests to run outside of Glassfish that aren't working correctly. I get the following error (I've edited the class names a little) com.xyz.abc.services.persistence.entity.MyEntity cannot be cast to com.xyz.abc.services.persistence.entity.MyEntity The object cannot be cast to a class of the same type? How can that be? Here's a snippet of the code that is in error Query q = entityManager.createNamedQuery("MyEntity.findAll"); List entityObjects = q.getResultList(); for (Object entityObject: entityObjects) { com.xyz.abc.services.persistence.entity.MyEntity entity = (com.xyz.abc.services.persistence.entity.MyEntity) entityObject; Previously, I had this code that produced the same error: CriteriaQuery cq = entityManager.getCriteriaBuilder().createQuery(); cq.select(cq.from(com.xyz.abc.services.persistence.entity.MyEntity.class)); List entityObjects = entityManager.createQuery(cq).getResultList(); for (Object entityObject: entityObjects) { com.xyz.abc.services.persistence.entity.MyEntity entity = (com.xyz.abc.services.persistence.entity.MyEntity) entityObject; This code is question is the same that I have deployed to the server. Here's the innermost exception if it helps Caused by: java.lang.ClassCastException: com.xyz.abc.services.persistence.entity.MyEntity cannot be cast to com.xyz.abc.services.persistence.entity.MyEntity at com.xyz.abc.services.persistence.entity.factory.MyEntityFactory.createBeans(MyEntityFactory.java:47) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method…
answer count: 2
score: 5

http://stackoverflow.com/comment/32387245
score: 1
comment on: http://stackoverflow.com/a/21409975
type: AnswerComment
has text: Just discovered an website that explains it perfectly and in-depth: http://www.javamex.com/tutorials/synchronization_concurrency_synchronized2.shtml
type: Comment

http://stackoverflow.com/q/2636845
has answer: http://stackoverflow.com/a/8960269
answer count: 3
downvote count: 0
favorite count: 0
has body: I'd like to know if it is possible in Java to nest Enums. Here what i'd like to be able to do : Have an enum Species made of CAT and DOG wich would grant me access to sub enums of the available CAT and DOG breeds. For example, i'd like to be able to test if wether a CAT or a DOG and if an animal is a PERSAN CAT or a PITBULL DOG. CAT and DOG breeds must be distinct enums ,i.e a CatBreeds enum and a DogBreeds enum. Here is an example of access pattern i'd like to use : Species : Species.CAT Species.DOG Breeds : Species.CAT.breeds.PERSAN Species.DOG.breeds.PITBULL
accepted answer: http://stackoverflow.com/a/2636862
has answer: http://stackoverflow.com/a/2636888
has comment: http://stackoverflow.com/comment/2650978
type: AnsweredQuestion
score: 2
has title: How to nest an Enum inside the value of an Enum
upvote count: 2
tagged with: java
type: Question
tagged with: enums
has answer: http://stackoverflow.com/a/2636862
possible better answer: http://stackoverflow.com/a/8960269

http://stackoverflow.com/a/2758262
has body: A real world example, from a Stack-class (from Assertion in Java Articles) public int pop() { // precondition assert !isEmpty() : "Stack is empty"; return stack[--num]; }
score: 7
has comment: http://stackoverflow.com/comment/22132861
upvote count: 20
has comment: http://stackoverflow.com/comment/84317864
has comment: http://stackoverflow.com/comment/40180826
has comment: http://stackoverflow.com/comment/2791401
has comment: http://stackoverflow.com/comment/2789935
type: Answer
answers question: http://stackoverflow.com/q/2758224
has comment: http://stackoverflow.com/comment/39128532
has comment: http://stackoverflow.com/comment/35033920
downvote count: 13

http://stackoverflow.com/comment/2763654
has text: @Tim: it results in essentially the same `PatternSyntaxException`. By the way, if anybody wants to play around with a variant of this problem, I just authored one on codingBat: http://codingbat.com/prob/p266235
comment on: http://stackoverflow.com/q/2734977
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2608376
upvote count: 7
possible better answer: http://stackoverflow.com/a/2610464
has answer: http://stackoverflow.com/a/2608748
favorite count: 0
accepted answer: http://stackoverflow.com/a/2608469
tagged with: jdbc
type: AnsweredQuestion
has body: Could someone please give me a link on how to create a query in JDBC that gets a variable name in the WHERE statement, or write an example, to be more specific, my code looks something like this: private String getLastModified(String url) { String lastModified = null; ResultSet resultSet; String query = "select LastModified from CacheTable where " + " URL.equals(url)"; try { resultSet = sqlStatement.executeQuery(query); } Now I need the syntax that enables me to return a ResultSet object where URL in the cacheTable equals url from the method's argument. thanks
downvote count: 0
has answer: http://stackoverflow.com/a/2608469
tagged with: java
has title: Specifying a variable name in QUERY WHERE clause in JDBC
tagged with: mysql
has answer: http://stackoverflow.com/a/2610464
type: Question
score: 7
answer count: 3

http://stackoverflow.com/q/2741394
upvote count: 2
answer count: 3
favorite count: 0
score: 2
downvote count: 0
has title: Java jasper report NullPointerException
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/24051524
has answer: http://stackoverflow.com/a/10673889
type: Question
tagged with: jasper-reports
has answer: http://stackoverflow.com/a/2760664
has comment: http://stackoverflow.com/comment/2771323
tagged with: java
has comment: http://stackoverflow.com/comment/2770281
has comment: http://stackoverflow.com/comment/2776969
has body: I am new to Java and I am running into this issue that I can't figure out. I inherited this project and I have the following code in one of my scriptlets: DefaultLogger.logMessage("DEBUG path: "+ reportFile.getPath()); DefaultLogger.logMessage("DEBUG parameters: "+ parameters); DefaultLogger.logMessage("DEBUG jr: "+ jr); bytes = JasperRunManager.runReportToPdf(reportFile.getPath(), parameters, jr); And I am getting the following results (the fourth line there is line 287 in FootwearReportsServlet.doGet): DEBUG path: C:\Development\JavaWorkspaces\Workspace1\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\RSLDevelopmentStandard\reports\templates\footwear\RslFootwearReport.jasper DEBUG parameters: {class_list_subreport=net.sf.jasperreports.engine.JasperReport@b07af1, signature_path=images/logo_reports.jpg, submission_id=20070213154168780, test_results_subreport=net.sf.jasperreports.engine.JasperReport@5795ce, logo_path=images/logos_3.gif, report_connection_secondary=com.mysql.jdbc.JDBC4Connection@2c39d2, testing_packages_subreport=net.sf.jasperreports.engine.JasperReport@1883d5f, signature_path2=images/logo_reports.jpg, tpid_subreport=net.sf.jasperreports.engine.JasperReport@17531fd, first_page_subreport=net.sf.jasperreports.engine.JasperReport@12504e0} DEBUG jr: net.sf.jasperreports.engine.data.JRMapCollectionDataSource@1630eb6 Apr 29, 2010 4:15:13 PM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet FootwearReportsServlet threw exception java.lang.NullPointerException at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:517) at net.sf.jasperreports.engine.JasperRunManager.runReportToPdf(JasperRunManager.java:385) at com.rsl.reports.FootwearReportsServlet.doGet(FootwearReportsServlet.java:287) at javax.servlet.http.HttpServl…

http://stackoverflow.com/a/2768649
downvote count: 0
score: 1
type: Answer
has comment: http://stackoverflow.com/comment/2922156
accepted answer of: http://stackoverflow.com/q/2765876
answers question: http://stackoverflow.com/q/2765876
upvote count: 1
has comment: http://stackoverflow.com/comment/2806502
has body: The List&lt;Element&gt; field type is usually generated by XJC when you have something like this in the schema: &lt;xs:any processContents="skip" maxOccurs="unbounded" minOccurs="0" /&gt; The key here is processContents="skip", which means "anything goes" - any well-formed XML can go in here. Because it's a free-for-all, all XJC can do is represent it as a DOM, and it becomes your responsibility to handle that payload. If you remove processContents="skip", then JAXB will make an attempt to bind the payload to an object model, if it can match the payload XML to a class in the JAXBContext. In this case, XJC will generate this a field of type List&lt;Object&gt;. This may not seem like a improvement, but this List can contain Element (if the JAXBContext doesn't recognise the payload as something it can bind to), or JAXBElement (if it does recognise it). The latter contains the bound version of the payload, and is much easier to handle. This is all described further here. If you cannot modify the schema, and are stuck with processContents="skip", then you're going to have to jump through hoops. You can build another JAXBContext that knows about your payload classes, and use that to marshal to an Element (using something like marshaller.marshal(payload, new DOMResult()). You can then dump that element into the payload.
type: AcceptedAnswer

package
tags question: http://stackoverflow.com/q/2714769
tag name: package
tags question: http://stackoverflow.com/q/2654161
tags question: http://stackoverflow.com/q/2681161
tags question: http://stackoverflow.com/q/2611565
type: Tag
tags question: http://stackoverflow.com/q/2692643
tags question: http://stackoverflow.com/q/2686887
tags question: http://stackoverflow.com/q/2768914
tags question: http://stackoverflow.com/q/2758799
tags question: http://stackoverflow.com/q/2720963
tags question: http://stackoverflow.com/q/2674325
tags question: http://stackoverflow.com/q/2755818

http://stackoverflow.com/comment/2696490
type: Comment
type: QuestionComment
has text: Without any knowledge on what the library is supposed to do, it will be hard to provide help. Is there some configuration file involved? Do register callbacks in the worker thread?
comment on: http://stackoverflow.com/q/2677335
score: 0

http://stackoverflow.com/q/2713148
has answer: http://stackoverflow.com/a/2713419
accepted answer: http://stackoverflow.com/a/2713338
possible better answer: http://stackoverflow.com/a/2713177
tagged with: logging
answer count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2713177
score: 3
has answer: http://stackoverflow.com/a/2713232
upvote count: 3
tagged with: java
has comment: http://stackoverflow.com/comment/2738399
type: Question
has comment: http://stackoverflow.com/comment/2738339
has answer: http://stackoverflow.com/a/2713338
has comment: http://stackoverflow.com/comment/2740234
has body: Suppose, you have a special log table of your application. What do you think about creating a BLOB field for a possible stack trace ? Logging is done to file as well, but it is not so convenient to read a text file, moreover database is more "accessible".
downvote count: 0
tagged with: log4j
favorite count: 0
has title: What do you think of saving stack trace in a special log table?

http://stackoverflow.com/a/2712938
upvote count: 3
accepted answer of: http://stackoverflow.com/q/2712921
has comment: http://stackoverflow.com/comment/2737855
answers question: http://stackoverflow.com/q/2712921
has comment: http://stackoverflow.com/comment/2737817
has body: JButton extends AbstractButton (in the same way JRadioButton does) and hence you can use the same solution as with JRadioButton: Simply add a number of JButtons to a ButtonGroup. However, typically this approach will be unintuitive to the end user as people don't generally expect buttons to remain "stuck down"; This is specifically why JRadioButtons exist.
type: AcceptedAnswer
downvote count: 0
score: 3
type: Answer

http://stackoverflow.com/comment/2788411
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2756387
has text: @Peter c:\Program Files\Java\jdk1.6.0_20

http://stackoverflow.com/comment/2658428
type: Comment
has text: thank u all... is it possible to write methods in properties file?
comment on: http://stackoverflow.com/a/2643418
type: AnswerComment
score: 0

http://stackoverflow.com/a/2670775
upvote count: 1
score: 1
has body: Do you know a tutorial how to create a CXF soap web service from existing Java code and embed it in Tomcat, Embedding to Tomcat (to avoid using spring, opening own port): Servlet Transport also generate a wsdl file You java code 2 wsdl also maven plugin exists. But you can get the wsdl from working service by http://host:port/servicename?wsdl url and provide it ;)
type: AcceptedAnswer
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2666737
accepted answer of: http://stackoverflow.com/q/2666737

http://stackoverflow.com/comment/2626660
type: Comment
type: AnswerComment
has text: @chris_l: pretend a pirate replaces the routine that calls the remote service with one that always returns true. Just like what he would do if the check was made locally.
score: 0
comment on: http://stackoverflow.com/a/2615174

http://stackoverflow.com/q/2773733
type: AnsweredQuestion
upvote count: 9
has body: As the title says it, I have a huge xml file (GBs) ... ... ... ... and I'd like to transform it into a much smaller one which retains only a few of the elements. My parser should do the following: 1. Parse through the file until a relevant element starts. 2. Copy the whole relevant element (with children) to the output file. go to 1. step 1 is easy with SAX and impossible for DOM-parsers. step 2 is annoying with SAX, but easy with the DOM-Parser or XSLT. so what? - is there a neat way to combine SAX and DOM-Parser to do the task?
tagged with: java
has answer: http://stackoverflow.com/a/2773786
possible better answer: http://stackoverflow.com/a/2773757
score: 9
type: Question
has answer: http://stackoverflow.com/a/2776502
has answer: http://stackoverflow.com/a/2773757
has answer: http://stackoverflow.com/a/2776346
downvote count: 0
answer count: 7
accepted answer: http://stackoverflow.com/a/2773762
favorite count: 0
tagged with: parsing
tagged with: http://stackoverflow.com/tag/xml
has title: How to transform huge xml files in java?
has answer: http://stackoverflow.com/a/2773776
has answer: http://stackoverflow.com/a/2773805
has answer: http://stackoverflow.com/a/2773762

http://stackoverflow.com/comment/130486615
type: Comment
comment on: http://stackoverflow.com/a/2784668
has text: When I do this it does not reference the other table even though I'm explicitly specifying the class in the tag. it does successfully when it's one to one however, but does not let me insert only update...
type: AnswerComment
score: 0

http://stackoverflow.com/comment/2751012
score: 0
type: Comment
has text: And what if I had 5000 files out of which only a few hundred need to be transfered (either because they are modified or new). How would JMS perform in that situation?
type: AnswerComment
comment on: http://stackoverflow.com/a/2722755

http://stackoverflow.com/comment/2785253
has text: No, I don't understand it. Adding and removing things to registry is done at runtime, but injecting it into objects that need it is a configuration detail. Which one are you talking about? You probably shouldn't be using DI. If you're new to Java, I'd say it's an advanced topic that you should defer.
type: AnswerComment
comment on: http://stackoverflow.com/a/2754065
score: 0
type: Comment

http://stackoverflow.com/a/2689234
has comment: http://stackoverflow.com/comment/2711062
has body: That's not pretty, but could do: simply use try to send an email to an illegal address and see what error message you get. If the error message complains about failed authentication, you know what to do. EDIT some working code: here's some working code to validate Gmail credentials. Gmail doesn't complain about the illegal@localhost though. Now you could either try to search for a recipient that causes an exception or really send mail to an address and discard it immediately. . Edit: It's not even necessary to send something. Simply connect and handle a possible AuthenticationFailedException. import java.util.Properties; import javax.mail.AuthenticationFailedException; import javax.mail.MessagingException; import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.Transport; public class Main { private static Session createSmtpSession(final String user, final String password) { final Properties props = new Properties(); props.setProperty("mail.transport.protocol", "smtp"); props.setProperty("mail.smtp.host", "smtp.gmail.com"); props.setProperty("mail.smtp.auth", "true"); props.setProperty("mail.smtp.port", "587"); props.setProperty("mail.smtp.starttls.enable", "true"); return Session.getDefaultInstance(props, new javax.mail.Authenticator() { @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(user, password); } }); } private static boolean validateCredentials(String user, String password) { try { Transport transport = createSmtpSession(user, password).getTransport(); transport.connect(); transport.close(); } catch (AuthenticationFailedException e) { return false; } catch (MessagingException e) { throw new RuntimeException("validate failed", e); } return true; } public static void main(String[] args) { System.out.println(validateCredentials(args[0], args[1])); } }
has comment: http://stackoverflow.com/comment/2712322
has comment: http://stackoverflow.com/comment/2710372
answers question: http://stackoverflow.com/q/2689177
has comment: http://stackoverflow.com/comment/2711164
score: 0
has comment: http://stackoverflow.com/comment/2711355
type: Answer

http://stackoverflow.com/comment/3371918
type: Comment
has text: @oxbow_lakes: I'd love to; can you suggest a link?
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2638298

http://stackoverflow.com/a/2678506
has comment: http://stackoverflow.com/comment/105375627
has body: In Java source code, double quote is a special character, used to declare string literals. You cannot have a double quote in a String literal without escaping it. In general, I would try to avoid hard-coding strings like that in source code, particularly if I found myself doing it a lot - as you've noted, they're a pain to deal with as source and they might be quite likely to change, in which case you could do without recompiling. If you don't need to supply runtime parts to the text data, you could get away with something as simple as reading in the data from a properties file, or you could use a templating engine like Apache Velocity to keep the character data separate and still substitute variables at runtime - several of the examples in the linked user guide do exactly that with HTML.
has comment: http://stackoverflow.com/comment/2698082
has comment: http://stackoverflow.com/comment/2698232
type: Answer
answers question: http://stackoverflow.com/q/2678483
score: 0

http://stackoverflow.com/comment/2796523
type: Comment
comment on: http://stackoverflow.com/a/2759303
has text: +1 for adding more details and a possible solution (to a very unspecific question).
type: AnswerComment
score: 0

http://stackoverflow.com/comment/2715924
comment on: http://stackoverflow.com/a/2694138
score: 3
has text: @Avi You may want it but this is not possible in a fully automated way. Tools can help a bit (e.g. `mvn dependency:analyze`) but they won't take runtime dependencies into account. So this leaves you with manual tweak of the classpath and regression testing (assuming you have tests with high coverage). At the end, *"know what you're doing"* is your best weapon, whether you like it or not.
type: AnswerComment
type: Comment

http://stackoverflow.com/a/2708270
answers question: http://stackoverflow.com/q/2708229
has comment: http://stackoverflow.com/comment/2732270
has comment: http://stackoverflow.com/comment/2732313
accepted answer of: http://stackoverflow.com/q/2708229
upvote count: 1
type: AcceptedAnswer
has body: Actually, an exception can occur between the 2 calls in the last code sample,and leave the resource open. If the thread is stopped violently by another thread using the Thread.stop() or Thread.stop(Throwable) immediately after the stream construction, the thread will throw an exception (ThreadDeath in the first case), and the resources will not be disposed of. But this is exactly why these methods are deprecated...
type: Answer
has comment: http://stackoverflow.com/comment/2732290
has comment: http://stackoverflow.com/comment/2732323
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/2732280
has comment: http://stackoverflow.com/comment/2732428
has comment: http://stackoverflow.com/comment/2732341

http://stackoverflow.com/q/2701100
downvote count: 0
score: 18
answer count: 6
has answer: http://stackoverflow.com/a/2701187
has answer: http://stackoverflow.com/a/9492353
tagged with: rhel5
has comment: http://stackoverflow.com/comment/2724044
possible better answer: http://stackoverflow.com/a/9179769
has answer: http://stackoverflow.com/a/2701283
upvote count: 18
favorite count: 0
has answer: http://stackoverflow.com/a/9179769
has answer: http://stackoverflow.com/a/2716386
accepted answer: http://stackoverflow.com/a/2716386
has comment: http://stackoverflow.com/comment/2723925
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/29787295
type: Question
has body: I'm not quite sure how I got into this mess, but for some reason I'm not able to change the current version of Java using alternatives. I can run alternatives --config java and type my selection but when I echo the version number for either java or javac, it spits back out 1.5 every time (despite alternatives showing the current version is 1.6). The server I'm working with is running RHEL5, by the way. I have verified that the paths used in alternatives are pointing to the correct directories. Here's some output from my session: [brilewis@myserver]$ sudo /usr/sbin/update-alternatives --config java There are 3 programs which provide 'java'. Selection Command ** 1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java + 2 /usr/java/jdk1.5.0_10/bin/java 3 /usr/java/jdk1.6.0_16/bin/java Enter to keep the current selection[+], or type selection number: 3 [brilewis@myserver]$ java -version java version "1.5.0_10" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03) Java HotSpot(TM) Server VM (build 1.5.0_10-b03, mixed mode) [brilewis@myserver]$ sudo /usr/sbin/update-alternatives --config java There are 3 programs which provide 'java'. Selection Command ** 1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java 2 /usr/java/jdk1.5.0_10/bin/java + 3 /usr/java/jdk1.6.0_16/bin/java Enter to keep the current selection[+], or type selection number: UPDATE: The following is the output of echo $PATH: /usr/java/jdk1.5.0_10/bin:/usr/local/apache-ant-1.7.1/bin:/usr/local/apache-tomcat-6.0.24:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/NX/bin:/home/brilewis/bin UPDATE (4/26/10): I followed Bert's suggestion and removed JAVA_HOME from the PATH environment var in /etc/profile. After doing this, I was able to use alternatives to change the version of Java. The only problem is that when I try to run javac, I get "-bash: javac: command not found". This does not happen when the version is set to 1.5.
has title: Problem changing Java version using alternatives

http://stackoverflow.com/comment/2622962
score: 0
type: Comment
type: QuestionComment
has text: @Etaoin: Oh! I always thought it was dice-dices. I'll rollback it. Many thanks for noting.
comment on: http://stackoverflow.com/q/2612170

http://stackoverflow.com/a/2769122
upvote count: 7
has comment: http://stackoverflow.com/comment/2802302
downvote count: 0
score: 7
has body: My company has 100+ bundle projects and we use Eclipse to manage the dependencies. However, I don't recommend the "Required Plugins" approach to managing the dependencies. Your best bet is to create Plugin Projects. Export just the packages from each project that you want to be visible. Then on the import side do the following: Open the Manifest editor Goto the dependencies tab In the bottom left is a section called "Automated Management of Dependencies" Add any plugins that the current plugin depends on there Once you have code written, you can click the "add dependencies" link on that tab to auto-compute the imported packages. If you run from Eclipse, this gets done automatically for you when you execute. The benefits of this approach is that your built bundles are only using OSGi defined package import/export mechanism, as opposed to something from Eclipse. If you want to learn more, I'd recommend going to this site and ordering the book. It's excellent. http://equinoxosgi.org/
type: Answer
answers question: http://stackoverflow.com/q/2768903

http://stackoverflow.com/a/2711566
score: 0
has body: Answers to the same question here: http://discuss.joelonsoftware.com/default.asp?dotnet.12.384449.7 ... except nobody can't really answer because there is none indeed ! Anybody realize there is a HUGE Business Opportunity to do so ? Thoough Mainsoft has done a great job at recompiling .net for j2ee, they would have made more $$$ by just creating an ide fully for java.
has comment: http://stackoverflow.com/comment/33654426
answers question: http://stackoverflow.com/q/2694238
type: Answer

http://stackoverflow.com/comment/2722153
type: Comment
has text: Actually, you could wrap your code in a `do { ... } while (false);` to be able to jump back to the beginning. but that would lead to unclear / unmaintainable code, so it is frowned upon.
comment on: http://stackoverflow.com/a/2699190
score: 0
type: AnswerComment

http://stackoverflow.com/comment/2776870
has text: But then you would not get a benefit to deploy in different jvms. You just get additional jvms to monitor and have to deal with the dependencies, when you update one module.
score: 0
comment on: http://stackoverflow.com/a/2746788
type: AnswerComment
type: Comment

http://stackoverflow.com/q/2653118
has answer: http://stackoverflow.com/a/2653163
has comment: http://stackoverflow.com/comment/2669570
has answer: http://stackoverflow.com/a/2653229
score: 0
has comment: http://stackoverflow.com/comment/2669342
accepted answer: http://stackoverflow.com/a/2653170
answer count: 5
has comment: http://stackoverflow.com/comment/2669338
tagged with: sockets
has title: Limit Connections with semaphores
has answer: http://stackoverflow.com/a/2653225
has body: I'm trying to limit the number of connections my server will accept using semaphores, but when running, my code doesn't seem to make this restriction - am I using the semaphore correctly? eg. I have hardcoded the number of permit as 2, but I can connect an unlimited number of clients... public class EServer implements Runnable { private ServerSocket serverSocket; private int numberofConnections = 0; private Semaphore sem = new Semaphore(2); private volatile boolean keepProcessing = true; public EServer(int port) throws IOException { serverSocket = new ServerSocket(port); } @Override public void run() { while (keepProcessing) { try { sem.acquire(); Socket socket = serverSocket.accept(); process(socket, getNextConnectionNumber()); } catch (Exception e) { } finally { sem.release(); } } closeIgnoringException(serverSocket); } private synchronized int getNextConnectionNumber() { return ++numberofConnections; } // processing related methods }
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2669345
has answer: http://stackoverflow.com/a/48177552
tagged with: java
possible better answer: http://stackoverflow.com/a/2653163
type: Question
has answer: http://stackoverflow.com/a/2653170

http://stackoverflow.com/q/2777446
score: 1
tagged with: string
favorite count: 0
has title: Recursive String Function (Java)
has answer: http://stackoverflow.com/a/2777620
type: Question
linked to: http://stackoverflow.com/q/2538718
has answer: http://stackoverflow.com/a/2778401
has answer: http://stackoverflow.com/a/2777484
answer count: 3
upvote count: 1
tagged with: recursion
tagged with: java
type: UnansweredQuestion
has body: I am trying to design a function that essentially does as follows: String s = "BLAH"; store the following to an array: blah lah bah blh bla bl ba bh ah al So basically what I did there was subtract each letter from it one at a time. Then subtract a combination of two letters at a time, until there's 2 characters remaining. Store each of these generations in an array. Hopefully this makes sense, Jake
downvote count: 0

http://stackoverflow.com/q/2772324
type: Question
answer count: 3
downvote count: 0
score: 8
favorite count: 0
has answer: http://stackoverflow.com/a/2773226
has title: Can two different UDP socket in a system bind same port?
upvote count: 8
type: UnansweredQuestion
tagged with: sockets
has answer: http://stackoverflow.com/a/2772382
has answer: http://stackoverflow.com/a/61113164
has body: I have an application which uses UDP connection, now when i try to run the app more than once its throwing me an exception java.net.BindException: Address already in use: Cannot bind but in my another app, which uses tcp connection, i can open two instance of the same app and its working fine. why this error only with UDP connection? Edit: TCP socket: Socket clientSocket= new Socket(ipAddress, 8000); Socket clientSocket1= new Socket(ipAddress, 8000); If i create TCP socket like above,with same port, it is not throwing any error. but if i do this with UDP Socket it throwing me an exception, why?
tagged with: java
has comment: http://stackoverflow.com/comment/108116546

http://stackoverflow.com/comment/2705192
type: Comment
score: 3
comment on: http://stackoverflow.com/a/2685013
type: AnswerComment
has text: That's not the problem, as the exit code is 0 (meaning success), the problem is that the file redirection (the `>`) is handled by the shell/cmd.exe and therefore isn't applied. The solution still is the same, however.

http://stackoverflow.com/comment/2888990
score: 0
type: AnswerComment
has text: Thanks, VonC. Your answer is perfect!!
type: Comment
comment on: http://stackoverflow.com/a/2843523

http://stackoverflow.com/a/3977963
has body: Did you tried with the write method direct to the HttpServletResponse.getOutputStream()? Please take a look at the following example: HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet("new sheet"); ... OutputStream out = response.getOutputStream(); wb.write(out); out.close();
type: Answer
downvote count: 7
has comment: http://stackoverflow.com/comment/4256153
has comment: http://stackoverflow.com/comment/31885007
score: 1
upvote count: 8
answers question: http://stackoverflow.com/q/2673751
has comment: http://stackoverflow.com/comment/79166021

http://stackoverflow.com/comment/2698823
has text: Thanks. I ensured that the encoding in the `content` attribute of the `meta` tag is what is being used to encode the query string of the get request by running simple Servlet example.
comment on: http://stackoverflow.com/a/2677184
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2781999
has text: @primehunter326: @aioobe's comment is correct. Like the `actionPerformed()` method of `javax.swing.Timer`, the `process() method of `SwingWorker` runs on the EDT.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2750681

http://stackoverflow.com/q/2694797
favorite count: 0
tagged with: sockets
upvote count: 7
possible better answer: http://stackoverflow.com/a/8159154
tagged with: bind
type: AnsweredQuestion
tagged with: java
score: 7
type: Question
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/8159154
has title: BindException with INTERNET permission requested
tagged with: android
has answer: http://stackoverflow.com/a/2695160
accepted answer: http://stackoverflow.com/a/2695160
has body: I have seen several questions regarding SocketException when using Android, but none of them cover the BindException that I get even with the INTERNET permission specified in my manifest. Here is part of my manifest: Here is the relevant portion of my LogCat output: 04-22 14:49:06.117: DEBUG/MyLibrary(4844): Address to bind: 192.168.1.14 port: 843 04-22 14:49:06.197: WARN/System.err(4844): java.net.BindException: Permission denied (maybe missing INTERNET permission) 04-22 14:49:06.207: WARN/System.err(4844): at org.apache.harmony.luni.platform.OSNetworkSystem.socketBindImpl(Native Method) 04-22 14:49:06.207: WARN/System.err(4844): at org.apache.harmony.luni.platform.OSNetworkSystem.bind(OSNetworkSystem.java:107) 04-22 14:49:06.217: WARN/System.err(4844): at org.apache.harmony.luni.net.PlainSocketImpl.bind(PlainSocketImpl.java:184) 04-22 14:49:06.217: WARN/System.err(4844): at java.net.ServerSocket.bind(ServerSocket.java:414) 04-22 14:49:06.227: WARN/System.err(4844): at org.apache.harmony.nio.internal.ServerSocketChannelImpl$ServerSocketAdapter.bind(ServerSocketChannelImpl.java:213) 04-22 14:49:06.227: WARN/System.err(4844): at java.net.ServerSocket.bind(ServerSocket.java:367) 04-22 14:49:06.237: WARN/System.err(4844): at org.apache.harmony.nio.internal.ServerSocketChannelImpl$ServerSocketAdapter.bind(ServerSocketChannelImpl.java:283) 04-22 14:49:06.237: WARN/System.err(4844): at mylibrary.net.PolicyConnection$PolicyServerWorker.(PolicyConnection.java:201) I Really hope this is a simple problem and not something complicated by the fact that the binding is occurring within a worker thread on a port less than 1024. Update Looks as if this is a privileged port issue, anyone know how to bind to ports lower than 1024 in Android? SelectorProvider provider = SelectorProvider.provider(); try { ServerSocketChannel channel = provider.openServerSocketChannel(); policySocket = channel.socket(); Log.d("MyLibrary", "Address to bind: " + device.getAddress().getAddress() + " port: …

http://stackoverflow.com/a/2763942
has body: Don't use Timer. The ScheduledExecutorService implementations are much better and provide the functionality you want with some extra work. See 409932 for some reasons why to avoid Timer.
answers question: http://stackoverflow.com/q/2763897
type: AcceptedAnswer
upvote count: 3
type: Answer
score: 3
accepted answer of: http://stackoverflow.com/q/2763897
downvote count: 0

http://stackoverflow.com/q/2771973
type: Question
accepted answer: http://stackoverflow.com/a/2776270
score: 5
upvote count: 5
answer count: 1
downvote count: 0
linked to: http://stackoverflow.com/q/151777
favorite count: 0
has answer: http://stackoverflow.com/a/2776270
tagged with: android
has title: OnLowMemory getting called
type: AnsweredQuestion
has body: I am doing an App which access the gprs .I am facing problem when the user starts another application who uses gprs also like google maps .It takes it own heap memory ,after doing some operation on Maps app it calls OnLowMemory of my service .and my ui is also killed in background. I am not getting any proper tutorial haw can i start my app when it is getting killed during onLowMemory ,or is there any other way to handle it . Thanks in advance.
tagged with: java
has comment: http://stackoverflow.com/comment/2805600

http://stackoverflow.com/comment/13195933
comment on: http://stackoverflow.com/a/4818714
score: 2
has text: You saved my life, some code I wrote for android was not working with 4.1+... Thank you so much !
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2770412
type: Comment
comment on: http://stackoverflow.com/a/2741236
has text: @Dan `map.put(key, value);` to insert a value. `Integer value = map.get(key);` to retrieve a value (will be `null` if key is not mapped. Create with `Map<Integer,Integer> map = new HashMap<Integer,Integer>();`. And that's about all you need. @Dav Perhaps there is something in Google's Collections (or perhaps it is not considered worthwhile (in Java)). `ConcurrentMap.putIfAbsent` would make things cleaner, if more obscure.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/19718545
score: 1
has text: @jalf It is a logical thing to do, but it is prone to issues. Basically pointer values can be copied into multiple locations, so unless you have some sort of exotic "track each time this pointer's value was copied, and keep a reference of all of those value locations, including tracking if some of those locations are destroyed over time" then you'll update only some of the pointer values (which would be very bad). Actually, you can't really even create such a system; because, some of those values might be passed between programs. With a reference to pointer table, it's in one place only.
type: AnswerComment
comment on: http://stackoverflow.com/a/2629758
type: Comment

http://stackoverflow.com/q/2610295
score: 0
answer count: 2
has title: CompletionService.take().isDone() always true?
has body: Is it safe to assume that java.util.concurrent.CompletionService.take().isDone() will always return true? If so, why does take() return a Future, rather than the value directly? If not, what does "completed task" as used in the documentation mean?
tagged with: future
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2610314
has answer: http://stackoverflow.com/a/2610314
tagged with: java
type: Question
tagged with: concurrency
has answer: http://stackoverflow.com/a/2611171
accepted answer: http://stackoverflow.com/a/2611171

http://stackoverflow.com/comment/2771562
type: AnswerComment
score: 0
type: Comment
has text: Good advice, though note that Dates are by nature timezone-independent. Under the covers a Date is just a `long` offset in milliseconds since 1 January 1970 in UTC (Greenwich Mean Time).
comment on: http://stackoverflow.com/a/2742216

http://stackoverflow.com/q/2770894
tagged with: wicket
possible better answer: http://stackoverflow.com/a/33120240
tagged with: spring
type: AnsweredQuestion
tagged with: java
tagged with: hibernate
type: Question
answer count: 2
has title: Wicket testing - AnnotApplicationContextMock - There is no application attached to current thread main
score: 0
has answer: http://stackoverflow.com/a/2770937
has answer: http://stackoverflow.com/a/33120240
accepted answer: http://stackoverflow.com/a/2770937
has body: I've written a couple of tests for a small web app, but I get an error when I try to run the page specific tests that makes use of WicketTester. Google sends me to a mailing list for Apache Wicket, where a user experienced the same exception. He/she said the problem was that AnnotApplicationContextMock was initialized before the Wicket Application. I've pasted my WicketApplication class as well. Has any of you dealt with this error before? I've pasted the exception and the class below. Exception: ------------------------------------------------------------------------------- Test set: com.upbeat.shoutbox.web.TestViewShoutsPage ------------------------------------------------------------------------------- Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.545 sec (AnnotApplicationContextMock.java:61) at com.upbeat.shoutbox.web.TestViewShoutsPage.setUp(TestViewShoutsPage.java:30) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.internal.runners.MethodRoadie.runBefores(MethodRoadie.java:129) at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:93) at org.unitils.UnitilsJUnit4TestClassRunner$CustomMethodRoadie.runBeforesThenTestThenAfters(UnitilsJUnit4TestClassRunner.java:168) at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:84) at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49) at org.unitils.UnitilsJUnit4TestClassRunner.invokeTestMethod(UnitilsJUnit4TestClassRunner.java:127) at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:59) at org.unitils.UnitilsJUnit4TestClassRunner.access$000(UnitilsJUnit4TestClassRunner.java:42) at org.unitils.UnitilsJUnit4TestClassRunner$1.run(UnitilsJUnit4TestClassRunner.java:8…

http://stackoverflow.com/comment/26127751
has text: @HamzehSoboh, correct (almost). Thanks for pointing it out. I didn't take into account that `string1.substring(0, string2.length())` throws `IndexOutOfBoundsException` if `string1.length() < string2.length()`. But condition should be `string1.length() >= string2.length()`.
comment on: http://stackoverflow.com/a/2602964
type: AnswerComment
type: Comment
score: 1

http://stackoverflow.com/a/44072167
type: Answer
has body: Object -> String (For example, GSON - you will not have to write serialization not to list all fields of your class) String.hashCode() -> int (Instead of Object.hashCode()! This realization of hashCode() depends on content of String, not on address in memory --- you can use it across different app launches, different threads, etc.) (or 2. String -> md5)
score: 0
answers question: http://stackoverflow.com/q/2644847

http://stackoverflow.com/q/2667873
tagged with: jsf
tagged with: java
has answer: http://stackoverflow.com/a/2673105
has answer: http://stackoverflow.com/a/34987472
type: Question
answer count: 2
score: 0
has body: I have a javascript that is calling a function addData(param1,param2,param3,param4) which is calling addClip at the end And I need to pass those to a backing bean. &lt;a4j:form&gt; &lt;a4j:jsFunction name="addClip" action="#{backingBean.goGo}"&gt; &lt;a4j:actionparam name="param1" assignTo="#{backingBean.param1}"/&gt; &lt;/a4j:jsFunction&gt; &lt;/a4j:form&gt; But I can't seem to pass any values to the backingbean. I've even tried setting a static value for the actionparam. But when I try to do a Systemout on the setParam1 method it only prints out null. Have I missed anything important?
tagged with: richfaces
tagged with: ajax4jsf
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/2691541
has title: jsFunction pass data to backingbean
has comment: http://stackoverflow.com/comment/2686671

http://stackoverflow.com/comment/2649015
has text: @kts: NASM isn't a language. It's an assembler. Where is the "NASM language specification"? I don't believe that you *really* can't see the difference between a language which was designed to be portable and which *does* have a VM on non-Windows platform and a language which deliberately targets x86 and x64. The simple fact is that I can sit down at my Linux workstation, create a program C#, compile it and run it. That completely flies in the face of your post. Your failure to recognise the difference between .NET and C# doesn't remove that difference. The question talks about *languages*.
type: Comment
comment on: http://stackoverflow.com/a/2627051
score: 2
type: AnswerComment

http://stackoverflow.com/q/2637879
favorite count: 0
has answer: http://stackoverflow.com/a/11060024
has body: I've been working for some time on (Java) Bytecode, however, it had never occurred to me to ask why are some instructions typed? I understand that in an ADD operation, we need to distinguish between an integer addition and a FP addition (that's why we have IADD and FADD). However, why do we need to distinguish between ISTORE and FSTORE? They both involve the exact same operation, which is moving 32 bits from the stack to a local variable position? The only answer I can think of is for type-safety, to prevent this: (ILOAD, ILOAD, FADD). However, I believe that type-safety is already enforced at the Java language level. OK, the Class file format is not directly coupled with Java, so is this a way to enforce type-safety for languages that do not support it? Any thought? Thank you. EDIT: to follow up on Reedy's answer. I wrote this minimal program: public static void main(String args[]) { int x = 1; } which compiled to: iconst_1 istore_1 return using a bytecode editor, I changed the second instruction: iconst_1 fstore_1 return and it returned a java.lang.VerifyError: Expecting to find float on stack. I wonder, if on the stack there's no information on the type, just bits, how did the FSTORE instruction knew that it was dealing with a int and not a float? Note: I couldn't find a better title for this question. Feel free to improve it.
accepted answer: http://stackoverflow.com/a/2638143
answer count: 4
score: 14
type: AnsweredQuestion
upvote count: 14
tagged with: java
type: Question
has title: Types in Bytecode
has answer: http://stackoverflow.com/a/2638364
tagged with: bytecode
has answer: http://stackoverflow.com/a/2638143
possible better answer: http://stackoverflow.com/a/2682381
has answer: http://stackoverflow.com/a/2682381
tagged with: verification
downvote count: 0

http://stackoverflow.com/comment/2777825
has text: As long as it can reuse the memory for new data i should be ok. I want to be able to add new rows as i delete old rows. Thank you!
comment on: http://stackoverflow.com/a/2747134
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2819261
has text: Obviously you need to set up a cron task to restart you process every 8-10 hours. Problem solved! Honestly, that is not normal and it is not something you should tolerate. I the load on the application basically stable during this time? Could you identify any threads that had gone off into the weeds or the like? Is this the trace from overnight? Is the 8 hours of quiet because people were not using the system?
comment on: http://stackoverflow.com/q/2783915
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2780255
has answer: http://stackoverflow.com/a/2780919
type: Question
score: 3
has answer: http://stackoverflow.com/a/2780291
tagged with: java
linked to: http://stackoverflow.com/q/84285
tagged with: concurrency
has comment: http://stackoverflow.com/comment/2816083
has comment: http://stackoverflow.com/comment/2816043
has comment: http://stackoverflow.com/comment/2815567
accepted answer: http://stackoverflow.com/a/2780292
downvote count: 1
has answer: http://stackoverflow.com/a/2782620
duplicate of: http://stackoverflow.com/q/8057510
favorite count: 0
has answer: http://stackoverflow.com/a/2780292
answer count: 5
has comment: http://stackoverflow.com/comment/2815172
upvote count: 4
has answer: http://stackoverflow.com/a/2780702
type: AnsweredQuestion
has title: Is it a good idea to start a thread from its own constructor?
has comment: http://stackoverflow.com/comment/2815096
has body: Can we call thread_object.start() from within a constructor of this same object? Is this approach a good idea ?
tagged with: multithreading
linked to: http://stackoverflow.com/q/8057510
possible better answer: http://stackoverflow.com/a/2780919

http://stackoverflow.com/comment/2805413
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2771786
has text: But ease of development is about proportional with how much you know the language beforehand. I'm a .NET-geek trying to learn RoR. So for me PHP would be out of the question.

http://stackoverflow.com/a/21304569
answers question: http://stackoverflow.com/q/2720526
type: Answer
downvote count: 0
score: 1
has body: I am not sure how this will benefit but it worked for my use case which required a boot delegation settings. Each application server would have a configuration settings file (usually &lt;application server name&gt;.properties e.g., weblogic.properties, sling.properties....). You may have to add the following line "&lt;application server name&gt;.bootdelegation.com.sun=com.sun.*" For example For weblogic Server &nbsp;&nbsp;&nbsp;: "weblogic.bootdelegation.com.sun=com.sun.* " For Adobe CQ Server : "sling.bootdelegation.com.sun=com.sun.*" And this will work for most of the problem associated with this thread issue. Now coming to the explanation, com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl is already packaged with rt.jar which is a part of every run time library of JDK/JRE. However this package is totally ignored while booting the application. When specifically instructed to load through application configuration, the correct implementation class is loaded (which is what .bootdelegation. does). I hope this helps.
upvote count: 1

http://stackoverflow.com/comment/2725597
comment on: http://stackoverflow.com/a/2702329
has text: @KGVT: I don't believe this can make a measurable difference on any modern system. Yes, technically, it's one extra comparison in the common case, but it's just not big enough to matter. If your program is too slow, instrument it and find the bottlenecks; I don't believe this will be one of them.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/98123428
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/7525678
type: Comment
has text: @RamzanMahmood: Yes, that is by design. You may not invoke `isDisplayed()` on an element that is no longer in the DOM.

http://stackoverflow.com/comment/2713491
has text: Nate/VonC do you still think that this theory explains the problem I'm stating?
type: Comment
comment on: http://stackoverflow.com/a/2675243
score: 0
type: AnswerComment

http://stackoverflow.com/comment/2772213
score: 1
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2742966
has text: +1. You could still use `JScrollPane` with the default policy to show scrollbars only when necessary, and use `Math.min` with a constant for `height` (maybe height of containing JTextPane minus vertical position). This would make sure that the list always fits even if there are more values, but scrollBar will only be displayed when necessary.

http://stackoverflow.com/comment/2749537
has text: The servlet resets the token every POST. The client sends the token on every request, that should match with the one last generated by the TransactionTokenBean. Hence session scoped.
type: Comment
comment on: http://stackoverflow.com/a/2722692
score: 0
type: AnswerComment

http://stackoverflow.com/a/2766558
score: 0
has body: The documentation for ZipFile.close() says: Closing this ZIP file will close all of the input streams previously returned by invocations of the getInputStream method. Presumably the native close method is performing the close the InputStreams. The close method of InputStream has IOException as a checked exception. The most likely cause is an out of space condition on the filesystem where the zip file is being written error in the underlying filesystem. Unless you can identify the cause and work around it on the fly, all you can do is report the condition to the user.
type: Answer
answers question: http://stackoverflow.com/q/2766450
has comment: http://stackoverflow.com/comment/2799120

http://stackoverflow.com/comment/2741091
comment on: http://stackoverflow.com/a/2713432
type: Comment
has text: Seconded, you'll have to find another way. Even a hosted PHP script cannot process the type of data you're talking about. Consider writing a bridge application that can listen on the socket and then buffer the data and post it in batches to the Servlet. What sort of connection does the field device have to the internet? (does it come through your office?), if you're unable to set up a bridge application in your organisation/home then a VPS or dedicated server could be required. You can get a VPS pretty cheap these days, even if you just used it to buffer the data and pass it on to GAE.
type: AnswerComment
score: 0

http://stackoverflow.com/q/2728793
has comment: http://stackoverflow.com/comment/85162649
answer count: 5
accepted answer: http://stackoverflow.com/a/2728810
has title: Java Integer compareTo() - why use comparison vs. subtraction?
has answer: http://stackoverflow.com/a/2728858
has comment: http://stackoverflow.com/comment/138995731
type: AnsweredQuestion
has body: I've found that java.lang.Integer implementation of compareTo method looks as follows: public int compareTo(Integer anotherInteger) { int thisVal = this.value; int anotherVal = anotherInteger.value; return ( thisVal &lt; anotherVal ? -1 : ( thisVal == anotherVal ? 0 : 1 ) ) ; } The question is why use comparison instead of subtraction: return thisVal - anotherVal;
tagged with: java
has answer: http://stackoverflow.com/a/2728810
has answer: http://stackoverflow.com/a/2729198
type: Question
score: 93
has comment: http://stackoverflow.com/comment/2757581
upvote count: 93
tagged with: comparison
tagged with: integer-overflow
tagged with: optimization
downvote count: 0
possible better answer: http://stackoverflow.com/a/2728858
has answer: http://stackoverflow.com/a/2728817
tagged with: integer
favorite count: 0
has answer: http://stackoverflow.com/a/2729761

http://stackoverflow.com/comment/2652669
score: 0
has text: If we did not pass an implementation of proxy interfaces to method.invoke(), it's meanless to invoke a blank implementation on the proxy instance we created.If we pass this reference, why don't we call the instance method directly?
type: AnswerComment
comment on: http://stackoverflow.com/a/2636527
type: Comment

http://stackoverflow.com/q/2614719
has answer: http://stackoverflow.com/a/18295667
accepted answer: http://stackoverflow.com/a/2614771
score: 387
tagged with: android
upvote count: 388
has body: I am using a PreferenceActivity to show some settings for my application. I am inflating the settings via a xml file so that my onCreate (and complete class methods) looks like this: public class FooActivity extends PreferenceActivity { @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); addPreferencesFromResource(R.xml.preference); } } The javadoc of PreferenceActivity PreferenceFragment states that These preferences will automatically save to SharedPreferences as the user interacts with them. To retrieve an instance of SharedPreferences that the preference hierarchy in this activity will use, call getDefaultSharedPreferences(android.content.Context) with a context in the same package as this activity. But how I get the name of the SharedPreference in another Activity? I can only call getSharedPreferences(name, mode) in the other activity but I need the name of the SharedPreference which was used by the PreferenceActivity. What is the name or how can i retrieve it?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/61382761
tagged with: java
tagged with: sharedpreferences
has answer: http://stackoverflow.com/a/41782536
has title: How do I get the SharedPreferences from a PreferenceActivity in Android?
downvote count: 1
tagged with: preferenceactivity
type: Question
has answer: http://stackoverflow.com/a/2614771
has answer: http://stackoverflow.com/a/17130111
possible better answer: http://stackoverflow.com/a/3544070
answer count: 6
has answer: http://stackoverflow.com/a/3544070
linked to: http://stackoverflow.com/q/10786172
favorite count: 0

http://stackoverflow.com/a/2665580
has body: Hm... If I change the line: Mongo m = new Mongo("localhost", 27017); to: Mongo m = new Mongo(); all works fine.
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2665544
answers question: http://stackoverflow.com/q/2665544
score: 0
type: Answer

http://stackoverflow.com/comment/2615995
score: 0
comment on: http://stackoverflow.com/a/2605177
type: Comment
has text: which setting? And as advised - give more details (code) about your problem
type: AnswerComment

http://stackoverflow.com/comment/2732088
comment on: http://stackoverflow.com/a/2706073
has text: You might find it not as slow as other solutions, and the behaviour isn't defined for negatives. Just like the other solutions, there will be a non DDDDDDDD, where D is a digit, output for negative numbers.
score: 0
type: AnswerComment
type: Comment

w3c
type: Tag
tag name: w3c
tags question: http://stackoverflow.com/q/2640231
tags question: http://stackoverflow.com/q/2747416

http://stackoverflow.com/a/2777024
type: Answer
answers question: http://stackoverflow.com/q/2776780
upvote count: 4
downvote count: 0
has body: You can use the option: java -verbose:class which shows what jars are being used
score: 4

http://stackoverflow.com/q/2664807
answer count: 2
possible better answer: http://stackoverflow.com/a/2664911
downvote count: 0
score: 4
has answer: http://stackoverflow.com/a/2671856
favorite count: 0
has comment: http://stackoverflow.com/comment/2682766
accepted answer: http://stackoverflow.com/a/2671856
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2682790
has body: EDIT: i just deleted the entire post and reformulated the question to be more generic. I want to do a simple strategy game: map, units. Map: one class. Units: another class, self drawn. Simple questions: How does an unit should redraw itself on the map. A unit should be a JPanel or similar Swing component (just to be able to manage them as an entity with its own mousehandlers) or can be another thing, without neglecting the fact that it should be an autonomous object with its own action handlers and fields. Is this map-units model correct of a simple game that would help me to learn in a fun way Java and OOP fundamentals. Thats it!
has answer: http://stackoverflow.com/a/2664911
tagged with: java
has title: How should objects be in a Java game
type: Question
upvote count: 4

http://stackoverflow.com/comment/26796441
type: Comment
score: 7
type: AnswerComment
comment on: http://stackoverflow.com/a/2691163
has text: @VipulPurohit For this error, yes, but for the problem behind it: NO! One should not use string operations on floats to perform MATHS

http://stackoverflow.com/q/2727669
has answer: http://stackoverflow.com/a/2727723
has answer: http://stackoverflow.com/a/2727685
answer count: 4
tagged with: buildpath
downvote count: 0
type: UnansweredQuestion
has body: I try to do it the following way: Right click on the name of the project. Click on Build Path in the drop dawn menu. Click on "Configure Build Path" And then I do not know what to do. Should I select "Source", "Projects", "Libraries", "Order and Export"? In "Libraries" I have "Add JARs..." and "Add External JARs...". What should I select? (I have already a .jar file in the lib folder of my project.) ADDED: If I click on "Add JARs" in the "Libraries" tab, I see the "lib" sub-folder but if I go there I do not see my .jar file there (and I know that it is there).
tagged with: java
score: 6
type: Question
upvote count: 6
has title: How can I add a .jar to my build path in Eclipse?
tagged with: eclipse
has answer: http://stackoverflow.com/a/2727692
has answer: http://stackoverflow.com/a/2727683
tagged with: jar
favorite count: 0

http://stackoverflow.com/comment/2704111
has text: Thanks, but what could I put in onError() to stop the submission though? It appears that on the client side there is no script preventing the full form submission from happening. I'm not sure how I could prevent that from happening unless there are no validation errors. I've tried implementing getFailureScript by returning "return false;" to attempt to squash the event, but to no avail.
score: 0
comment on: http://stackoverflow.com/a/2682971
type: AnswerComment
type: Comment

http://stackoverflow.com/q/2638446
has answer: http://stackoverflow.com/a/2638484
possible better answer: http://stackoverflow.com/a/2638475
favorite count: 0
accepted answer: http://stackoverflow.com/a/2638463
answer count: 4
has answer: http://stackoverflow.com/a/2638463
has answer: http://stackoverflow.com/a/2638475
type: AnsweredQuestion
downvote count: 0
score: 1
has title: Why Eclipse does not see .jar file of a library?
tagged with: java
tagged with: eclipse
type: Question
has answer: http://stackoverflow.com/a/42788646
has body: I have a java project in which I have "Referenced Libraries". In the "Referenced Libraries" I have a .jar file of a library that I use (I use only one external library). When I try to "Run -> Run" the code I have a NullPointerException. From my previous experience I know that it it (very likely) because my code does not see the library. I just started to use Eclipse and it can be the I do not "connect" libraries in a correct way. Should I use some options or additional action to force Eclipse to see the .jar file of the library? ADDED: By the right click on the library I get a drop-down menu in which I see "Build Path". My be I need to do something there?
upvote count: 1
tagged with: jar

http://stackoverflow.com/comment/125786417
type: Comment
has text: Nice, works with implements Parceable as well.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/7827593

http://stackoverflow.com/a/2733595
upvote count: 17
has comment: http://stackoverflow.com/comment/2761607
answers question: http://stackoverflow.com/q/2733479
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/3562940
type: Answer
has comment: http://stackoverflow.com/comment/3571050
has comment: http://stackoverflow.com/comment/2761846
accepted answer of: http://stackoverflow.com/q/2733479
score: 17
has body: The reason for including the float type is to some extent historic: it represents a standard IEEE floating point representation from the days when shaving 4 bytes off the size of a floating point number in return for extremely poor precision was a tradeoff worth making. Nowadays, uses for float are pretty limited. But, for example, having the data type can make it easier to write code that needs interoperability with older systems that do use float. As far as performance is concerned, I think the float and double are essentially identical except for the performance of divisions. Generally, whichever you use, the processor converts to its internal format, does the calculation, then converts back again, and the actual calculation effectively takes a fixed time. In the case of divisions, on Intel processors at least, as I recall the time taken to do a division is generally one clock cycle per 2 bits of precision, so that whether you use float or double does make a difference. Unless you really really have a strong reason for using it, in new code, I would generally avoid 'float'.

http://stackoverflow.com/comment/54740020
has text: Did you follow the [installation guide](https://github.com/stagemonitor/stagemonitor/wiki/Installation)?
type: Comment
comment on: http://stackoverflow.com/a/24111032
score: 0
type: AnswerComment

http://stackoverflow.com/comment/2788145
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2756668
has text: @Andrea Why u used `isInterrupted()` and not `interrupted()`? I think that the interrupt status should be cleared when the thread knows that it has been interrupted.
type: AnswerComment

http://stackoverflow.com/comment/2790720
has text: *there are no unit tests in the project* well, that should be a red flag. The use of static methods like this and the lack of DI likely makes unit testing nearly impossible.
score: 4
type: AnswerComment
comment on: http://stackoverflow.com/a/2758924
type: Comment

http://stackoverflow.com/comment/2688505
score: 0
type: Comment
type: AnswerComment
has text: "It is distributed under the terms of the GNU Lesser General Public Licence": http://www.gnu.org/licenses/lgpl.html
comment on: http://stackoverflow.com/a/2669555

http://stackoverflow.com/comment/115934263
comment on: http://stackoverflow.com/a/14729798
has text: Why is it deprecated?
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/2705555
has comment: http://stackoverflow.com/comment/2742817
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2705468
accepted answer of: http://stackoverflow.com/q/2705468
type: Answer
has comment: http://stackoverflow.com/comment/2789351
score: 1
upvote count: 1
downvote count: 0
has body: Here are some PDF open source APIs http://java-source.net/open-source/pdf-libraries This has been asked many time, You might want to look at this post
has comment: http://stackoverflow.com/comment/2742578

http://stackoverflow.com/a/30194260
type: Answer
has body: I am somewhat amazed that such a simple case as setting a null value in a bean, like this: BeanUtils.setProperty(pojo, "date", null); causes crashing behavior, as described above. For what it's worth, here is my workaround: import org.apache.commons.beanutils.BeanMap; BeanMap beanMap = new BeanMap(pojo); Method writeMethod = beanMap.getWriteMethod("date"); writeMethod.invoke(pojo, null);
score: 0
answers question: http://stackoverflow.com/q/2601175

function
tags question: http://stackoverflow.com/q/2712313
tag name: function
tags question: http://stackoverflow.com/q/2709945
tags question: http://stackoverflow.com/q/2704863
type: Tag
tags question: http://stackoverflow.com/q/2785891
tags question: http://stackoverflow.com/q/2752192
tags question: http://stackoverflow.com/q/2761172

http://stackoverflow.com/a/2735673
has comment: http://stackoverflow.com/comment/2764140
score: 0
answers question: http://stackoverflow.com/q/2735657
has comment: http://stackoverflow.com/comment/2763982
has comment: http://stackoverflow.com/comment/2763888
has comment: http://stackoverflow.com/comment/2763808
type: Answer
has body: where you have: DateFormat df = new SimpleDateFormat("dd/MM/yyyy"); try DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
has comment: http://stackoverflow.com/comment/2763817

http://stackoverflow.com/a/2646259
has body: Two things: Make sure you call setRequestMethod to set the HTTP request to be a POST. You should be warned that doing multipart POST requests by hand is difficult and error-prone. If you're running on *NIX, the tool netcat is very useful for debugging this stuff. Run netcat -l -p 3000 and point your program to port 3000; you'll see exactly what the program is sending (Control-C to close it afterwards).
upvote count: 2
has comment: http://stackoverflow.com/comment/2661567
answers question: http://stackoverflow.com/q/2646194
type: Answer
score: 2
downvote count: 0

http://stackoverflow.com/comment/2614592
comment on: http://stackoverflow.com/q/2604614
has text: I didn't downvote, but one problem with the question is that the code is (besides an eyesore for Java conventions and spelling reasons) not relevant to the question.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/2676741
type: AnswerComment
score: 2
has text: I disagree. Prevention without diagnosis is just dogma. Run the diagnosis as part of your CI cycle to avoid the "quick fix" problem.
type: Comment
comment on: http://stackoverflow.com/a/2659021

http://stackoverflow.com/a/2754807
score: 5
downvote count: 0
has body: Java generics are not covariant. See Java Theory and Practice: Generics Gotchas for further details. The page shows a simple example that would havoc the type-system if it was covariant: Imagine you could assign a List&lt;Integer&gt; to a List&lt;Number&gt;. Then the following code would allow you to put something that wasn't an Integer into a List&lt;Integer&gt;: List&lt;Integer&gt; li = new ArrayList&lt;Integer&gt;(); List&lt;Number&gt; ln = li; // illegal ln.add(new Float(3.1415)); // ERROR: Adds a float to list, which is a list of Integers!
type: Answer
upvote count: 5
answers question: http://stackoverflow.com/q/2754756

http://stackoverflow.com/a/2629650
answers question: http://stackoverflow.com/q/2629501
type: Answer
has body: Actually, it does support operator overloading... of a very limited, built-in only nature. For instance "+" is overloaded for String's in addition to the usual arithmetic. Of course, most people want to know why Java does not support user-defined operator overloading. :-) The simplest answer seems to be that the Java creators did not, at the time, see any clean way to add it to the language without making Java a mess (like C++) in the process.
has comment: http://stackoverflow.com/comment/69307316
accepted answer of: http://stackoverflow.com/q/2629501
upvote count: 12
score: 12
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/2615926
has body: Its not very clear what you want to do. But I guess you are trying to get all the occurrences of the string "hello" in your bigger string. If so, you can try: String text = "hello0123456789hello0123456789hello1234567890hello3423243423232"; String match="hello"; for(int i=0; (i = text.indexOf(match,i)) != -1;i += match.length()){ System.out.println(i); } Output: 0 15 30 45 I've used the overloaded version of indexOf which takes the index to start the search from as an argument.
downvote count: 0
type: Answer
score: 2
answers question: http://stackoverflow.com/q/2615889
upvote count: 2

http://stackoverflow.com/a/2598852
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/2611350
has body: Is there any reason you are using Marshalling to achieve this? It will have a set way of defining the XML output so that it knows how to recreate the objects when unmarshalling. So if you really want that XML output using marshalling I think you would need to create a new type called Error and your list would be: private List&lt;Error&gt; messages; And the mapping: &lt;field name="messages" collection="arraylist" type="error" container="false&gt; &lt;bind-xml name="errors" node="element"/&gt; &lt;/field&gt; Alternatively, if you are just looking to create xml output and your content really is as simple as what you have given above then you could just write a toXml() method which loops through the list adding the content exactly as you want it. The inverse can be done with a fromXml() method that parses the XML using DOM or SAX and rebuilds the list of strings.
upvote count: 2
type: Answer
answers question: http://stackoverflow.com/q/2598621

http://stackoverflow.com/q/2599183
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/2602748
tagged with: configuration
has answer: http://stackoverflow.com/a/2599226
score: 0
has answer: http://stackoverflow.com/a/2599467
has answer: http://stackoverflow.com/a/2599316
tagged with: classloader
type: UnansweredQuestion
answer count: 4
has body: I would like to include a default default.properties file in my .jar library. The idea is to allow the user to override my default is he so desires. I'm having trouble getting the classloader to play nicely with this setup, I've tried to look a at popular jars such as log4j, common-* and others and it seems that no one is implementing this idea. Am I going the wrong way? The second best thing is hard coding the values, and using the default if no .properties key has been found, but this sound oh so wrong. Suggestions?
has title: Shipping jar with default .properties file configurations

http://stackoverflow.com/q/2706209
has answer: http://stackoverflow.com/a/2706864
tagged with: swing
has title: When should I write my own Look and Feel for Java Swing instead of customizing one?
type: AnsweredQuestion
score: 2
upvote count: 2
tagged with: java
tagged with: look-and-feel
type: Question
accepted answer: http://stackoverflow.com/a/2706864
possible better answer: http://stackoverflow.com/a/2706746
has answer: http://stackoverflow.com/a/5262487
has answer: http://stackoverflow.com/a/2706746
answer count: 3
downvote count: 0
favorite count: 0
has body: I have used a few different Look and Feels for Java Swing, but I don't really like anyone to 100% so I often end up with customizing it a lot. Sometimes I am thinking about if it is a better idea to write my own LaF (by extending an existing one), but I don't really know. For the moment, I mostly use Nimbus, but I change all colors (to darker ones) and rewrite the appearance of some components, like sliders and scrollbars. I also mostly customize all tables and I am thinking about to change the look of a few other components. When is it recommended to create a new Look-and-Feel instead of customizing one? What are the pros and cons? I.e. customize Nimbus or create a new one by extending Nimbus? Related article: Creating a Custom Look and Feel (old)

http://stackoverflow.com/a/2654053
accepted answer of: http://stackoverflow.com/q/2654025
score: 275
has comment: http://stackoverflow.com/comment/2670626
has comment: http://stackoverflow.com/comment/2670723
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2654025
has comment: http://stackoverflow.com/comment/13217933
has comment: http://stackoverflow.com/comment/62527084
has comment: http://stackoverflow.com/comment/75253106
has comment: http://stackoverflow.com/comment/119636301
type: Answer
has comment: http://stackoverflow.com/comment/88930575
has comment: http://stackoverflow.com/comment/88913578
upvote count: 275
has body: You can use the getters of java.time.LocalDateTime for that. LocalDateTime now = LocalDateTime.now(); int year = now.getYear(); int month = now.getMonthValue(); int day = now.getDayOfMonth(); int hour = now.getHour(); int minute = now.getMinute(); int second = now.getSecond(); int millis = now.get(ChronoField.MILLI_OF_SECOND); // Note: no direct getter available. System.out.printf("%d-%02d-%02d %02d:%02d:%02d.%03d", year, month, day, hour, minute, second, millis); Or, when you're not on Java 8 yet, make use of java.util.Calendar. Calendar now = Calendar.getInstance(); int year = now.get(Calendar.YEAR); int month = now.get(Calendar.MONTH) + 1; // Note: zero based! int day = now.get(Calendar.DAY_OF_MONTH); int hour = now.get(Calendar.HOUR_OF_DAY); int minute = now.get(Calendar.MINUTE); int second = now.get(Calendar.SECOND); int millis = now.get(Calendar.MILLISECOND); System.out.printf("%d-%02d-%02d %02d:%02d:%02d.%03d", year, month, day, hour, minute, second, millis); Either way, this prints as of now: 2010-04-16 15:15:17.816 To convert an int to String, make use of String#valueOf(). If your intent is after all to arrange and display them in a human friendly string format, then better use either Java8's java.time.format.DateTimeFormatter (tutorial here), LocalDateTime now = LocalDateTime.now(); String format1 = now.format(DateTimeFormatter.ISO_DATE_TIME); String format2 = now.atZone(ZoneId.of("GMT")).format(DateTimeFormatter.RFC_1123_DATE_TIME); String format3 = now.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss", Locale.ENGLISH)); System.out.println(format1); System.out.println(format2); System.out.println(format3); or when you're not on Java 8 yet, use java.text.SimpleDateFormat: Date now = new Date(); // java.util.Date, NOT java.sql.Date or java.sql.Timestamp! String format1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.ENGLISH).format(now); String format2 = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.ENGLISH).format(now); String form…
has comment: http://stackoverflow.com/comment/79968470
downvote count: 0

last-modified
type: Tag
tags question: http://stackoverflow.com/q/2641286
tag name: last-modified

http://stackoverflow.com/comment/2727580
type: Comment
has text: This probably won't work for the reason outlined in answers to your other question at http://stackoverflow.com/questions/2702834/commons-exec-hanging-when-i-call-executor-executecommandline
score: 1
comment on: http://stackoverflow.com/a/2702421
type: AnswerComment

http://stackoverflow.com/comment/2644629
comment on: http://stackoverflow.com/a/2629542
type: AnswerComment
score: 3
type: Comment
has text: 'this' is no more a pointer than any other variable. It simply allows an explicit reference to the current object.

http://stackoverflow.com/a/2704900
upvote count: 2
has body: The logic is essentially: map to a list, as you suggest to put something in the map, retrieve the list that corresponds to that key if the list is null, create a new one and map the key to that new list add the item to the list As another poster has mentioned, you could consider a standard multi-map library class such as that provided in Google Collections. (I personally would just implement it myself because it's really simple and doesn't really warrant a whole additional library in my view, but mileage varies.)
has comment: http://stackoverflow.com/comment/2733579
type: Answer
has comment: http://stackoverflow.com/comment/2728482
score: 2
has comment: http://stackoverflow.com/comment/2729069
downvote count: 0
answers question: http://stackoverflow.com/q/2704882

http://stackoverflow.com/comment/2654721
type: Comment
comment on: http://stackoverflow.com/a/2639314
score: 0
type: AnswerComment
has text: @David Maybe a mistake on your side :)

c++
tags question: http://stackoverflow.com/q/2763117
tags question: http://stackoverflow.com/q/2742299
tags question: http://stackoverflow.com/q/2648756
tags question: http://stackoverflow.com/q/2635720
tags question: http://stackoverflow.com/q/2725270
tags question: http://stackoverflow.com/q/2635851
tags question: http://stackoverflow.com/q/2700195
tags question: http://stackoverflow.com/q/2635272
tags question: http://stackoverflow.com/q/2772310
tags question: http://stackoverflow.com/q/2655405
type: Tag
tags question: http://stackoverflow.com/q/2685626
tags question: http://stackoverflow.com/q/2638986
tags question: http://stackoverflow.com/q/2648877
tags question: http://stackoverflow.com/q/2617313
tags question: http://stackoverflow.com/q/2678423
tags question: http://stackoverflow.com/q/2634135
tags question: http://stackoverflow.com/q/2657298
tags question: http://stackoverflow.com/q/2623277
tags question: http://stackoverflow.com/q/2631425
tags question: http://stackoverflow.com/q/2727860
tags question: http://stackoverflow.com/q/2762556
tags question: http://stackoverflow.com/q/2775303
tags question: http://stackoverflow.com/q/2761223
tags question: http://stackoverflow.com/q/2756243
tags question: http://stackoverflow.com/q/2654752
tags question: http://stackoverflow.com/q/2748056
tags question: http://stackoverflow.com/q/2630529
tags question: http://stackoverflow.com/q/2609706
tags question: http://stackoverflow.com/q/2628356
tags question: http://stackoverflow.com/q/2716749
tags question: http://stackoverflow.com/q/2749889
tags question: http://stackoverflow.com/q/2745777
tags question: http://stackoverflow.com/q/2656494
tags question: http://stackoverflow.com/q/2650893
tags question: http://stackoverflow.com/q/2756233
tags question: http://stackoverflow.com/q/2741846
tags question: http://stackoverflow.com/q/2651730
tag name: c++
tags question: http://stackoverflow.com/q/2690031
tags question: http://stackoverflow.com/q/2657819

http://stackoverflow.com/q/2625506
type: Question
has comment: http://stackoverflow.com/comment/2641230
has comment: http://stackoverflow.com/comment/2643440
score: -1
answer count: 2
has comment: http://stackoverflow.com/comment/2641263
tagged with: user-interface
accepted answer: http://stackoverflow.com/a/2625528
favorite count: 0
has body: Currently I am using Netbeans to develop applications in Swing, but Netbeans is very very slow. Can anyone suggest me a comprehensive Swing development GUI like Netbeans but lightweight Thanks
has title: Can you suggest me a fast Swing IDE
tagged with: swing
type: AnsweredQuestion
tagged with: netbeans
possible better answer: http://stackoverflow.com/a/2628224
tagged with: java
downvote count: 2
upvote count: 1
has answer: http://stackoverflow.com/a/2628224
has answer: http://stackoverflow.com/a/2625528

http://stackoverflow.com/a/2711062
answers question: http://stackoverflow.com/q/2710458
has comment: http://stackoverflow.com/comment/2741244
score: 2
has comment: http://stackoverflow.com/comment/2741302
has comment: http://stackoverflow.com/comment/2742189
downvote count: 0
has body: Don't really understand the question. Each component can have a different background color so what background color do you want your custom component to use? I would guess generally speaking the background color of a LAF would be determined by a JPanel, so I guess your custom component could just extend JPanel and you don't have to worry about this. If you want to query the default backgroud colors of every component then you can use the UIManager to look it up. See the UIManager Defaults example.
upvote count: 2
type: Answer

http://stackoverflow.com/q/2773266
tagged with: java
tagged with: apache-commons-vfs
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/2807065
downvote count: 0
has title: Commons VFS and IBM MVS System
has answer: http://stackoverflow.com/a/2913776
has answer: http://stackoverflow.com/a/2855259
tagged with: unix
favorite count: 0
type: UnansweredQuestion
upvote count: 1
has body: I'm using Apache Commons VFS / SFTP, we are trying to download files from the IBM MVS system. The download part is all good, however, we can not open up the zipped files after downloading. Seems like the zip file was compressed using a different algorithm or something Anyone has any pointers? *Note, the same function works fine if we connect to a regular unix/linux SFTP server. Below is an example of what we did String defaultHost = "[my sftp ip address]"; String host = defaultHost; String defaultRemotePath = "//__root.dir1.dir2."; String remotePath = defaultRemotePath; String user = "test"; String password = "test"; String remoteFileName = "Blah.ZIP.BLAH"; log.info("FtpPojo() begin instantiation"); FileObject localFileObject = fsManager.resolveFile("C:/Work/Blah.ZIP.BLAH"); log.debug("local file name is :"+localFileObject.getName().getBaseName()); log.debug("FtpPojo() instantiated and fsManager created"); String uri = createSftpUri(host, user, password) + ":322"+remotePath+remoteFileName; remoteRepo = fsManager.resolveFile(uri, fsOptions); remoteRepo.copyFrom(localFileObject, Selectors.SELECT_ALL);
score: 1

http://stackoverflow.com/comment/2815499
score: 0
comment on: http://stackoverflow.com/q/2780442
type: QuestionComment
type: Comment
has text: @phoenix24 no..its noy windows -xp specific

http://stackoverflow.com/a/2718848
answers question: http://stackoverflow.com/q/2718565
type: AcceptedAnswer
downvote count: 6
upvote count: 37
has comment: http://stackoverflow.com/comment/54327595
has body: That's the way I do it: // in some.class.with.Constants public static final boolean DEV_MODE = true; // in some other class import static some.class.with.Constants.DEV_MODE; if(DEV_MODE){ Log.d('sometag', 'somemessage'); }
has comment: http://stackoverflow.com/comment/2745138
type: Answer
has comment: http://stackoverflow.com/comment/54331631
score: 31
accepted answer of: http://stackoverflow.com/q/2718565

http://stackoverflow.com/a/2633781
answers question: http://stackoverflow.com/q/2633582
type: Answer
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/2647618
has body: You should create your own class, something like "CustomPanel" that extends from JPanel. You put that class in its own file, and everything that goes on the JPanel should be a part of that class. Then, instead of adding a JPanel to the tabbed panel, you create an instance of CustomPanel and add it to the tabbed panel.
has comment: http://stackoverflow.com/comment/2647579
downvote count: 0
has comment: http://stackoverflow.com/comment/2647875

http://stackoverflow.com/q/2736356
linked to: http://stackoverflow.com/q/2725141
has comment: http://stackoverflow.com/comment/2926805
tagged with: character-encoding
has comment: http://stackoverflow.com/comment/2936094
answer count: 2
has answer: http://stackoverflow.com/a/2880716
downvote count: 0
tagged with: applet
possible better answer: http://stackoverflow.com/a/2884952
has comment: http://stackoverflow.com/comment/2764594
favorite count: 0
has answer: http://stackoverflow.com/a/2884952
upvote count: 2
has comment: http://stackoverflow.com/comment/2932646
has body: i have a java applet application in which i use rich text area . i write URDU the national language of PAKISTAN. i managed to do so with uni codes. the problem is, when i write urdu in text area and select a font and color for each line it do all of this but when i save this file using UTF-8 encoding and then open it again it shows all text formatted as i choose format of last line. my requirement is to open file as it is saved. i mean each file should have same formatting as i done before saving. I'm still suffering with this problem even after bounty can any one help! dated 07-06-2010.
score: 2
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2880716
tagged with: java
type: Question
has title: how to manage formatting of text when read a save file?

http://stackoverflow.com/comment/2770773
comment on: http://stackoverflow.com/q/2741677
type: Comment
has text: @dalton: Yes, referencing related questions helps answerers understand the context. It also clarifies whether the question is a duplicate.
score: 0
type: QuestionComment

http://stackoverflow.com/q/2771669
downvote count: 1
has title: Extending abstract classes in c#
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/2771997
has body: I am a Java developer and I have noticed some differences in extending abstract classes in c# as opposed to Java. I was wondering how a c# developer would achived the following. 1) Covarience public abstract class A { public abstract List&lt;B&gt; List(); } public class BList : List&lt;B&gt; { } public abstract class C : A { public abstract BList List(); } So in the above hierarchy, there is covarience in C where it returns a type compatible with what A returns. However this gives me an error in Visual Studio. Is there a way to specify a covarient return type in c#? 2) Adding a setter to a property public abstract class A { public abstract String Name { get; } } public abstract class B : A { public abstract String Name { get; set } } Here the compiler complains of hiding. Any suggestions? Please do not suggest using interfaces unless that is the ONLY way to do this.
type: Question
tagged with: c#
answer count: 2
has answer: http://stackoverflow.com/a/2774526
has comment: http://stackoverflow.com/comment/2808199
favorite count: 0
upvote count: 2
type: UnansweredQuestion

http://stackoverflow.com/a/2624237
has comment: http://stackoverflow.com/comment/2643142
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2649889
has comment: http://stackoverflow.com/comment/2637323
has comment: http://stackoverflow.com/comment/101208306
has body: I completely disagree. To me the model is correct. A RuntimeException is one which most typically denotes a serious error in the logic of the programming (such as ArrayIndexOutOfBounds, NullPointer, or IllegalArgument) or something that the runtime has otherwise determined really shouldn't be happening (such as SecurityException). Conversely IOException and its derivatives are exceptions that could reasonably occur during normal execution of a program, and common logic would dictate that either those problems should be dealt with, or at least the programmer should be aware that they can occur. For example with Files if your application logger can't write its data would you rather be forced to catch a potential IOException and recover, or have something that may not be critical to your app bring down the whole JVM because no one thought to catch the unchecked Exception (as you may have guessed, I'll choose the former). I think that there are many situations in which an IOException is either recoverable, or at the least the programmer should be explicitly aware of the potential so that if it is not recoverable the system might be able to crash more "gently". As far your thought of if the system can not recover there are always alternatives with a checked exception. You can always have your methods declare it in their throws, throw a runtime exception of their own or crash the JVM violently: public void doit() throws IOException { try{ }catch(IOException e){ // try to recover ... // can't recover throw e; } } public void doit() { try{ }catch(IOException e){ // try to recover ... // can't recover throw new RuntimeException(e); } } public void doit() { try{ }catch(IOException e){ // try to recover ... // OH NO!!!! System.exit(Constant.UNRECOVERABLE_IO_ERROR); } }
has comment: http://stackoverflow.com/comment/23453509
accepted answer of: http://stackoverflow.com/q/2624145
has comment: http://stackoverflow.com/comment/2642198
score: 28
has comment: http://stackoverflow.com/comment/2740596
answers question: http://stackoverflow.com/q/2624145
has comment: http://stackoverflow.com/comment/2637030
type: Answer
upvote count: 31
downvote count: 3
has comment: http://stackoverflow.com/comment/2640792
has comment: http://stackoverflow.com/comment/2740502
has comment: http://stackoverflow.com/comment/2746258
has comment: http://stackoverflow.com/comment/2637134

http://stackoverflow.com/q/2698296
type: Question
accepted answer: http://stackoverflow.com/a/2698506
tagged with: grails
has answer: http://stackoverflow.com/a/2698506
upvote count: 1
answer count: 1
has body: I want to put my images to db but i want to have a link on each image. So I have the idea to copy the image to the temp dir of tomcat (or weblogic). But I must map the tempdir to a virtual path. How do it ?
tagged with: tomcat
favorite count: 0
has title: How to create virtual path to tempdir tomcat?
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java

http://stackoverflow.com/comment/87045232
type: Comment
has text: @BilltheLizard - You are absolutely correct. Java is a combination of both i.e its a compiled as well as interpreted language. First it is compiled into byte code and then the JVM interprets that compiled byte code line by line and converts it to the machine language that can run on the underlying OS and CPU architecture.
comment on: http://stackoverflow.com/a/2657276
score: 0
type: AnswerComment

http://stackoverflow.com/q/2738574
has title: Java "constant string too long" compile error. Only happens using Ant, not when using Eclipse
favorite count: 0
answer count: 12
has answer: http://stackoverflow.com/a/2738630
has answer: http://stackoverflow.com/a/2738598
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/48109377
has answer: http://stackoverflow.com/a/70745855
has answer: http://stackoverflow.com/a/18784142
tagged with: ant
tagged with: java
has comment: http://stackoverflow.com/comment/5713446
has answer: http://stackoverflow.com/a/2744297
tagged with: eclipse
type: Question
has answer: http://stackoverflow.com/a/45796412
has answer: http://stackoverflow.com/a/42878612
possible better answer: http://stackoverflow.com/a/18784142
accepted answer: http://stackoverflow.com/a/2738598
downvote count: 0
has answer: http://stackoverflow.com/a/31509628
score: 72
has answer: http://stackoverflow.com/a/60931084
upvote count: 72
has body: I have a few really long strings in one class for initializing user information. When I compile in Eclipse, I don't get any errors or warnings, and the resulting .jar runs fine. Recently, I decided to create an ant build file to use. Whenever I compile the same class with ant, I get the "constant string too long" compile error. I've tried a number of ways to set the java compiler executable in ant to make sure that I'm using the exact same version as in Eclipse. I'd rather figure out how to get the same successful compile I get in Eclipse in Ant than try to rework the code to dynamically concatenate the strings.
has answer: http://stackoverflow.com/a/63415515
has answer: http://stackoverflow.com/a/51708807

http://stackoverflow.com/comment/118563760
type: Comment
has text: What does this part mean: `You can't ask what value a given key maps to, nor can you delete the entry for a given key without knowing what value it maps to.` ?!?
comment on: http://stackoverflow.com/a/2651833
type: AnswerComment
score: 0

enums
tags question: http://stackoverflow.com/q/2746807
tags question: http://stackoverflow.com/q/2668141
tags question: http://stackoverflow.com/q/2708272
tags question: http://stackoverflow.com/q/2601616
tags question: http://stackoverflow.com/q/2636845
tags question: http://stackoverflow.com/q/2715004
tags question: http://stackoverflow.com/q/2751733
tag name: enums
tags question: http://stackoverflow.com/q/2663980
tags question: http://stackoverflow.com/q/2709593
tags question: http://stackoverflow.com/q/2765687
type: Tag
tags question: http://stackoverflow.com/q/2647677
tags question: http://stackoverflow.com/q/2780129
tags question: http://stackoverflow.com/q/2699750
tags question: http://stackoverflow.com/q/2705585
tags question: http://stackoverflow.com/q/2681029
tags question: http://stackoverflow.com/q/2642281
tags question: http://stackoverflow.com/q/2711862
tags question: http://stackoverflow.com/q/2637890

http://stackoverflow.com/q/2746258
type: UnansweredQuestion
type: Question
has answer: http://stackoverflow.com/a/2773477
score: 0
tagged with: java
answer count: 1
has body: Recently I have debugging into a problem where a connection to a database server from the application server get reset. I am pretty sure there is no reset being called from either end. But while I was debugging into the problem, while inspecting the SocketException, I found the walkback variable. arg0 SocketException (id=11532) cause SocketException (id=11532) detailMessage "Connection reset" stackTrace null walkback long[50] (id=11618) What do the values in this variable represent? UPDATE The issue was a firewall killing long running idle connections.
has title: What values do the walkback array in the SocketException contain?

http://stackoverflow.com/comment/2710307
type: Comment
score: 0
has text: Then I'd have to create an instance of the class. Correct me if I'm wrong, but regarding it's purpose that doesn't seem to be usefull here.
type: QuestionComment
comment on: http://stackoverflow.com/q/2689312

http://stackoverflow.com/comment/2779013
score: 1
has text: JNA or JNI would seem to be the only factor to me, and those are pretty rare in real world use. Even then, the bytecode can still always be moved without recompiling - it's just you may have to also re-compile the libraries the JNI is expecting to be there. The byte code is still portable though.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2748912

http://stackoverflow.com/q/2738886
answer count: 3
has comment: http://stackoverflow.com/comment/2767473
has answer: http://stackoverflow.com/a/2738968
linked to: http://stackoverflow.com/q/113511
upvote count: 46
favorite count: 0
tagged with: hash
has answer: http://stackoverflow.com/a/2741898
has body: I'm wondering what is the best practice for writing #hashCode() method in java. Good description can be found here. Is it that good?
linked to: http://stackoverflow.com/q/2735037
downvote count: 0
has comment: http://stackoverflow.com/comment/2767515
has answer: http://stackoverflow.com/a/2739208
accepted answer: http://stackoverflow.com/a/2739208
has comment: http://stackoverflow.com/comment/2767605
has comment: http://stackoverflow.com/comment/2770930
type: Question
type: AnsweredQuestion
tagged with: java
possible better answer: http://stackoverflow.com/a/2741898
has comment: http://stackoverflow.com/comment/2767448
score: 46
has title: What is a best practice of writing hash function in java?

jtextpane
tags question: http://stackoverflow.com/q/2725141
tags question: http://stackoverflow.com/q/2750073
tag name: jtextpane
type: Tag
tags question: http://stackoverflow.com/q/2735808
tags question: http://stackoverflow.com/q/2723073
tags question: http://stackoverflow.com/q/2678812
tags question: http://stackoverflow.com/q/2645834
tags question: http://stackoverflow.com/q/2741598
tags question: http://stackoverflow.com/q/2759880

http://stackoverflow.com/comment/2755693
type: Comment
score: 1
comment on: http://stackoverflow.com/a/2728499
has text: If a.length does not divide evenly by 5 the array will not be big enough, and various exceptions will be thrown inside the for loop.
type: AnswerComment

http://stackoverflow.com/comment/2846909
score: 0
has text: @Ruepen: did you succeed in finding out what caused the exception?
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2778988

http://stackoverflow.com/comment/2635956
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2622641
has text: I've been thinking about this and am not sure whether it goes against the definition that an Iterator is "An iterator over a collection". See my latest edit.
type: Comment

http://stackoverflow.com/a/18848086
answers question: http://stackoverflow.com/q/2642777
has comment: http://stackoverflow.com/comment/39399331
type: Answer
upvote count: 1
has body: There a many answers above but I wasn't able to get any of them working correctly (with my limited time), so for anyone else in the same situation you can try the code below which worked perfectly for my java testing purposes: public static HttpClient wrapClient(HttpClient base) { try { SSLContext ctx = SSLContext.getInstance("TLS"); X509TrustManager tm = new X509TrustManager() { public void checkClientTrusted(X509Certificate[] xcs, String string) throws CertificateException { } public void checkServerTrusted(X509Certificate[] xcs, String string) throws CertificateException { } public X509Certificate[] getAcceptedIssuers() { return null; } }; ctx.init(null, new TrustManager[]{tm}, null); SSLSocketFactory ssf = new SSLSocketFactory(ctx); ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); ClientConnectionManager ccm = base.getConnectionManager(); SchemeRegistry sr = ccm.getSchemeRegistry(); sr.register(new Scheme("https", ssf, 443)); return new DefaultHttpClient(ccm, base.getParams()); } catch (Exception ex) { return null; } } and call like: DefaultHttpClient baseClient = new DefaultHttpClient(); HttpClient httpClient = wrapClient(baseClient ); Reference: http://tech.chitgoks.com/2011/04/24/how-to-avoid-javax-net-ssl-sslpeerunverifiedexception-peer-not-authenticated-problem-using-apache-httpclient/
score: -3
downvote count: 4

http://stackoverflow.com/a/2694490
has comment: http://stackoverflow.com/comment/2716345
answers question: http://stackoverflow.com/q/2694470
upvote count: 5
has comment: http://stackoverflow.com/comment/2716243
has comment: http://stackoverflow.com/comment/2716455
has comment: http://stackoverflow.com/comment/2716567
score: 5
downvote count: 0
has comment: http://stackoverflow.com/comment/2716249
has comment: http://stackoverflow.com/comment/2716226
type: Answer
has body: It appears that you have defined a class called Rand somewhere in your project. Don't use this for a variable name. I'd suggest using random with a small r. Also, this line is illegal: int a - 0 ; You should probably remove it as otherwise you are defining a twice.

http://stackoverflow.com/comment/2769258
has text: this is a theoritical exercise, there's no actual app, so i can't do any load testing.. @Neil : I'm interested by your comment on the "simultaneous" connections : what differences will it make ? (feel free to really answer)
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2739983

http://stackoverflow.com/a/2706085
has comment: http://stackoverflow.com/comment/2730834
has comment: http://stackoverflow.com/comment/2729970
has comment: http://stackoverflow.com/comment/2731362
score: 20
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2732076
has comment: http://stackoverflow.com/comment/2729791
type: Answer
has comment: http://stackoverflow.com/comment/2729758
accepted answer of: http://stackoverflow.com/q/2706069
upvote count: 20
downvote count: 0
answers question: http://stackoverflow.com/q/2706069
has body: Object is an exception to the first rule, and has no superclass. From JLS3 8.1.4: The extends clause must not appear in the definition of the class Object, because it is the primordial class and has no direct superclass. You can also try it out with reflection: Object.class.getSuperclass(); // returns null

http://stackoverflow.com/a/2607867
accepted answer of: http://stackoverflow.com/q/2607800
type: AcceptedAnswer
downvote count: 0
type: Answer
has body: When you do this, next points to the same thing as current bag, so all changes to next are reflected in currentBag. In your getNext() method: while (!valid) { next = this.currentBag; ... } Try this instead: while (!valid) { next = new ArrayList&lt;Boolean&gt;(this.currentBag); ... }
upvote count: 3
answers question: http://stackoverflow.com/q/2607800
score: 3

http://stackoverflow.com/a/77296696
type: Answer
answers question: http://stackoverflow.com/q/2735736
has comment: http://stackoverflow.com/comment/136313401
downvote count: 1
score: -1
upvote count: 0
has body: According to one of the text book that I have refered tells that, "const is a Java keyword but it is not being used now to create constants. so, you need to use final keyword"

http://stackoverflow.com/a/2778418
has body: Exceptions are always caught by the first surrounding try/catch block that matches the type of the exception that is being thrown. The try/catch block will match if it catches exception of the same type as the exception or one of the parent types. Most likely your two project differ in what type of the exception they catch in the block that is calling the checkParticleLightRestriction method.
score: 0
answers question: http://stackoverflow.com/q/2778386
type: Answer

http://stackoverflow.com/a/8926837
downvote count: 2
upvote count: 56
type: Answer
answers question: http://stackoverflow.com/q/2598712
score: 54
has body: You can use the @Scheduled annotation, but together with the cron parameter only: @Scheduled(cron = "${yourConfiguration.cronExpression}") Your 5 seconds interval could be expressed as "*/5 * * * * *". However as I understand you cannot provide less than 1 second precision.
has comment: http://stackoverflow.com/comment/21585453

http://stackoverflow.com/q/2697310
tagged with: security
has title: why it is good idea to disable REFRESH in web application(for security purposes)
type: Question
has body: we are doing XSRF fixes for our code. we are using the session token to request token comparison method to achieve this. in case when session token is not equal to request token we will be redirecting to error page. Problem:Once we are in Main Menu page, if the user "refresh" the page, it is throwing XSRF issue. Reason: As there wont be any request token(when we do a page refresh). since request token is NULL and it is not equal to session token it was throwing XSRF error. The users of the application are not very happy with this approach. so is there any way to enable page refresh? or is it absolutely necessary/important to disable the page refresh(for security)? Thanks in advance.
tagged with: java
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/2698567
tagged with: csrf
type: UnansweredQuestion

http://stackoverflow.com/q/2653591
upvote count: 6
has title: Decrypting “long” message encrypted with RSA java
favorite count: 0
accepted answer: http://stackoverflow.com/a/2654368
tagged with: jce
linked to: http://stackoverflow.com/q/295436
downvote count: 0
has answer: http://stackoverflow.com/a/2654368
tagged with: encryption
tagged with: encryption-asymmetric
score: 6
possible better answer: http://stackoverflow.com/a/23723450
has answer: http://stackoverflow.com/a/23723450
type: AnsweredQuestion
has body: Hi this is the same question, that was asked two years ago: Java/JCE: Decrypting “long” message encrypted with RSA I had a large byte array and rsa keypair, initiated by value 1024. Using rsa encryption and the specified size of the key is strong requirement, I can't change it. So I can't use symmetric encryption with asymetric encryption symmetric key. I can't use any other keys. I had a byte array and need ciphered byte array to be returned. I wonder if there is any ready tool, that can manage with this problem? Sorry for such an amateurish question, but I really need a help.
tagged with: java
tagged with: rsa
type: Question
answer count: 2

ssl-certificate
tags question: http://stackoverflow.com/q/2762080
type: Tag
tags question: http://stackoverflow.com/q/2759911
tags question: http://stackoverflow.com/q/2694281
tags question: http://stackoverflow.com/q/2767047
tags question: http://stackoverflow.com/q/2698841
tag name: ssl-certificate

http://stackoverflow.com/a/2682086
has comment: http://stackoverflow.com/comment/2702051
score: 1
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2681359
has body: Does it have to be Java? On Naked Objects for .NET (see www.nakedobjects.net) we are currently working on a brand new variant called Naked Objects MVC, which combines Naked Objects with ASP.NET MVC. This gives you a 100% generic HTML UI, which you can then customise as much as you want when you are ready to do that. We're a few weeks away from releasing the Beta.
upvote count: 1

http://stackoverflow.com/comment/29488418
has text: @BradCupit I also had this error (and didn't want to stop using the LevelChangePropagator for performance reasons). Though I found it hard to believe, Meriton's solution (below) worked for me and allowed me to keep it.
comment on: http://stackoverflow.com/a/8472969
type: AnswerComment
type: Comment
score: 1

http://stackoverflow.com/q/2669724
tagged with: java
tagged with: hibernate
type: Question
has answer: http://stackoverflow.com/a/21872298
has answer: http://stackoverflow.com/a/5225253
has body: I'm trying to use Hibernate to persist a class that looks like this: public class Item implements Serializable, Comparable&lt;Item&gt; { // Item id private Integer id; // Description of item in inventory private String description; // Number of items described by this inventory item private int count; //Category item belongs to private String category; // Date item was purchased private GregorianCalendar purchaseDate; public Item() { } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public int getCount() { return count; } public void setCount(int count) { this.count = count; } public String getCategory() { return category; } public void setCategory(String category) { this.category = category; } public GregorianCalendar getPurchaseDate() { return purchaseDate; } public void setPurchasedate(GregorianCalendar purchaseDate) { this.purchaseDate = purchaseDate; } My Hibernate mapping file contains the following: &lt;property name="puchaseDate" type="java.util.GregorianCalendar"&gt; &lt;column name="purchase_date"&gt;&lt;/column&gt; &lt;/property&gt; When I try to run, I get error messages indicating there is no getter function for the purchaseDate attribute: 577 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!) 577 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20 577 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false 592 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/home_inventory 592 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=root, password=****} 1078 [main] INFO…
downvote count: 0
answer count: 7
favorite count: 0
has title: Hibernate unable to instantiate default tuplizer - cannot find getter
tagged with: tuplizer
has answer: http://stackoverflow.com/a/4427657
has answer: http://stackoverflow.com/a/21079417
has answer: http://stackoverflow.com/a/3525309
has answer: http://stackoverflow.com/a/2669745
type: UnansweredQuestion
score: 16
has answer: http://stackoverflow.com/a/2669763
upvote count: 16

http://stackoverflow.com/a/21409975
upvote count: 4
has comment: http://stackoverflow.com/comment/44707418
has comment: http://stackoverflow.com/comment/49620992
has comment: http://stackoverflow.com/comment/60233637
has comment: http://stackoverflow.com/comment/50177524
has comment: http://stackoverflow.com/comment/50177591
answers question: http://stackoverflow.com/q/2779484
has comment: http://stackoverflow.com/comment/50143031
type: Answer
has comment: http://stackoverflow.com/comment/50083321
has comment: http://stackoverflow.com/comment/49619705
has comment: http://stackoverflow.com/comment/50090081
has body: This basically has to do with the hardware architecture (i.e. RAM and caches). If you don't use synchronized together with wait() or notify(), another thread could enter the same block instead of waiting for the monitor to enter it. Moreover, when e.g. accessing an array without a synchronized block, another thread may not see the changement to it...actually another thread will not see any changements to it when it already has a copy of the array in the x-level cache (a.k.a. 1st/2nd/3rd-level caches) of the thread handling CPU core. But synchronized blocks are only one side of the medal: If you actually access an object within a synchronized context from a non-synchronized context, the object still won't be synchronized even within a synchronized block, because it holds an own copy of the object in its cache. I wrote about this issues here: https://stackoverflow.com/a/21462631 and When a lock holds a non-final object, can the object&#39;s reference still be changed by another thread? Furthermore, I'm convinced that the x-level caches are responsible for most non-reproducible runtime errors. That's because the developers usually don't learn the low-level stuff, like how CPU's work or how the memory hierarchy affects the running of applications: http://en.wikipedia.org/wiki/Memory_hierarchy It remains a riddle why programming classes don't start with memory hierarchy and CPU architecture first. "Hello world" won't help here. ;)
has comment: http://stackoverflow.com/comment/50184374
downvote count: 1
has comment: http://stackoverflow.com/comment/32387245
has comment: http://stackoverflow.com/comment/50090034
score: 3
has comment: http://stackoverflow.com/comment/50177679
has comment: http://stackoverflow.com/comment/50090003
has comment: http://stackoverflow.com/comment/49631218
has comment: http://stackoverflow.com/comment/49631175

http://stackoverflow.com/comment/68501191
type: Comment
comment on: http://stackoverflow.com/q/2749689
score: 7
has text: The DB table with the foreign key column is treated as owning side. So the business entity representing that DB table is the Owner(Owning-side) of that relation. Not neccessarily, but most of the cases Owning-side will have @JoinColumn annotation.
type: QuestionComment

http://stackoverflow.com/a/2679965
has comment: http://stackoverflow.com/comment/2902120
has comment: http://stackoverflow.com/comment/2902924
type: Answer
accepted answer of: http://stackoverflow.com/q/2676114
answers question: http://stackoverflow.com/q/2676114
has body: Unlike Oracle, I'm not sure that the Jaybird JDBC driver supports the RETURNING syntax. Alternatively, you might look at the getGeneratedKeys() method , discussed here.
score: 0
type: AcceptedAnswer

http://stackoverflow.com/comment/100427772
score: 0
type: Comment
has text: it has been 50 years since we landed on moon,,, and tuple still ain't part of Java core library woahhh
comment on: http://stackoverflow.com/a/2754377
type: AnswerComment

http://stackoverflow.com/a/54125198
type: Answer
has body: I tried like this it is working. Give me some suggestion if i am wrong. import java.lang.reflect.Constructor; class TestCon { private TestCon() { System.out.println("default constructor...."); } public void testMethod() { System.out.println("method executed."); } } class TestPrivateConstructor { public static void main(String[] args) { try { Class testConClass = TestCon.class; System.out.println(testConClass.getSimpleName()); Constructor[] constructors = testConClass.getDeclaredConstructors(); constructors[0].setAccessible(true); TestCon testObj = (TestCon) constructors[0].newInstance(); //we can call method also.. testObj.testMethod(); } catch (Exception e) { e.printStackTrace(); } } }
answers question: http://stackoverflow.com/q/2599440
score: 0

http://stackoverflow.com/a/2707548
upvote count: 6
has body: The reason why you need to @Override neither or both, is because of the way they interrelate with the rest of the API. You'll find that if you put m1 into a HashSet&lt;MyCustomObject&gt;, then it doesn't contains(m2). This is inconsistent behavior and can cause a lot of bugs and chaos. The Java library has tons of functionalities. In order to make them work for you, you need to play by the rules, and making sure that equals and hashCode are consistent is one of the most important ones.
type: Answer
score: 6
answers question: http://stackoverflow.com/q/2707541
downvote count: 0

http://stackoverflow.com/a/16141632
score: 1
answers question: http://stackoverflow.com/q/2690031
downvote count: 0
has body: A chat application that is based on P2P connection is difficult to be formed mainly due to NAT firewalls under which most of the users are. You can study IETF standards like ICE,STUN, TURN, SIP and son on. Though implementing these is a herculean task. But, RTMFP is an easy solution for implementing P2P voice and video chat app. It is developed by Adobe and can be easily used by any flash developer in his application. Its free and easy to implement.U just need to know flash development for this. Also Study Adobe Cirrus and Adobe AIR for desktop apps. Cheers!!!
type: Answer
upvote count: 1

http://stackoverflow.com/comment/2677473
score: 2
has text: the constructor argument shouldn't matter. what's the error you're getting and what is the definition of the variable `terms`?
comment on: http://stackoverflow.com/q/2660295
type: QuestionComment
type: Comment

http://stackoverflow.com/a/2748024
has body: The closest you can get is a static field outside the method: private static int x; public [static] void Foo() { x++; } Closure example as requested: using System; class Program { private static readonly Action incrementCount; private static readonly Func&lt;int&gt; getCount; static Program() { int x = 0; incrementCount = () =&gt; x++; getCount = () =&gt; x; } public void Foo() { incrementCount(); incrementCount(); Console.WriteLine(getCount()); } static void Main() { // show it working from an instance new Program().Foo(); } }
has comment: http://stackoverflow.com/comment/2777779
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2778825
has comment: http://stackoverflow.com/comment/2777795
score: 6
type: Answer
accepted answer of: http://stackoverflow.com/q/2748018
upvote count: 6
answers question: http://stackoverflow.com/q/2748018
has comment: http://stackoverflow.com/comment/2778232
has comment: http://stackoverflow.com/comment/2782542

http://stackoverflow.com/a/2623255
answers question: http://stackoverflow.com/q/2623213
score: 0
type: Answer
upvote count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/2635737
has body: public string FirstLine(string inputstring) { //split the given string using newline character string[] strarray = inputstring.Split('\n'); //return the first element in the array as that is the first line return strarray[0]; }

http://stackoverflow.com/a/8505318
type: Answer
upvote count: 5
score: 5
downvote count: 0
answers question: http://stackoverflow.com/q/2670124
has body: Based on previous answers and further Google'ing I made a test in which a Thread continously appends Strings to a JTextArea in a JScrollPane. I think it is important to use invokeLater here, since the JScrollBar needs to be updated with its new maximum value before we scroll to that value. Using invokeLater, the AWT Thread will take care of this. private class AppendThread extends Thread { public void run() { while (true) { String s = "random number = " + Math.random() + "\n"; boolean scrollDown = textAreaBottomIsVisible(); textArea.append(s); if (scrollDown) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { JScrollBar bar = scrollPane.getVerticalScrollBar(); bar.setValue(bar.getMaximum()); } } ); } try { Thread.sleep(1000); } catch (Exception e) { System.err.println("exception = " + e); } } } private boolean textAreaBottomIsVisible() { Adjustable sb = scrollPane.getVerticalScrollBar(); int val = sb.getValue(); int lowest = val + sb.getVisibleAmount(); int maxVal = sb.getMaximum(); boolean atBottom = maxVal == lowest; return atBottom; } }

http://stackoverflow.com/a/2687604
has comment: http://stackoverflow.com/comment/2708501
upvote count: 11
has body: int count = 0; for (String item : cart) { if (products.contains(item)) count++; } }
type: Answer
score: 11
downvote count: 0
answers question: http://stackoverflow.com/q/2687599

http://stackoverflow.com/a/2645379
has comment: http://stackoverflow.com/comment/2660642
has comment: http://stackoverflow.com/comment/2661310
score: 17
has comment: http://stackoverflow.com/comment/2662604
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2644688
has comment: http://stackoverflow.com/comment/2661865
has comment: http://stackoverflow.com/comment/2660782
has comment: http://stackoverflow.com/comment/2660714
type: Answer
has comment: http://stackoverflow.com/comment/2660692
has body: Your producer thread simply puts more elements than the consumer consumes, so the queue eventually hits its capacity limit, thus the producer waits. Consolidating my original answer since now we have basically the full picture: You hit the inherent throughput limit of the LinkedBlockingQueue (every queue has one) by doing extremely fast put()s, where even continual take()s, with zero further processing, cannot keep up. (By the way this shows that in this structure, on your JVM and machine anyway, put()s are at least slightly more costly than the reads). Since there is a particular lock that consumers lock, putting more consumer threads could not possibly help (if your consumer was actually doing some processing and that was bounding the throughput, then adding more consumers would help. There are better queue implementations for a scenario with more than one consumers (or producers), you could try SynchronousQueue, ConcurrentLinkedQueue, and the upcoming TransferQueue of jsr166y). Some suggestions: Try to make more coarse-grained objects, so that the overhead of queueing each is balanced with the actual work that is offloaded from the producing thread (in your case, it seems you create much communication overhead for objects that represent negligible amounts of work) You could also have the producer help the consumer by offloading some consuming work (not much point in waiting idly when there is work to be done). /updated after John W. rightly pointed out my original answer was misleading
accepted answer of: http://stackoverflow.com/q/2644688
has comment: http://stackoverflow.com/comment/2662744
has comment: http://stackoverflow.com/comment/2662030
has comment: http://stackoverflow.com/comment/2662887
upvote count: 17
has comment: http://stackoverflow.com/comment/2663881

http://stackoverflow.com/comment/133400174
type: Comment
comment on: http://stackoverflow.com/a/4027996
score: 0
type: AnswerComment
has text: is there any sort of alternative for the NIO Selector? I wrote a multicast udp receiver thinking that the multiplex would be great for not needing to handle multithreading, but I m not anywhere close to no gc. Is the only option to rewrite using a multicastSocket?

timer
tag name: timer
type: Tag
tags question: http://stackoverflow.com/q/2673045
tags question: http://stackoverflow.com/q/2622104
tags question: http://stackoverflow.com/q/2745990
tags question: http://stackoverflow.com/q/2763897
tags question: http://stackoverflow.com/q/2691835

http://stackoverflow.com/comment/2779030
has text: agreed ... but in none of those cases will recompiling the "Java binaries (bytecode)" make the slightest difference!!
type: AnswerComment
comment on: http://stackoverflow.com/a/2748912
type: Comment
score: 0

http://stackoverflow.com/q/2617762
has comment: http://stackoverflow.com/comment/2832031
upvote count: 10
possible better answer: http://stackoverflow.com/a/20925743
tagged with: jfilechooser
type: Question
answer count: 2
downvote count: 0
has body: I don't like this ugly FileChooser layout in Linux. This layout is used by any other program and is MUCH more beautiful. Is this layout available in Java? If so, how?
favorite count: 0
has title: Alternative to JFileChooser on Linux?
tagged with: linux
has answer: http://stackoverflow.com/a/2626360
tagged with: swing
has comment: http://stackoverflow.com/comment/2629646
accepted answer: http://stackoverflow.com/a/2626360
has answer: http://stackoverflow.com/a/20925743
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/759376
tagged with: java
score: 10

http://stackoverflow.com/a/2675284
has body: For fun... how NOT to do it ;-) String s = Arrays.asList(a,b,c,d,e).toString().replaceAll("[\\[\\], ]", ""); Not that anyone would really think of doing it this way in this case - but this illustrates why it's important to give access to certain object members, otherwise API users end up parsing the string representation of your object, and then you're stuck not being able to modify it, or risk breaking their code if you do.
score: 4
type: Answer
upvote count: 4
downvote count: 0
answers question: http://stackoverflow.com/q/2674707

http://stackoverflow.com/q/2661025
tagged with: clojure
favorite count: 0
score: 6
type: AnsweredQuestion
tagged with: java
has body: Based on the Embedding section of http://github.com/technomancy/swank-clojure, I'm using the following to test it out. Is there a better way to do this that doesn't use Compiler? Is there a way to programmatically stop swank? It seems start-repl takes control of the thread. What would be a good way to spawn off another thread for it and be able to kill that thread programatically. import clojure.lang.Compiler; import java.io.StringReader; public class Embed { public static void main(String[] args) throws Exception { final String startSwankScript = "(ns my-app\n" + " (:use [swank.swank :as swank]))\n" + "(swank/start-repl) "; Compiler.load(new StringReader(startSwankScript)); } } Any help much appreciated, hhh
type: Question
tagged with: swank
upvote count: 6
downvote count: 0
has title: Embedding swank-clojure in java program
answer count: 1
has answer: http://stackoverflow.com/a/2663888
accepted answer: http://stackoverflow.com/a/2663888

http://stackoverflow.com/a/2761728
score: 8
has body: You're making a classic mistake: confusing RDF (which is what SPARQL queries) with (one of) its serialisation, namely RDF/XML. rdf:about (and rdf:ID, rdf:Description, rdf:resource) are part of RDF/XML, a way RDF is written down. You can play around with the RDF Validator to see what RDF triples result from a piece of RDF/XML. In your case let's start with: &lt;?xml version="1.0"?&gt; &lt;rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/terms/"&gt; &lt;rdf:Description rdf:about="http://www.example.org/"&gt; &lt;dc:title&gt;Example for Donal Fellows&lt;/dc:title&gt; &lt;/rdf:Description&gt; &lt;/rdf:RDF&gt; Plug that into the validator and you get: Number Subject Predicate Object 1 http://www.example.org/ http://purl.org/dc/terms/title "Example for Donal Fellows" (you can also ask for a pictorial representation) Notice that rdf:about is not present: its value provides the subject for the triple. How do I do a query to find properties associated with http://www.example.org? Like this: select * { &lt;http://www.example.org/&gt; ?predicate ?object } You'll get: ?predicate ?object &lt;http://purl.org/dc/terms/title&gt; "Example for Donal Fellows" You'll notice that the query is a triple match with variables (?v) in places where we want to find values. We could also ask what predicate links http://www.example.org/ with "Example for..." by asking: select * { &lt;http://www.example.org/&gt; ?predicate "Example for Donal Fellows" } This pattern matching is the heart of SPARQL. RDF/XML is a tricky beast, and you might find it easier to work with N-Triples, which is very verbose but clear, or turtle, which is like N-Triples with a large number of shorthands and abbreviations. Turtle is often preferred by the rdf community. P.S. rdfs:about doesn't exist anywhere.
answers question: http://stackoverflow.com/q/2760896
has comment: http://stackoverflow.com/comment/2794460
accepted answer of: http://stackoverflow.com/q/2760896
type: AcceptedAnswer
downvote count: 1
upvote count: 9
type: Answer

http://stackoverflow.com/comment/2729510
has text: @poly: As for the attitude progression: good on you! But I hope you don't lose your enthusiasm completely; your solution to the `repeatEnd` problem (http://stackoverflow.com/questions/2606214/codingbat-repeatend-using-regex) was bloody brilliant.
score: 1
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2704572

http://stackoverflow.com/comment/6281418
type: Comment
has text: You can tick yourself off as the answer. +1 from me.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2630267

http://stackoverflow.com/a/2639032
score: 36
upvote count: 36
downvote count: 0
has comment: http://stackoverflow.com/comment/3293177
answers question: http://stackoverflow.com/q/2635013
has comment: http://stackoverflow.com/comment/3141067
type: Answer
has body: Your question is ironic. You're wondering why the Java community is struggling with three different proposals for adding closures, and your suggested solution is to add a fourth option to the mix? But to answer your question: The right forum for discussion is the mailing list of openjdk project lambda. This is not a place where suggestions are likely to influence that effort. The type systems for C# and Java are significantly different, so the C# solution would not directly apply. For example, C# has declaration-site variance (in/out), while java has use-site variance (wildcards). Inference of lambda parameter types as specified in C# would not apply in Java. The evolution of Java must remain backward compatible, but adding the delegate keyword would be a breaking change. C# has three types of delegate expressions: the old one with the delegate keyword, statement lambdas with =>{, and expression lambdas. If the C# language team has it to do over again, we'd certainly not have this many forms. Why should Java adopt C#'s historical baggage? Because C# generics operate over primitives, the Func&lt;> and Action&lt;> delegate types can be used as poor-man's structural function types. But in Java, generics are erased, work only over reference types, and types cannot be distinguished by their arity. Consequently Java would have to have a large number of distinctly-named "standard" function types to get the same effect. That would not be pretty. Overall, the C# solution does not adapt to a very natural solution in Java.

http://stackoverflow.com/comment/2650224
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2636220
has text: Normally you should have a docked window on the left that shows the projects in your workspace. If this isn't there you can go to the menu: window -> show view -> package explorer.
type: AnswerComment

http://stackoverflow.com/q/2765368
tagged with: java-6
answer count: 1
has answer: http://stackoverflow.com/a/2765440
has body: I've a problem with Javaw.exe process. I am developping an application relative to media acknowledgment using jdsk 1.6.0.11 &amp; Eclipse 5 for Plugin Developpment. every time i want test my web cam (JUnit) then i've got a message : "Javaw.exe will close,we're sorry".Anyone can help me please??
type: UnansweredQuestion
tagged with: plugins
has title: Javaw.exe problem with Eclipse 5.0
has comment: http://stackoverflow.com/comment/2797878
tagged with: java
type: Question
tagged with: junit4
tagged with: eclipse
score: 0

http://stackoverflow.com/comment/2692219
type: Comment
comment on: http://stackoverflow.com/a/2667562
type: AnswerComment
score: 0
has text: You are kind of right. I had many lines of the message because the above given code was called many times and it was called many times because I pressed the submit button many times (when my program was frozen). And my program was frozen because of another stupid mistake which is unrelated to the given code.

http://stackoverflow.com/q/2599102
answer count: 3
has comment: http://stackoverflow.com/comment/2636307
accepted answer: http://stackoverflow.com/a/2623702
upvote count: 3
possible better answer: http://stackoverflow.com/a/17240646
has answer: http://stackoverflow.com/a/17240646
has body: I need a good OLEDate java implementation, and this one does not seem to be working. Is there any known good opensource implementations (like in apache commons)? If not, where do I read about it, so that I write my own implementation?
has title: OLEDate java implementation
type: AnsweredQuestion
score: 3
tagged with: java
tagged with: date
type: Question
has answer: http://stackoverflow.com/a/2623702
has answer: http://stackoverflow.com/a/28479647
downvote count: 0
tagged with: coledatetime
favorite count: 0

http://stackoverflow.com/comment/2778974
type: Comment
type: AnswerComment
has text: @Stephen, I changed it to "systems." There are many factors that can impede portability, including using JNA or JNI to link to libraries that are only written for a single architecture.
comment on: http://stackoverflow.com/a/2748912
score: 0

http://stackoverflow.com/comment/132418043
type: Comment
has text: “(client and I agreed that he'll never supply certain input values [described as preconditions], and that he doesn't want me to check for these values over and over again)”—A perverse incentive (refer to the bet). Never use asserts for input from those shady one dollar clients.
comment on: http://stackoverflow.com/a/6724943
score: 0
type: AnswerComment

http://stackoverflow.com/a/2760984
downvote count: 0
score: 1
accepted answer of: http://stackoverflow.com/q/2760251
has body: We had similar case, where we developed a connector to access external WebDav storage, and wanted to use it also from a stand alone application (non-managed). I do believe that the easiest way is to solve this at the design level, and organize your code in a way that the connector's core logic is JCA-agnostic and can be reused easily. Then you can wrap this with JCA-specific code that exposes the connector to the AS. It could probably even be packaged in two jar -- That's at least the solution we choose (but we packaged all in one .jar). Otherwise, a JCA connector is the "glue" between the following three parties: the Application Server the EIS the Application Component. It should be possible to simulate the AS with a lightweight implementation of the necessary classes, and then use the JCA connector directly. One main job of the AS with respect to a JCA connector is to manage the pooling of connections, and from what I remember, the corresponding interface that you should then implement is ConnectionManager. The JCA connector receive a reference to a ConnectionManager, but the implementation is AS-specific. Writing a lightweight implementation that provides rudimentary pooling (or no pooling at all) sounds feasible. I had written once a sequence diagram of the connection allocation mechanism. Maybe you will find it useful. Another interface is ResourceAdapter where you define the startup/shutdown, but that's easy to invoke manually. (There is probably a bit more than that, and it of course depends on what your JCA connector uses. For instance, if it use Work and the WorkManager, then it becomes a lot more complicated to mock. Same remark if the connector is transactional. But it doesn't seem to be your case.) Otherwise, I think that Spring has some support for JCA, it may be worth having a look how they did it. From reading the JCA spec, there is supposedly some support to execute the code in a non-managed environment Can you mention the specific part of the spec y…
has comment: http://stackoverflow.com/comment/2820119
upvote count: 1
type: AcceptedAnswer
type: Answer
answers question: http://stackoverflow.com/q/2760251

http://stackoverflow.com/q/2760289
favorite count: 0
tagged with: multi-tenant
type: UnansweredQuestion
has title: performance monitoring tools for multi-tenant web application
score: 2
upvote count: 2
tagged with: java
has comment: http://stackoverflow.com/comment/2792292
type: Question
tagged with: performance
has comment: http://stackoverflow.com/comment/2812331
has answer: http://stackoverflow.com/a/2760598
answer count: 2
has body: We have a need to monitor performance of our java web app. We are looking for some tolls which can help us with this task. The major difficulty is that we are SaaS provider with multi-tenant server architecture with hundreds of customers running on the same hardware. So far we tried commercial products like DynaTrace and Coradinat but unfortunately they don't get the job done so far. What we need is a simple report which would tell us if we had performance problems on each customer site in a specified period of time. Mostly it will be response time per customer but also we will need some more specifics based on the URLs. please let me know if someone had any experience with setting up such monitoring. Thanks!
downvote count: 0
has answer: http://stackoverflow.com/a/24111032

http://stackoverflow.com/comment/139049916
type: Comment
has text: True, but imagine if after 3 months you learn another language that speeds up the development even more than you original language
type: AnswerComment
comment on: http://stackoverflow.com/a/2627284
score: 0

http://stackoverflow.com/a/2812027
downvote count: 0
has body: an answer to my specific question that I started with in this thread: i cannot force to start a scheduled job, but what I can do is remove the scheduled job and start a new job with a delay of 0 seconds. addScheduledJobAfterDelay() return a string that represents the job id. i can use it to remove the scheduled job. The problem is that there is no way to know if I'm interrupting the scheduled job or not. Executors do provide that information. that is why Executors are better choice in this specific case then using the red5 scheduling service. how to remove a scheduled job (red5): ISchedulingService scheduler = (ISchedulingService) getScope().getContext().getBean(ISchedulingService.BEAN_NAME); scheduler.removeScheduledJob("ScheduleJobString"); the string ScheduleJobString should be replaced with the string that you have received from creating the job: String scheduleJobString = scheduler.addScheduledOnceJob(DelayInSeconds*1000,new MyJob());
type: Answer
score: 1
answers question: http://stackoverflow.com/q/2774043
accepted answer of: http://stackoverflow.com/q/2774043
upvote count: 1
type: AcceptedAnswer

http://stackoverflow.com/a/2647482
type: Answer
answers question: http://stackoverflow.com/q/2647349
score: 0
has body: You're not "updating" test1 anywhere. This line is assigning a different object of type Tournament that it's reading from the input stream, and assigning this new object to test1: test1 = (Tournament) in.readObject(); Meanwhile, test2 is still pointing to the original object that was allocated at the start of your code block.

http://stackoverflow.com/q/2706100
has title: Special characters incongruence
tagged with: spring
has answer: http://stackoverflow.com/a/2706253
score: 1
tagged with: java
upvote count: 1
type: Question
linked to: http://stackoverflow.com/q/2705640
has body: Hello I'm building a Spring MVC web application that runs on Tomcat 6.0.20 and JDK 1.6.0_19. When I send some special characters through an HTML form some of them are stored as question marks ? For example these symbols are stored correctly: €, á, é, í, ‰, etc But some symbols are replaced with ? like: ₤, ♪, ☺ MySQL tables charset is utf-8. My jsp also use utf-8 &lt;%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %&gt; I have included org.springframework.web.filter.CharacterEncodingFilter in web.xml as suggested here When I debug the POST request when sending 3 characters €a₤ with firebug I get: %E2%82%ACa%E2%82%A4 which is correct since E2 82 AC is the code for € and E2 82 A4 is the code for ₤ but ₤ is stored as ? in the database. When I save ₤ directly into the database it is displayed correctly in the webpage. How can I fix this?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2706147
accepted answer: http://stackoverflow.com/a/2706147
answer count: 2
tagged with: encoding
downvote count: 0
tagged with: jsp
favorite count: 0
possible better answer: http://stackoverflow.com/a/2706253

http://stackoverflow.com/a/25246982
type: Answer
score: 34
answers question: http://stackoverflow.com/q/2751733
downvote count: 0
upvote count: 34
has comment: http://stackoverflow.com/comment/127326808
has body: From JPA 2.1 you can use AttributeConverter. Create an enumerated class like so: public enum NodeType { ROOT("root-node"), BRANCH("branch-node"), LEAF("leaf-node"); private final String code; private NodeType(String code) { this.code = code; } public String getCode() { return code; } } And create a converter like this: import javax.persistence.AttributeConverter; import javax.persistence.Converter; @Converter(autoApply = true) public class NodeTypeConverter implements AttributeConverter&lt;NodeType, String&gt; { @Override public String convertToDatabaseColumn(NodeType nodeType) { return nodeType.getCode(); } @Override public NodeType convertToEntityAttribute(String dbData) { for (NodeType nodeType : NodeType.values()) { if (nodeType.getCode().equals(dbData)) { return nodeType; } } throw new IllegalArgumentException("Unknown database value:" + dbData); } } On the entity you just need: @Column(name = "node_type_code") You luck with @Converter(autoApply = true) may vary by container but tested to work on Wildfly 8.1.0. If it doesn't work you can add @Convert(converter = NodeTypeConverter.class) on the entity class column.
has comment: http://stackoverflow.com/comment/111686224
has comment: http://stackoverflow.com/comment/96408293

http://stackoverflow.com/comment/2795814
type: AnswerComment
comment on: http://stackoverflow.com/a/2763513
type: Comment
score: 2
has text: @Lars: For K/V pairs, *key=value* in `.properties` file (check javadoc for `Properties` class), for lists only the sky is the limit although I'd suggest you use something simple that fits your needs. Maybe XML if you want to, but usually that's not really necessary.

http://stackoverflow.com/comment/2757885
has text: @predhme - you must not specify `.class`.
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2730303

http://stackoverflow.com/a/2728609
has comment: http://stackoverflow.com/comment/2761341
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2727718
score: 2
answers question: http://stackoverflow.com/q/2727718
has comment: http://stackoverflow.com/comment/2767535
upvote count: 2
has comment: http://stackoverflow.com/comment/2770721
type: AcceptedAnswer
has body: You should see them all in the datastore view, but only if they have at least one indexed property - kinds with no indexed properties don't currently show up (known bug).
has comment: http://stackoverflow.com/comment/2779302
has comment: http://stackoverflow.com/comment/2758918
type: Answer

http://stackoverflow.com/comment/2743057
has text: Hmm... what? I'm not affiliated to Hibernate and the opinion expressed above is only mine, it reflects *my* experience of hibernate, of benchmarks (and I have some solid experience in that field and also of vendors), and of the testing *I* did with the PolePosition bench this weekend after being heavily surprised by its results. If there is some convergence with other opinions, it's maybe because of evidence. Now, to be clear, I don't call you a liar and Hibernate has flaws but saying that Hibernate is tuned on this bench is not true.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/2685981
type: Comment

system-calls
type: Tag
tags question: http://stackoverflow.com/q/2693020
tag name: system-calls

http://stackoverflow.com/comment/2793196
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2760957
has text: I tried putting <%! MySingleton instance = MySingleton.getInstance(); %> in index.jsp and when index.jsp gets loaded it looks the constructor is getting called twice (confirmed via print to stderr in the constructor). I create the singleton as part of the static initialization of the class so it appears that for some reason two classloaders are involved in serving up index.jsp
type: AnswerComment

http://stackoverflow.com/a/2667671
score: 30
has comment: http://stackoverflow.com/comment/9368234
has comment: http://stackoverflow.com/comment/2689618
has body: This is not really answering your question but if you have code depending on the enum value, you can also create an abstract method in your enum that gets overloaded for every value: public enum EnumType { ENUM1 { @Override public void doSomeStuff() { // do something } }, ENUM2 { @Override public void doSomeStuff() { // do something else } }; public abstract void doSomeStuff(); }
answers question: http://stackoverflow.com/q/2663980
has comment: http://stackoverflow.com/comment/7667395
downvote count: 0
has comment: http://stackoverflow.com/comment/2689610
upvote count: 30
type: Answer

http://stackoverflow.com/a/2639005
upvote count: 1
has comment: http://stackoverflow.com/comment/6442846
has body: Not in the general sense, no. C++ classes do not exist in the compiled binary the vast majority of the time.
answers question: http://stackoverflow.com/q/2638986
has comment: http://stackoverflow.com/comment/6466373
downvote count: 0
has comment: http://stackoverflow.com/comment/6449381
type: Answer
score: 1

http://stackoverflow.com/q/2677147
accepted answer: http://stackoverflow.com/a/2678699
upvote count: 2
score: 2
type: AnsweredQuestion
tagged with: java
type: Question
answer count: 1
has answer: http://stackoverflow.com/a/2678699
downvote count: 0
has title: Check if edit is valid for database ms-access
has body: I want to be able to check if I can edit a cell in a database with a new object Example method declaration: something.isValid(Object newObject, row, column); Example cases: If the editing cell stores an Number and I give it a String, the method will return false... If the editing cell has to be different than every other entry (unique) and the new object is the same as something else, the method will also return false.... My main goal... I want to check a whole row, and if everything is valid, I will edit the whole row. Right now, the only way I can find out if I can actually edit something is by actually editing it and seeing if I get an error. edit://Interface DatabaseMetaData is a good method. Is there a SQL command method? ****edit://I feel like the resultsetmeta data is good enough. however, where is the isUnique() Method?** edit://isSigned() accomplishes this? edit://So I just check if !isSigned() and isWritable(). What about database column conditions? For example... X has to be more than 3 characters...**
favorite count: 0
tagged with: resultset
tagged with: jdbc

regex
tags question: http://stackoverflow.com/q/2661849
tags question: http://stackoverflow.com/q/2661884
tags question: http://stackoverflow.com/q/2687012
tags question: http://stackoverflow.com/q/2622776
tags question: http://stackoverflow.com/q/2780759
tags question: http://stackoverflow.com/q/2784652
tags question: http://stackoverflow.com/q/2636056
tag name: regex
tags question: http://stackoverflow.com/q/2704857
tags question: http://stackoverflow.com/q/2734977
tags question: http://stackoverflow.com/q/2724222
tags question: http://stackoverflow.com/q/2608205
tags question: http://stackoverflow.com/q/2631010
tags question: http://stackoverflow.com/q/2754557
tags question: http://stackoverflow.com/q/2667015
tags question: http://stackoverflow.com/q/2739617
tags question: http://stackoverflow.com/q/2697256
tags question: http://stackoverflow.com/q/2660725
tags question: http://stackoverflow.com/q/2758708
tags question: http://stackoverflow.com/q/2669269
tags question: http://stackoverflow.com/q/2711226
tags question: http://stackoverflow.com/q/2660435
tags question: http://stackoverflow.com/q/2606852
tags question: http://stackoverflow.com/q/2709839
tags question: http://stackoverflow.com/q/2726694
tags question: http://stackoverflow.com/q/2717421
tags question: http://stackoverflow.com/q/2690614
tags question: http://stackoverflow.com/q/2699339
tags question: http://stackoverflow.com/q/2732461
tags question: http://stackoverflow.com/q/2708833
tags question: http://stackoverflow.com/q/2606214
tags question: http://stackoverflow.com/q/2657864
tags question: http://stackoverflow.com/q/2756794
tags question: http://stackoverflow.com/q/2659853
tags question: http://stackoverflow.com/q/2671497
tags question: http://stackoverflow.com/q/2618697
tags question: http://stackoverflow.com/q/2703689
tags question: http://stackoverflow.com/q/2723727
tags question: http://stackoverflow.com/q/2664057
tags question: http://stackoverflow.com/q/2762977
tags question: http://stackoverflow.com/q/2770967
tags question: http://stackoverflow.com/q/2707870
tags question: http://stackoverflow.com/q/2757529
tags question: http://stackoverflow.com/q/2646773
tags question: http://stackoverflow.com/q/2723765
tags question: http://stackoverflow.com/q/2705990
tags question: http://stackoverflow.com/q/2702857
tags question: http://stackoverflow.com/q/2728910
tags question: http://stackoverflow.com/q/2667727
tags question: http://stackoverflow.com/q/2647317
tags question: http://stackoverflow.com/q/2759770
tags question: http://stackoverflow.com/q/2723894
tags question: http://stackoverflow.com/q/2613928
tags question: http://stackoverflow.com/q/2735003
tags question: http://stackoverflow.com/q/2658072
tags question: http://stackoverflow.com/q/2657325
tags question: http://stackoverflow.com/q/2607177
tags question: http://stackoverflow.com/q/2722685
tags question: http://stackoverflow.com/q/2688792
tags question: http://stackoverflow.com/q/2628534
tags question: http://stackoverflow.com/q/2660522
tags question: http://stackoverflow.com/q/2733255
tags question: http://stackoverflow.com/q/2668307
tags question: http://stackoverflow.com/q/2683592
tags question: http://stackoverflow.com/q/2649975
tags question: http://stackoverflow.com/q/2681977
tags question: http://stackoverflow.com/q/2635082
tags question: http://stackoverflow.com/q/2602133
tags question: http://stackoverflow.com/q/2660342
tags question: http://stackoverflow.com/q/2700953
tags question: http://stackoverflow.com/q/2717760
type: Tag
tags question: http://stackoverflow.com/q/2780805
tags question: http://stackoverflow.com/q/2728233

http://stackoverflow.com/q/2637183
type: Question
has comment: http://stackoverflow.com/comment/2651272
has title: Can i get the absolute path of just moved file to somewhere in native file system from known folder?
score: 0
tagged with: filesystems
tagged with: operating-system
answer count: 1
type: UnansweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/2645985
has body: I am recently working on a Java desktop application which needs to track a path of file which has been recently moved to somewhere in native file system from the known source. For Example : - Let's suppose i have a file A.txt in %TEMP% folder (C:\Users\Admin\AppData\Local\Temp\A.txt). Now Operating system moves that file to, suppose my Desktop. So i suppose to get the path "C:\Users\Admin\Desktop\A.txt". How can I get the destination path, that's unknown, of recently moved file from known source? Please Note: We can search the file name on Native file system but it makes the process slow and time consuming. Is there any fast searching code OR JAR, that would be a open source, available which can make a fast search without consuming time. Can we some who communicate with Operating system which can either give us the path of recently moved file OR we can access its logs Or etc..etc. It must work with Linux, MAC and Windows. So finally we need the absolute path of just moved file to somewhere in native file system from known folder.

http://stackoverflow.com/q/2705504
possible better answer: http://stackoverflow.com/a/2705962
has answer: http://stackoverflow.com/a/2705527
score: 4
type: AnsweredQuestion
tagged with: solver
accepted answer: http://stackoverflow.com/a/2705531
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/2705520
upvote count: 4
tagged with: anagram
has answer: http://stackoverflow.com/a/2705530
has title: Java Anagram Solver
downvote count: 0
has answer: http://stackoverflow.com/a/2705531
tagged with: string
favorite count: 0
has answer: http://stackoverflow.com/a/2705962
answer count: 5
has body: I can work out how to create anagrams of a string but I don't know how I can compare them to a dictionary of real words to check if the anagram is a real word. Is there a class in the Java API that contains the entire English dictionary?
tagged with: dictionary

http://stackoverflow.com/comment/2651390
type: Comment
comment on: http://stackoverflow.com/a/2637253
type: AnswerComment
has text: It does not have any effect sir but If I remove loading LnF then it works fine
score: 0

http://stackoverflow.com/comment/2862395
type: Comment
comment on: http://stackoverflow.com/a/2816017
has text: I still don't have a big picture... can you give me an examples?
type: AnswerComment
score: 0

http://stackoverflow.com/comment/2766283
type: AnswerComment
comment on: http://stackoverflow.com/a/2737821
score: 0
type: Comment
has text: +1 .. and in addition, set the charset to UTF-8 in the Content-Type http response header. Don't know what takes precedence, but it doesn't harm to be consistent across the board.

http://stackoverflow.com/q/2656209
has answer: http://stackoverflow.com/a/2656295
has comment: http://stackoverflow.com/comment/2673785
has answer: http://stackoverflow.com/a/2656313
tagged with: java
has comment: http://stackoverflow.com/comment/48675165
has answer: http://stackoverflow.com/a/2657240
has comment: http://stackoverflow.com/comment/48695400
has answer: http://stackoverflow.com/a/2656262
type: Question
has body: I am downloading zip file from web server using Java but somehow I am loosing about 2kb in each file. I don't know why since same code works fine with other formats, e.g, text, mp3 and extra. any help is appreciated? here is my code. public void download_zip_file(String save_to) { try { URLConnection conn = this.url.openConnection(); conn.setDoOutput(true); conn.setDoInput(true); conn.setRequestProperty("content-type", "binary/data"); InputStream in = conn.getInputStream(); FileOutputStream out = new FileOutputStream(save_to + "tmp.zip"); byte[] b = new byte[1024]; int count; while ((count = in.read(b)) &gt; 0) { out.write(b, 0, count); } out.close(); in.close(); } catch (IOException e) { e.printStackTrace(); } }
has comment: http://stackoverflow.com/comment/48696425
has comment: http://stackoverflow.com/comment/2674000
answer count: 6
has comment: http://stackoverflow.com/comment/2674150
has comment: http://stackoverflow.com/comment/48694191
has comment: http://stackoverflow.com/comment/48694139
downvote count: 0
has title: download zip file using java?
has answer: http://stackoverflow.com/a/2657915
score: 8
favorite count: 0
tagged with: http://stackoverflow.com/tag/zip
has answer: http://stackoverflow.com/a/2656830
tagged with: download
upvote count: 8
type: UnansweredQuestion
tagged with: io

http://stackoverflow.com/a/38942442
score: 0
answers question: http://stackoverflow.com/q/2615712
type: Answer
has body: Use following function ` public static int secHigh(int arr[]){ int firstHigh = 0,secHigh = 0; for(int x: arr){ if(x &gt; firstHigh){ secHigh = firstHigh; firstHigh = x; }else if(x &gt; secHigh){ secHigh = x; } } return secHigh; } Function Call int secondHigh = secHigh(arr);

http://stackoverflow.com/comment/2747238
type: AnswerComment
score: 0
type: Comment
has text: Thanks for all your answers! That helped me a lot!
comment on: http://stackoverflow.com/a/2720821

http://stackoverflow.com/a/2761102
has comment: http://stackoverflow.com/comment/2800899
type: Answer
upvote count: 2
answers question: http://stackoverflow.com/q/2675471
has comment: http://stackoverflow.com/comment/2795004
has body: This isn't science, but it's based on 28 years in the business, observing and participating in teams which used a huge array of technologies, from assembly up through a long list of higher-level languages, plus of course a litany of methodological silver-bullet-du-jours: What really affects productivity is your people - specifically, how good they are, and how well led they are. So if you're trying to pick a language or other technology, go for the one with which more of your team is competent. If that's a tossup, or if it's truly green-field, hire the best people you can find, and then pick the tech best supported by the vendors whose tech you'll be dependent on... or toss a coin.
score: 2
downvote count: 0

http://stackoverflow.com/q/2678483
linked to: http://stackoverflow.com/q/878573
has answer: http://stackoverflow.com/a/40181827
tagged with: http://stackoverflow.com/tag/html
linked to: http://stackoverflow.com/q/3034186
has answer: http://stackoverflow.com/a/2678498
has answer: http://stackoverflow.com/a/2678581
favorite count: 0
has answer: http://stackoverflow.com/a/2678590
has answer: http://stackoverflow.com/a/2678506
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/12236697
has comment: http://stackoverflow.com/comment/46561473
accepted answer: http://stackoverflow.com/a/2678590
has comment: http://stackoverflow.com/comment/2697891
tagged with: java
score: 24
tagged with: heredoc
has title: Simple/Direct/Heredoc way of constructing a HTML string in Java
tagged with: convenience-methods
upvote count: 24
type: Question
has body: In python I can construct a HTML string without worrying about escaping special characters like &lt; or " by simply enclosing the string in triple quotes like: html_string = """ &lt;html&gt; &lt;body&gt; &lt;p&gt;My text with "quotes" and whatnot!&lt;p&gt; &lt;/body&gt; &lt;/html&gt; """ Is there a similar way to do this in Java?
downvote count: 0
has answer: http://stackoverflow.com/a/71447090
linked to: http://stackoverflow.com/q/121199
answer count: 6
tagged with: string
possible better answer: http://stackoverflow.com/a/40181827

http://stackoverflow.com/a/11418597
score: 0
answers question: http://stackoverflow.com/q/2706206
type: Answer
has body: Although the question assumes some subjective thinking from the potential answerer; I think there could be a definitive answer. IMO, today's web apps didn't make desktop apps development fall, to the contrary; they just made its application domains more obvious. Reading some testimonials will make my point clearer.

http://stackoverflow.com/comment/2698204
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2678643
type: Comment
has text: I just looked at it, but how do you pass the positions to the method

http://stackoverflow.com/comment/2739610
score: 0
type: AnswerComment
has text: The string is from a RSS feed that is in UTF-8, and I want to show in in a HTML page that uses ISO 8859 encoding
comment on: http://stackoverflow.com/a/2714503
type: Comment

http://stackoverflow.com/comment/2796577
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2754452
has text: @Pascal ok upon list()ing the query i got the following 04-May-2010 10:31:26 org.hibernate.util.JDBCExceptionReporter logExceptions WARNING: SQL Error: 0, SQLState: 08S01 04-May-2010 10:31:26 org.hibernate.util.JDBCExceptionReporter logExceptions SEVERE: Communications link failure Last packet sent to the server was 0 ms ago.
score: 0

http://stackoverflow.com/q/2673894
upvote count: 1
has body: I have setup Riak on a Ubuntu machine, and it seam to work if I do riak ping. Now I would like to use the Riak Java client to store an object, but it doesn't work. I get com.basho.riak.client.response.RiakIORuntimeException when I try to store an object. What am I doing wrong? Is there a way to test if I can access riak from my java client? Do I have to create a Bucket first? how? import com.basho.riak.client.RiakClient; import com.basho.riak.client.RiakObject; import com.basho.riak.client.response.FetchResponse; public class RiakTest { public static void main(String[] args) { // connect RiakClient riak = new RiakClient("http://192.168.1.107:8098/riak"); // create object RiakObject o = new RiakObject("mybucket", "mykey", "myvalue"); // store riak.store(o); } }
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2693181
possible better answer: http://stackoverflow.com/a/12283571
has answer: http://stackoverflow.com/a/2674763
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/12283571
type: Question
accepted answer: http://stackoverflow.com/a/2674763
answer count: 2
tagged with: key-value-store
downvote count: 0
favorite count: 0
has title: How to store an object in Riak with the Java client?
tagged with: riak

http://stackoverflow.com/q/2744962
tagged with: java
tagged with: file
type: Question
score: 3
has answer: http://stackoverflow.com/a/2753315
accepted answer: http://stackoverflow.com/a/2753315
has comment: http://stackoverflow.com/comment/2774278
has comment: http://stackoverflow.com/comment/2783527
has comment: http://stackoverflow.com/comment/2774366
has answer: http://stackoverflow.com/a/2745030
upvote count: 3
answer count: 3
tagged with: load
has comment: http://stackoverflow.com/comment/2774432
has comment: http://stackoverflow.com/comment/2775002
possible better answer: http://stackoverflow.com/a/2745030
has comment: http://stackoverflow.com/comment/2774162
favorite count: 0
has title: Load/Store Objects in file in Java
has comment: http://stackoverflow.com/comment/2783005
tagged with: store
has answer: http://stackoverflow.com/a/2768174
type: AnsweredQuestion
has body: I want to store an object from my class in file, and after that to be able to load the object from this file. But somewhere I am making a mistake(s) and cannot figure out where. May I receive some help? public class GameManagerSystem implements GameManager, Serializable { private static final long serialVersionUID = -5966618586666474164L; HashMap&lt;Game, GameStatus&gt; games; HashMap&lt;Ticket, ArrayList&lt;Object&gt;&gt; baggage; HashSet&lt;Ticket&gt; bookedTickets; Place place; public GameManagerSystem(Place place) { super(); this.games = new HashMap&lt;Game, GameStatus&gt;(); this.baggage = new HashMap&lt;Ticket, ArrayList&lt;Object&gt;&gt;(); this.bookedTickets = new HashSet&lt;Ticket&gt;(); this.place = place; } public static GameManager createManagerSystem(Game at) { return new GameManagerSystem(at); } public boolean store(File f) { try { FileOutputStream fos = new FileOutputStream(f); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(games); oos.writeObject(bookedTickets); oos.writeObject(baggage); oos.close(); fos.close(); } catch (IOException ex) { return false; } return true; } public boolean load(File f) { try { FileInputStream fis = new FileInputStream(f); ObjectInputStream ois = new ObjectInputStream(fis); this.games = (HashMap&lt;Game,GameStatus&gt;)ois.readObject(); this.bookedTickets = (HashSet&lt;Ticket&gt;)ois.readObject(); this.baggage = (HashMap&lt;Ticket,ArrayList&lt;Object&gt;&gt;)ois.readObject(); ois.close(); fis.close(); } catch (IOException e) { return false; } catch (ClassNotFoundException e) { return false; } return true; } . . . } public class JUnitDemo { GameManager manager; @Before public void setUp() { manager = GameManagerSystem.createManagerSystem(Place.ENG); } @Test public void testStore() { Game g = new Game(new Date(), Teams.LIONS, Teams.SHARKS); manager.registerGame(g); File file = new File("file.ser"); assertTrue(airport.store(file)); } }
downvote count: 0

http://stackoverflow.com/a/15357579
has comment: http://stackoverflow.com/comment/44116206
downvote count: 0
type: Answer
has body: You should consider using JAutodoc, which is a very useful plugin for Eclipse. The parametrization is way more advanced than the standard Eclipse generation.
answers question: http://stackoverflow.com/q/2612633
score: 1
upvote count: 1

http://stackoverflow.com/comment/2654841
comment on: http://stackoverflow.com/q/2640239
has text: Also see http://stackoverflow.com/questions/507853/system-error-code-8-not-enough-storage-is-available-to-process-this-command and http://stackoverflow.com/questions/548971/win32exception-not-enough-storage-is-available-to-process-this-command
type: Comment
type: QuestionComment
score: 2

http://stackoverflow.com/q/2766465
has body: i have to create a list of ,let's say 50 people, (in Java) and display the list, and i don't really know how to do that. so this is what i have tried to do so far . please correct and complete some of my code . public class Person { String name; String stuff; } public class CreatePerson { public static void ang() { ArrayList&lt;Person&gt; thing=new ArrayList&lt;Person&gt;(); Scanner diskScanner = new Scanner(in); for(int i=0; i&lt;50; i++){ Person pers = new Person(); out.print("name: "); pers.name=diskScanner.nextLine(); out.print("stuff: "); pers.stuff=diskScanner.nextLine(); thing.add(pers); break; } // Display people for (int i=0; i&lt;50; i++) { out.println(??);{ } } }}
has answer: http://stackoverflow.com/a/2766581
has answer: http://stackoverflow.com/a/2766483
has answer: http://stackoverflow.com/a/2768190
tagged with: structure
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2766548
tagged with: list
has comment: http://stackoverflow.com/comment/2799016
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/2798975
answer count: 6
accepted answer: http://stackoverflow.com/a/2766548
tagged with: arraylist
score: 0
has comment: http://stackoverflow.com/comment/2798981
has title: How to create and display a list in Java?
has answer: http://stackoverflow.com/a/2766479
possible better answer: http://stackoverflow.com/a/2766483
has answer: http://stackoverflow.com/a/2766638

http://stackoverflow.com/comment/68018693
has text: The code should be in validate(), not paint(), because changing the font invalidate the Component which trigger a call to paint(), so swing is endlessly repainting the component, using a lot of cpu.
type: Comment
score: 0
comment on: http://stackoverflow.com/a/2715279
type: AnswerComment

http://stackoverflow.com/q/2777214
downvote count: 0
answer count: 1
favorite count: 0
tagged with: resultset
tagged with: jdbc
upvote count: 6
has comment: http://stackoverflow.com/comment/2811821
accepted answer: http://stackoverflow.com/a/2777279
score: 6
type: AnsweredQuestion
tagged with: java
has body: When using JDBC and accessing primitive types via a result set, is there a more elegant way to deal with the null/0 than the following: int myInt = rs.getInt(columnNumber) if(rs.wasNull())? { // Treat as null } else { // Treat as 0 } I personally cringe whenever I see this sort of code. I fail to see why ResultSet was not defined to return the boxed integer types (except, perhaps, performance) or at least provide both. Bonus points if anyone can convince me that the current API design is great :) My personal solution was to write a wrapper that returns an Integer (I care more about elegance of client code than performance), but I'm wondering if I'm missing a better way to do this. Just to clarify, what bothers me about this code is not the length, but the fact that a it creates a state dependency between subsequent calls, and what appears like a simple getter actually has a side effect within the same row.
type: Question
has comment: http://stackoverflow.com/comment/7853824
has answer: http://stackoverflow.com/a/2777279
has title: When accessing ResultSets in JDBC, is there an elegant way to distinguish between nulls and actual zero values?

http://stackoverflow.com/a/2657833
answers question: http://stackoverflow.com/q/2657819
has comment: http://stackoverflow.com/comment/2676284
downvote count: 0
has comment: http://stackoverflow.com/comment/2887992
has comment: http://stackoverflow.com/comment/2676802
has comment: http://stackoverflow.com/comment/2676110
type: Answer
upvote count: 11
score: 11
has body: All the a op= b operators are a shortcut to a = a op b. However since C++ allows op and op= to be overridden separately you rely on each implementer of custom types to be consistent.
has comment: http://stackoverflow.com/comment/2675495

http://stackoverflow.com/comment/46106695
has text: Could you care to elaborate please?
type: AnswerComment
type: Comment
score: 0
comment on: http://stackoverflow.com/a/9190596

http://stackoverflow.com/a/2774276
downvote count: 0
answers question: http://stackoverflow.com/q/2774195
type: Answer
accepted answer of: http://stackoverflow.com/q/2774195
score: 2
upvote count: 2
has body: Here is a way: Object yourObject = ...; Class clazz = yourObject.getClass(); Method setter = clazz.getMethod("setString", String.class); // You need to specify the parameter types Object[] params = new Object[]{"New String"}; setter.invoke(this, params); // 'this' represents the class from were you calling that method. // If you have a static method you can pass 'null' instead.
type: AcceptedAnswer

xtext
tags question: http://stackoverflow.com/q/2751633
type: Tag
tag name: xtext

http://stackoverflow.com/comment/105284298
type: Comment
has text: And `registry` too, in fact that alone is sufficient.
comment on: http://stackoverflow.com/a/2659029
type: AnswerComment
score: 0

http://stackoverflow.com/comment/47800816
has text: @mallardz, What else do you expect? This is the least surprising behavior, considering that Java is statically typed and the result has to fit in the destination type. The only alternative is a compile error, which isn't user friendly at all. Plus it matches C, where if you have an unsigned char x and you do x++, you aren't expecting to get an int back.
comment on: http://stackoverflow.com/a/2696819
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/a/2637286
upvote count: 3
answers question: http://stackoverflow.com/q/2637268
has comment: http://stackoverflow.com/comment/2651397
has comment: http://stackoverflow.com/comment/2651379
has body: I'm guessing either your DoWork methods should be called CreateContact or your call to CreateContact should be DoWork... But this isn't really a pattern. It's just a common use of method overloading.
type: Answer
score: 3
downvote count: 0

http://stackoverflow.com/q/2691121
has body: Does anybody know Swing related GUI guidelines - specifically on how to design Swing apps and which components I should use? I'm not looking for an official standard, but pragmatic tips I can use to set a good standard for my projects. I haven't used too much of Swing by myself. Surely clicking a GUI with a GUI designer isn't a big deal. However I'd like to get some insights from people who have experience with Swing and know what to avoid. Swing lately (in Java 6- 10) got decent changes. So there isn't too much specific standardization out there currently.
has title: Best Practice Guide: Swing
favorite count: 0
has answer: http://stackoverflow.com/a/2691307
type: UnansweredQuestion
tagged with: swing
score: 11
duplicate of: http://stackoverflow.com/q/1742001
downvote count: 1
type: Question
upvote count: 12
tagged with: java
tagged with: ui-guidelines
answer count: 2
linked to: http://stackoverflow.com/q/1742001
has answer: http://stackoverflow.com/a/2691180
tagged with: layout-manager

http://stackoverflow.com/comment/2698580
has text: You may be able to use a CategoryTableXYDataset. I know it takes x, y values, but you could write a custom axis renderer (and a custom legend if needed0 such that the underlying values on the axis are numbers, but they render as strings. For example, the y-axis might have values 1, 2 and 3, but the renderer would render them as june 1, june 2, june 3. It's not an ideal solution but the type of chart you're trying to create doesn't really fit in with the existing JFreeChart plots and is probably easier than writing your own plot.
type: Comment
comment on: http://stackoverflow.com/a/2677987
score: 0
type: AnswerComment

http://stackoverflow.com/comment/2617247
type: AnswerComment
score: 0
type: Comment
has text: I know you can solve it with a simple `else`. But I said it was a very stupid example. But it is true!
comment on: http://stackoverflow.com/a/2607144

http://stackoverflow.com/a/19602144
score: 26
answers question: http://stackoverflow.com/q/2611834
upvote count: 26
type: Answer
has body: As far as I can tell (in December 2013) ... Douglas Crockford's master source repository for "json.org" is now on GitHub - https://github.com/douglascrockford/JSON-java. (The GIT history starts in 2010, and the latest change in "master" is a couple of weeks ago.) Paul Merlin (aka "eskatos") has Mavenized the code: https://github.com/eskatos/org.json-java Binary "org.json" JAR files are "regularly" built from Paul Merlin's tree and pushed to Maven Central. You can find them via the "here" link in Paul's README.md file; see the line above. There are other older (pre-2010) binary releases of the "org.json" JAR file in Maven Central under various guises; review the search results for this link" http://mvnrepository.com/search.html?query=org.json. The copyright dates in the "org.json" source code don't mean much. They clearly aren't updated when the code is updated. However, Douglas Crockford does update the @version javadoc tags, at least in some commits. UPDATE (December 2016) As of some time in 2015, Douglas Crockford has passed ownership of the Github repository to Sean Leary. The old Github URL for the project now redirects to https://github.com/stleary/JSON-java. The project continues to be relatively active. See also: Where has json.org java library gone?
downvote count: 0

http://stackoverflow.com/a/16638897
answers question: http://stackoverflow.com/q/2736389
score: 26
downvote count: 0
has body: There are a couple of ways by which you can access variables or objects in other classes or Activity. A. Database B. Shared preferences. C. Object serialization. D. A class which can hold common data can be named as Common Utilities. It depends on you. E. Passing data through Intents and Parcelable Interface. It depends upon your project needs. A. Database SQLite is an open source database which is embedded into Android. SQLite supports standard relational database features like SQL syntax, transactions and prepared statements. Tutorials B. Shared preferences Suppose you want to store username. So there will now be two things, a key username, value value. How to store // Create object of SharedPreferences. SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); //Now get Editor SharedPreferences.Editor editor = sharedPref.edit(); //Put your value editor.putString("userName", "stackoverlow"); //Commits your edits editor.commit(); Using putString(), putBoolean(), putInt(), putFloat(), and putLong() you can save your desired dtatype. How to fetch SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); String userName = sharedPref.getString("userName", "Not Available"); http://developer.android.com/reference/android/content/SharedPreferences.html C. Object serialization Object serlization is used if we want to save an object state to send it over a network or you can use it for your purpose also. Use Java beans and store in it as one of his fields and use getters and setter for that. JavaBeans are Java classes that have properties. Think of properties as private instance variables. Since they're private, the only way they can be accessed from outside of their class is through methods in the class. The methods that change a property's value are called setter methods, and the methods that retrieve a property's value are called getter methods. public class VariableStorage implements Serializable { private String inStr…
type: Answer
upvote count: 26

http://stackoverflow.com/comment/2776707
has text: The modules are not very useful on their own - it takes several of them to serve a request. But I was not necessarily talking about deployment on several machines - the problem how to structure the application also arises on one machine.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2746788

static
tags question: http://stackoverflow.com/q/2640883
tags question: http://stackoverflow.com/q/2649213
tags question: http://stackoverflow.com/q/2719536
tags question: http://stackoverflow.com/q/2673510
tags question: http://stackoverflow.com/q/2740554
tags question: http://stackoverflow.com/q/2613952
tags question: http://stackoverflow.com/q/2695893
tags question: http://stackoverflow.com/q/2657875
tags question: http://stackoverflow.com/q/2768914
tags question: http://stackoverflow.com/q/2668117
tags question: http://stackoverflow.com/q/2731119
tags question: http://stackoverflow.com/q/2752094
tags question: http://stackoverflow.com/q/2694566
tag name: static
tags question: http://stackoverflow.com/q/2685345
tags question: http://stackoverflow.com/q/2763279
tags question: http://stackoverflow.com/q/2629475
tags question: http://stackoverflow.com/q/2625031
type: Tag
tags question: http://stackoverflow.com/q/2784772
tags question: http://stackoverflow.com/q/2689312

http://stackoverflow.com/a/16158414
type: Answer
has body: Check out Sonar. It's an open-source, stand-alone, web service that you "submit" your code to and it produces beautiful HTML reports on all kinds of code metrics. It also keeps a history of builds. And best of all, you don't have to modify your builds or poms! There is a maven goal for it too: sonar:sonar. Jenkins (previously Hudson) has a plugin for it, so it's totally painless if you use that for your CI. Check it out - you won't be sorry!
answers question: http://stackoverflow.com/q/2758662
score: 0

http://stackoverflow.com/comment/2801227
type: Comment
has text: Thanks! Any idea if this is supported in Netbeans?
comment on: http://stackoverflow.com/a/2767278
score: 1
type: AnswerComment

http://stackoverflow.com/a/2732259
type: AcceptedAnswer
downvote count: 0
type: Answer
upvote count: 10
accepted answer of: http://stackoverflow.com/q/2732174
score: 10
has body: I would handle that with a ChangeEvent. It's just an indication that something has changed. As for implementing the add/remove/fire functionality. There is no mechanism like PropertyChangeSupport, but the code is simple enough there's not really a need for it. private final EventListenerList listenerList = new EventListenerList(); private final ChangeEvent stateChangeEvent = new ChangeEvent(this); public void addChangeListener(ChangeListener l) { listenerList.add(ChangeListener.class, l); } public void removeChangeListener(ChangeListener l) { listenerList.remove(ChangeListener.class, l); } protected void fireChange() { for (ChangeListener l: listenerList.getListeners(ChangeListener.class)) { l.stateChanged(stateChangeEvent); } } Note: JComponent provides a protected listenerList object for use by sub-classes.
answers question: http://stackoverflow.com/q/2732174
has comment: http://stackoverflow.com/comment/2760189

http://stackoverflow.com/comment/2967516
type: AnswerComment
has text: this is the best solution so far
type: Comment
comment on: http://stackoverflow.com/a/2675947
score: 0

http://stackoverflow.com/q/2778176
accepted answer: http://stackoverflow.com/a/2778273
upvote count: 1
tagged with: swing
type: AnsweredQuestion
score: 1
tagged with: java
type: Question
has title: PNGException "crc corruption" when attempting to create ImageIcon objects from ZIP archive
has answer: http://stackoverflow.com/a/2778273
has body: I've got a ZIP file containing a number of PNG images that I am trying to load into my Java application as ImageIcon resources directly from the archive. Here's my code: import java.io.*; import java.util.Enumeration; import java.util.zip.*; import javax.swing.ImageIcon; public class Test { public static void main( String[] args ) { if( args.length == 0 ) { System.out.println("usage: java Test.java file.zip"); return; } File archive = new File( args[0] ); if( !archive.exists() || !archive.canRead() ) { System.err.printf("Unable to find/access %s.\n", archive); return; } try { ZipFile zip = new ZipFile(archive); Enumeration &lt;? extends ZipEntry&gt;e = zip.entries(); while( e.hasMoreElements() ) { ZipEntry entry = (ZipEntry) e.nextElement(); int size = (int) entry.getSize(); int count = (size % 1024 == 0) ? size / 1024 : (size / 1024)+1; int offset = 0; int nread, toRead; byte[] buffer = new byte[size]; for( int i = 0; i &lt; count; i++ ) { offset = 1024*i; toRead = (size-offset &gt; 1024) ? 1024 : size-offset; nread = zip.getInputStream(entry).read(buffer, offset, toRead); } ImageIcon icon = new ImageIcon(buffer); // boom -- why? } zip.close(); } catch( IOException ex ) { System.err.println(ex.getMessage()); } } } The sizes reported by entry.getSize() match the uncompressed size of the PNG files, and I am able to read the data out of the archive without any exceptions, but the creation of the ImageIcon blows up. The stacktrace: sun.awt.image.PNGImageDecoder$PNGException: crc corruption at sun.awt.image.PNGImageDecoder.getChunk(PNGImageDecoder.java:699) at sun.awt.image.PNGImageDecoder.getData(PNGImageDecoder.java:707) at sun.awt.image.PNGImageDecoder.produceImage(PNGImageDecoder.java:234) at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:246) at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:172) at sun.awt.image.ImageFetcher.run(ImageFetcher.java:136) sun.awt.image.PNGImageDecoder$PNGException: crc corruption at sun.awt.image.PNGI…
tagged with: awt
answer count: 1
downvote count: 0
favorite count: 0
tagged with: http://stackoverflow.com/tag/zip

http://stackoverflow.com/comment/2770757
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2741598
has text: @Oscar & trashgod: exactly what did you change in the layout?

http://stackoverflow.com/q/2644611
has answer: http://stackoverflow.com/a/2644913
favorite count: 0
accepted answer: http://stackoverflow.com/a/2644913
tagged with: multithreading
has answer: http://stackoverflow.com/a/2644657
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
possible better answer: http://stackoverflow.com/a/2644657
tagged with: concurrency
type: Question
has body: What should be the ideal number of parallel java threads for copying a large set of files from a quad core linux box to an external shared folder? I can see that with a single thread it is taking a hell lot of time to move the files one by one. Multiple threads is improving the copy performance, but I don't know what should be the exact number of threads. I am using Java executor service to create the thread pool.
has title: How can I determine the ideal number of parallel java threads for copying a large set of files to an external shared folder?
answer count: 2
tagged with: file-io
upvote count: 1

http://stackoverflow.com/comment/31010353
has text: Whenever you're finding 1st , 2nd or 3rd highest and so on, you always needs to be sort an array into an ascending order.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/20704105
type: Comment

http://stackoverflow.com/q/2635229
answer count: 1
has comment: http://stackoverflow.com/comment/37388571
upvote count: 33
favorite count: 0
has answer: http://stackoverflow.com/a/2635249
has comment: http://stackoverflow.com/comment/13787823
type: AnsweredQuestion
downvote count: 0
tagged with: java
has title: Java variadic function parameters
has body: I have a function that accepts a variable number of parameters: foo (Class... types); In which I get a certain number of class types. Next, I want to have a function bar( ?? ) That will accepts a variable number of parameters as well, and be able to verify that the variables are the same number (that's easy) and of the same types (the hard part) as was specified in foo. How can I do that? Edit: to clarify, a call could be: foo (String.class, Int.class); bar ("aaa", 32); // OK! bar (3); // ERROR! bar ("aa" , "bb"); //ERROR! Also, foo and bar are methods of the same class.
type: Question
score: 33
accepted answer: http://stackoverflow.com/a/2635249

sql
tags question: http://stackoverflow.com/q/2628356
tags question: http://stackoverflow.com/q/2731443
tags question: http://stackoverflow.com/q/2621135
tags question: http://stackoverflow.com/q/2643384
tags question: http://stackoverflow.com/q/2654258
tags question: http://stackoverflow.com/q/2636130
tags question: http://stackoverflow.com/q/2757549
tags question: http://stackoverflow.com/q/2605385
tags question: http://stackoverflow.com/q/2628092
tags question: http://stackoverflow.com/q/2710212
tags question: http://stackoverflow.com/q/2778837
tags question: http://stackoverflow.com/q/2668449
tag name: sql
tags question: http://stackoverflow.com/q/2699963
type: Tag
tags question: http://stackoverflow.com/q/2698740
tags question: http://stackoverflow.com/q/2650180
tags question: http://stackoverflow.com/q/2620728
tags question: http://stackoverflow.com/q/2738109
tags question: http://stackoverflow.com/q/2719642
tags question: http://stackoverflow.com/q/2622937
tags question: http://stackoverflow.com/q/2640297
tags question: http://stackoverflow.com/q/2775113
tags question: http://stackoverflow.com/q/2713584
tags question: http://stackoverflow.com/q/2776362
tags question: http://stackoverflow.com/q/2786168
tags question: http://stackoverflow.com/q/2691730
tags question: http://stackoverflow.com/q/2647407
tags question: http://stackoverflow.com/q/2716818
tags question: http://stackoverflow.com/q/2763659
tags question: http://stackoverflow.com/q/2635058
tags question: http://stackoverflow.com/q/2714530
tags question: http://stackoverflow.com/q/2742039
tags question: http://stackoverflow.com/q/2746756
tags question: http://stackoverflow.com/q/2745764
tags question: http://stackoverflow.com/q/2771439

http://stackoverflow.com/comment/2799371
has text: That's not UTF-8 but rather CP850.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2766780
score: 1

http://stackoverflow.com/comment/2702059
comment on: http://stackoverflow.com/q/2682429
type: Comment
type: QuestionComment
has text: I think it has more to do with class loaders
score: 0

http://stackoverflow.com/comment/120414652
comment on: http://stackoverflow.com/a/2695437
score: 0
type: AnswerComment
has text: "So it is possible, for example, for addAll(c) to fail (throwing an exception) after adding only some of the elements in c." isn't this a "no"?
type: Comment

http://stackoverflow.com/a/2725042
score: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/2751742
type: Answer
answers question: http://stackoverflow.com/q/2724945
upvote count: 1
has body: I would look for some pure java APIs for manipulating rar files. This way the code will not be system dependent. A quick search on google returned this: http://www.example-code.com/java/rar_unrar.asp

http://stackoverflow.com/comment/2699863
has text: Thanks for the reply. Some follow up questions: (1) Actually my interfaces don't end in 'Interface' usually but do start with 'I'. Is there a standard naming convention for interfaces in Java? I always thought it was a matter of preference but would happily change if a convention exists. (2) The '_' for member variables I also assumed was a matter of coding style. If it doesn't affect the getter/setter names I thought it was ok. (3) If I was to use constructor injection, I would remove the setParent() method and allow a null parent reference in the constructor (no default constructor). OK?
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/2680097
type: Comment

http://stackoverflow.com/q/2677194
type: UnansweredQuestion
tagged with: macos
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/2696240
type: Question
has comment: http://stackoverflow.com/comment/2696588
has title: How to make Eclipse compile with Java 1.5 in Mac OS X Leopard (10.5)?
tagged with: java
tagged with: eclipse
has comment: http://stackoverflow.com/comment/2696247
upvote count: 2
answer count: 1
has answer: http://stackoverflow.com/a/2677908
favorite count: 0
has body: I have been developing in Snow Leopard (10.6). I believe I have some Java6-only API features and I'd like to find these. I moved my project to Leopard (10.5) -- since Snow Leopard does not support Java 1.5 -- but I am so far unable to make Eclipse give compile errors for a Java API call which I know to have been added in 1.6. Here is what I have done: Project properties -> Java Compiler -> set everything to 1.5. Preferences -> Java -> Installed JREs -> selected JVM 1.5.0. Project properties -> Java Build Path -> Libraries -> says JRE System Library [JVM 1.5.0] What am I missing? Is there another way to find Java API calls added in 1.6 when using Eclipse in Snow Leopard? Thanks.

http://stackoverflow.com/a/2619566
type: Answer
accepted answer of: http://stackoverflow.com/q/2619555
downvote count: 1
answers question: http://stackoverflow.com/q/2619555
has comment: http://stackoverflow.com/comment/27913730
score: 2
upvote count: 3
has comment: http://stackoverflow.com/comment/2633132
has comment: http://stackoverflow.com/comment/31391124
has comment: http://stackoverflow.com/comment/2633151
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2631770
has body: serialVersionUID can be any long that provides a unique signature to your object for serialization and deserialization. I don't think it even have to be unique. This is so that the serializer knows that that is the same Foo.class even after you have change the structure of the class. I typically use a -1L for the value.

http://stackoverflow.com/a/2636329
upvote count: 1
downvote count: 0
answers question: http://stackoverflow.com/q/2636288
type: Answer
score: 1
has body: I can think of two options. Start your Java application from within one batch file or ant file, and then have this automatically run another when you finish. Intercept when your application closes using java code, then start a batch file running from Java as a subprocess. You will probably need to use windows specific methods to keep it running after you exit, if you don't want to keep your application waiting around. Only 1 will work if your process is killed. How are you trying to do it at the moment, and how is it failing? Without this information we can't help you.

http://stackoverflow.com/q/2695085
tagged with: nslookup
answer count: 3
accepted answer: http://stackoverflow.com/a/2695294
tagged with: srv
has answer: http://stackoverflow.com/a/2695156
has answer: http://stackoverflow.com/a/2695294
has answer: http://stackoverflow.com/a/8957041
type: AnsweredQuestion
tagged with: java
tagged with: active-directory
possible better answer: http://stackoverflow.com/a/2695156
type: Question
score: 0
has title: Using Java for 'nslookup -type=srv'
has body: Is there a way in Java to do a Nslookup search on SRV records? I need to bind to Active Directory and would like to use the SRV records to help determine which of the ADs in the cluster are live. In command line the nslookup search string is: 'nslookup -type=srv _ ldap._tcp.ActiveDirectory domain name' Thanks.

http://stackoverflow.com/a/2674804
has body: It's possible to mix JPA and JDBC code in the same transaction using the JpaTransactionManager. A snippet from Spring 3's JavaDoc: This transaction manager also supports direct DataSource access within a transaction (i.e. plain JDBC code working with the same DataSource). This allows for mixing services which access JPA and services which use plain JDBC (without being aware of JPA)! You should be aware though that JPA caches the queries and executes all of them at the end of a transaction. So if you want to persist some data inside a transaction with JPA and then retrieve the data with JDBC, it will not work without explicitely flushing the JPA's persistence context before you attempt to retreive it with JDBC code. A code example that asserts with JDBC code that the JPA code deleted a row inside a transaction: @Test @Transactional @Rollback(false) public void testDeleteCoffeeType() { CoffeeType coffeeType = coffeeTypeDao.findCoffeeType(4L); final String caffeForte = coffeeType.getName(); coffeeTypeDao.deleteCoffeeType(coffeeType); entityManager.flush(); int rowsFoundWithCaffeForte = jdbcTemplate .queryForInt("SELECT COUNT(*) FROM COFFEE_TYPES where NAME = ?", caffeForte); assertEquals(0, rowsFoundWithCaffeForte); } And if you prefer to use the JpaTemplate class, just replace the entityManager.flush() with jpaTemplate.flush(); In response to Sajids' comment: With Spring you can configure a transaction manager that supports both JPA and JDBC like this: <tx:annotation-driven transaction-manager="transactionManager" /> and Annotation-Driven version @Bean public JpaTransactionManager transactionManager(EntityManagerFactory emf) { JpaTransactionManager jpaTransactionManager = new JpaTransactionManager(); jpaTransactionManager.setEntityManagerFactory(emf); return jpaTransactionManager; } In order to make it work, the JDBC queries must be executed with the JdbcTemplate or the SimpleJdbcTemplate class. In your case with the DAO that extends the SimpleJdbcDaoSupport, you shou…
answers question: http://stackoverflow.com/q/2673678
score: 29
accepted answer of: http://stackoverflow.com/q/2673678
has comment: http://stackoverflow.com/comment/2710098
has comment: http://stackoverflow.com/comment/2718867
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2711309
downvote count: 0
upvote count: 29
has comment: http://stackoverflow.com/comment/2728289
type: Answer

http://stackoverflow.com/comment/2648140
has text: +1 for the more "concise and readable option". While `str.substring(0, str.indexOf("\n"))` is efficient, it's not immediately obvious to me that it returns a line.
type: Comment
score: 1
comment on: http://stackoverflow.com/a/2634230
type: AnswerComment

http://stackoverflow.com/a/2686200
type: Answer
score: 3
downvote count: 0
answers question: http://stackoverflow.com/q/2686181
has body: You can call any method from the outer class with Outer.this.method(). But methods are resolved at runtime, so if you have overridden it in your subclass, only the subclass method (Bar.a()) can access the original (by calling super.a()). As you probably discovered, you can't write Bar.this.super.a() -- but even if you could, it would still give you Bar.a(), not Foo.a().
upvote count: 3

http://stackoverflow.com/q/2611573
tagged with: tail-recursion
has answer: http://stackoverflow.com/a/2611588
answer count: 4
has title: Whats wrong with this method?
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2622269
accepted answer: http://stackoverflow.com/a/2611588
upvote count: 3
tagged with: java
possible better answer: http://stackoverflow.com/a/2611589
has answer: http://stackoverflow.com/a/2611589
type: Question
tagged with: recursion
score: 3
has answer: http://stackoverflow.com/a/2611592
has body: Here's the method: public static String CPUcolor () { System.out.println ("What color am I?") ; String s = getIns() ; System.out.println ("are you sure I'm "+s+"? (Y/N)") ; String a = getIns() ; while (!((a.equals ("y")) || (a.equals ("Y")) || (a.equals ("n")) || (a.equals ("N")))) { System.out.println ("try again") ; a = getIns () ; } if (a.equals ("n") || a.equals("N")) {CPUcolor() ;} System.out.println ("I am "+s) ; return s ; } here is a possible output of this method (y's and n's are user inputs): What color am I? red are you sure I'm red? (Y/N) N What color am I? blue are you sure I'm blue? (Y/N) N What color am I? Yellow are you sure I'm Yellow? (Y/N) y I am Yellow I am blue I am red Why is it that the line's "I am blue" and "I am red" printed? Why are they printed in reverse order with red, the first entered, printed last?
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2611596

http://stackoverflow.com/q/2696783
has comment: http://stackoverflow.com/comment/2721636
score: 1
tagged with: java
tagged with: mtom
has comment: http://stackoverflow.com/comment/2720033
type: Question
downvote count: 0
has title: TCP error 10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full
tagged with: tomcat
favorite count: 0
has body: I am getting this TCP error: (10055: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full) occurred while transmitting data. Apparently I start getting this error if I try to transfer any file over 50 MB. I am using WCF. I have web services written in Java/Tomcat. Could it be a problem in server-side configurations? The server is Tomcat, can you tell me which value to customize in that case? <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> <message clientCredentialType="UserName" algorithmSuite="Default" /> <endpoint address="http://[IP]/Transfer" binding="basicHttpBinding" bindingConfiguration="MyWebService1SoapHttpPortBinding" contract="Transfer" name="MyWebService1SoapHttpPort" />
has comment: http://stackoverflow.com/comment/2780597
answer count: 0
tagged with: wcf
type: UnansweredQuestion
upvote count: 1

http://stackoverflow.com/comment/2612167
type: QuestionComment
has text: Actually your example has little to do with autoboxing, that behaviour predates it. It's true that autoboxing forces us to be more aware of it: equals() is the (usually correct) way of comparing objects, == is the (only) way of comparing primitives... autoboxing helps the programmer to treat Integer and int (almost) interchangeably... and hence the danger of bugs here.
comment on: http://stackoverflow.com/q/2602636
score: 0
type: Comment

http://stackoverflow.com/comment/43518108
type: Comment
has text: I think this is an atrocious answer which totally breaks encapsulation, and tightly couples components. The correct solution is to use parcelable as stated in one of the answers lower down. This is horrible practice!!
comment on: http://stackoverflow.com/a/7454611
type: AnswerComment
score: 154

http://stackoverflow.com/comment/28733384
has text: Less readable. If I saw this in code I'd wonder where the map is.
type: Comment
score: 54
type: AnswerComment
comment on: http://stackoverflow.com/a/15072119

http://stackoverflow.com/comment/136843540
score: 1
type: Comment
has text: @MikeNakis I was much younger in 2010 :)
comment on: http://stackoverflow.com/a/2683509
type: AnswerComment

http://stackoverflow.com/a/2612904
type: Answer
accepted answer of: http://stackoverflow.com/q/2612668
upvote count: 4
score: 4
has body: It depends on what you want to do. Java2D is a fairly rich environment for text, as seen in the Fonts tab of the demo, located in the demo/jfc/Java2D folder of the Demos and Samples; source code for the font demos may be found in the enclosed src.zip. Building on this foundation, I've had good results using the text utilities in JCommon, now part of JFreeChart 1.5. As you are annotating images, a basic example is shown here, and you may want to look into using AlphaComposite, also previewed in the Java2D demo.
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2612668

http://stackoverflow.com/a/2720824
accepted answer of: http://stackoverflow.com/q/2720774
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2720774
score: 8
upvote count: 8
type: Answer
downvote count: 0
has body: I would put them in the same namespace as their corresponding classes. For more general exception types you should try to put them in the most specific namespace which covers the classes that use them, so ConstraintViolationException would go in the myproject namespace.

http://stackoverflow.com/a/23510251
has comment: http://stackoverflow.com/comment/43668494
type: Answer
answers question: http://stackoverflow.com/q/2612633
upvote count: 3
score: 3
has body: Spring Tool Suite (popular Eclipse customization for Spring development) uses STS.ini. On Windows I found it in the same dir as an app launch executable.
downvote count: 0

http://stackoverflow.com/comment/138332413
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/21068644
score: 0
has text: @MohammadMehdiSarfejoo Consider a situation you change an idDocument's person A to another person B, but doesn't change A's list. This creates two seperate uni-directional relations. From A's perspective, A has that idDocument, but from idDoc's view, A doesn't have that idDocument.

http://stackoverflow.com/q/2742039
answer count: 3
has answer: http://stackoverflow.com/a/2742045
tagged with: sql
downvote count: 1
has comment: http://stackoverflow.com/comment/2773415
has title: sql query with space in the value
has comment: http://stackoverflow.com/comment/2771145
type: UnansweredQuestion
tagged with: openjpa
has comment: http://stackoverflow.com/comment/8259187
score: 2
has comment: http://stackoverflow.com/comment/2771135
tagged with: java
tagged with: orm
type: Question
has answer: http://stackoverflow.com/a/2742044
has answer: http://stackoverflow.com/a/2742047
has body: How do I write where clause where the value has spaces: Actually I am using openJPA and I have to set parameter. The value i will be setting has a space, eg: String somevalue="firstname lastname"; query.setparameter(somevalue); I did this but doesnot work. Any suggestion will be appreciated. Thanks.
favorite count: 0
upvote count: 3

http://stackoverflow.com/comment/91600704
comment on: http://stackoverflow.com/a/52326539
type: AnswerComment
has text: Welcome to Stack Overflow! Please don't answer just with source code. Try to provide a nice description about how your solution works. See: [How do I write a good answer?](https://stackoverflow.com/help/how-to-answer). Thanks
score: 0
type: Comment

http://stackoverflow.com/q/2673626
score: 2
tagged with: java
tagged with: cursor
has answer: http://stackoverflow.com/a/2673799
type: Question
downvote count: 0
has body: Pretty much what it says in the title, how the hell is this supposed to be done? Basically i need to pass a null (empty?) ref cursor as an IN parameter to a stored procedure. /** spring's PreparedStatementSetter#setValues(...) */ public void setValues(PreparedStatement ps) throws SQLException { CallableStatement cs = (CallableStatement) ps; cs.setString(1,"constant"); //this is the IN param cs.setNull(2, OracleTypes.CURSOR); //this is the OUT param cs.registerOutParameter(3, OracleTypes.CURSOR); } And this fails with: caused by: java.sql.SQLException: Unsupported feature: sqlType=-10 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146) at oracle.jdbc.driver.OraclePreparedStatement.setNullCritical(OraclePreparedStatement.java:4399) at oracle.jdbc.driver.OraclePreparedStatement.setNullInternal(OraclePreparedStatement.java:4161) at oracle.jdbc.driver.OracleCallableStatement.setNull(OracleCallableStatement.java:4472) I'm at a loss here, tried several different ways to do this, but I couldn't find any examples about this and have no idea how to do it properly.
favorite count: 0
has title: JDBC CallableStatement and Oracle SYS_REFCURSOR IN parameters?
tagged with: oracle-database
answer count: 1
tagged with: jdbc
upvote count: 2
type: UnansweredQuestion

http://stackoverflow.com/comment/2801145
type: Comment
comment on: http://stackoverflow.com/q/2765876
score: 0
type: QuestionComment
has text: I *think* I have it figured out but I won't know for sure until we have some test data in our DEV environment. I'll post my answer if it turns out to be correct.

http://stackoverflow.com/q/2636521
score: 6
has answer: http://stackoverflow.com/a/26497353
tagged with: java
answer count: 6
has answer: http://stackoverflow.com/a/38590618
type: Question
tagged with: resourcebundle
upvote count: 6
favorite count: 0
has comment: http://stackoverflow.com/comment/2650544
has title: java.util.MissingResourceException
has answer: http://stackoverflow.com/a/2636572
has body: I am getting below exception while running an application. This application read abc.properties file, Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name abc, locale en_US at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:853) at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:822) at java.util.ResourceBundle.getBundle(ResourceBundle.java:566) at com.ibm.dst.DailyExtract.getResourceBundle(DailyExtract.java:104) at com.ibm.dst.DailyExtract.main(DailyExtract.java:131) abc.properties file reside at the workspace. I am using RSA7 as IDE, is there any setting problem? any suggestions are welcome..... Thanks a lot in advance
has answer: http://stackoverflow.com/a/2636584
has answer: http://stackoverflow.com/a/13489283
has answer: http://stackoverflow.com/a/2636599
downvote count: 0
type: UnansweredQuestion

http://stackoverflow.com/q/2634135
has answer: http://stackoverflow.com/a/2634149
favorite count: 0
has title: Efficient JSON encoding for data that may be binary, but is often text
tagged with: python
tagged with: c++
type: UnansweredQuestion
type: Question
has body: I need to send a JSON packet across the wire with the contents of an arbitrary file. This may be a binary file (like a ZIP file), but most often it will be plain ASCII text. I'm currently using base64 encoding, which handles all files, but it increases the size of the data significantly - even if the file is ASCII to begin with. Is there a more efficient way I can encode the data, other than manually checking for any non-ASCII characters and then deciding whether or not to base64-encode it? I'm currently writing this in Python, but will probably need to do the same in Java, C# and C++, so an easily portable solution would be preferable.
score: 1
tagged with: java
tagged with: http://stackoverflow.com/tag/json
tagged with: encoding
upvote count: 1
answer count: 1
downvote count: 0

http://stackoverflow.com/q/2752713
has body: I am working on a project in which I have around 100000 addreses in major cities in India(it is a table in a database). I want to know if it is possible to obtain the distances to to nearest landmarks (Mall, Hospital, and Airport etc.). Ideally I want these distances to be mergeed to the parent table. We have Java and Php coders to get it done once we find out how to go about it. Any pointers will be of great help. Thank you.
upvote count: 0
answer count: 1
favorite count: 0
tagged with: python
has title: Obtain distances to nearest landmarks (Mall, Hospital, and Airport etc.) using google map
type: UnansweredQuestion
tagged with: php
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/3734719
tagged with: java
score: -1
has answer: http://stackoverflow.com/a/3543146

http://stackoverflow.com/q/2699583
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/2699600
tagged with: java
answer count: 1
downvote count: 0
has body: I am using JSF 2.0 and attempting to pass values between different pages in my App. The setup is as follows: I have a page called userSelect that has a backing bean userSelectBacking. On this page I display a list of users that can be selected and submit using an h:commandbutton, when the page is submit the navigation goes to a userEdit page. I have a page called userEdit, that has a backing bean userEditBacking which displays the information for a user and allows that user to be edited. I would like to pass the user selected from the userSelect page into the userEdit page. I am currently using f:setPropertyActionListener to set the user in my userEdit backing from the userSelect page, however when I navigate to the userEdit page, it loses the information I set. is there a way that I can pass the values between the two pages/backing beans? thanks
favorite count: 0
accepted answer: http://stackoverflow.com/a/2699600
type: AnsweredQuestion
tagged with: jsf
score: 1
has title: JSF, How to set a property in a different page/backing bean and then navigate to that page?

http://stackoverflow.com/comment/2673817
type: Comment
score: 3
comment on: http://stackoverflow.com/a/2651833
has text: Zwei brings up a good point. All those complications due to `add` can be handled just like how the `entrySet()` view does: allow some operations and don't allow others. A natural response, of course, is "What kind of `Set` doesn't support `add`?" -- well, if such behavior is acceptable for `entrySet()`, then why isn't it acceptable for `this`? That said, I _am_ mostly convinced already of why this is not such a great idea as I once thought, but I still think it's worthy of further debate, if only to enrich my own understanding of what makes a good API/OOP design.
type: AnswerComment

http://stackoverflow.com/q/2616057
type: Question
possible better answer: http://stackoverflow.com/a/2616743
tagged with: udp
answer count: 3
has answer: http://stackoverflow.com/a/2616743
downvote count: 0
accepted answer: http://stackoverflow.com/a/2616064
has answer: http://stackoverflow.com/a/2616151
favorite count: 0
has title: How to distinguish between two different UDP clients on the same IP address?
type: AnsweredQuestion
score: 7
tagged with: java
has body: I'm writing a UDP server, which is a first for me; I've only done a bit of TCP communications. And I'm having trouble figuring out exactly how to distinguish which user is which, since UDP deals only with packets rather than connections and I therefore cannot tell exactly who I'm communicating with. Here is pseudocode of my current server loop: DatagramPacket p; socket.receive(p); // now p contains the user's IP and port, and the data int key = getKey(p); if(key == 0) { // connection request key = makeKey(p); clients.add(key, p.ip); send(p.ip, p.port, key); // give the user his key } else { // user has a key // verify key belongs to that IP address // lookup the user's session data based on the key // react to the packet in the context of the session } When designing this, I kept in mind these points: Multiple users may exist on the same IP address, due to the presence of routers, therefore users must have a separate identification key. Packets can be spoofed, so the key should be checked against its original IP address and ignored if a different IP tries to use the key. The outbound port on the client side might change among packets. Is that third assumption correct, or can I simply assume that one user = one IP+port combination? Is this commonly done, or should I continue to create a special key like I am currently doing? I'm not completely clear on how TCP negotiates a connection so if you think I should model it off of TCP then please link me to a good tutorial or something on TCP's SYN/SYNACK/ACK mess. Also note, I do have a provision to resend a key, if an IP sends a 0 and that IP already has a pending key; I omitted it to keep the snippet simple. I understand that UDP is not guaranteed to arrive, and I plan to add reliability to the main packet handling code later as well.
upvote count: 7
has answer: http://stackoverflow.com/a/2616064

http://stackoverflow.com/a/4569078
answers question: http://stackoverflow.com/q/2668698
has body: See this blog of mine File-based User Authentication under WebSphere 6 for how to authenticate users agains a file with usernames/passwords.
type: Answer
score: 0

http://stackoverflow.com/comment/39990962
type: Comment
has text: @ceran The former. The latter is an implementation of a public API so cannot tell which thread it is called on.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2684423

http://stackoverflow.com/comment/30780219
has text: An advantage of using C# properties or getters and setters (even if you don't put any code in them) is that: you have the option to add code to them without changing any code that depends on your API.
type: AnswerComment
comment on: http://stackoverflow.com/a/2701297
type: Comment
score: 0

http://stackoverflow.com/comment/2724027
type: QuestionComment
comment on: http://stackoverflow.com/q/2701182
type: Comment
has text: It's generally a bad idea. If you know the object is of type Subclass, then refer to it as that and you have no problem. If the method really belongs in Base - put it in Base.
score: 2

http://stackoverflow.com/q/2724352
tagged with: jar
tagged with: tomcat
has answer: http://stackoverflow.com/a/2724451
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2724451
type: Question
has body: I am a brand new Java developer (I have been working in asp.net) and I inherited a project I am trying to get running correctly. I am on Windows 7 and have Tomcat installed and I am using Eclipse I'm trying to figure out how the heck Jar's work in java and I am really confused at the moment. I have been playing around with it and looking up stuff on the web for about a day now and this is where I am: I have a dynamic web project which I inherited and it has what I am going to assume is a fairly standard project layout. There is a lib folder in the project root which contains some jar's. If I don't do anything and go to a particular page in the site I get this error: "The import net.sf cannot be resolved, XLSTransformer cannot be resolved to a type" So I added jxls-core-0.9.8.jar to my build path in Eclipse and that error went away but now I am getting this error "java.lang.ClassNotFoundException: net.sf.jxls.transformer.XLSTransformer" I copied that jar from its current location to the tomcat/lib directory and that error went away. Now I am getting essentially the same issue with another file. Mainly I just need to know how should jar's work? Do they need to be in the class path, in web/WEB-INF/lib, in tomcat/lib, in all of them, none of them I just can't figure it out. Also when I was looking around I saw some stuff that indicated the order of my classpath entries matters as well. If that is the case how do you insure you have them in the correct order.
answer count: 3
has title: Java Lib file errors
has answer: http://stackoverflow.com/a/2747183
score: 0
tagged with: java
possible better answer: http://stackoverflow.com/a/2747162
has answer: http://stackoverflow.com/a/2747162
tagged with: eclipse

http://stackoverflow.com/q/2725141
has answer: http://stackoverflow.com/a/9159698
has answer: http://stackoverflow.com/a/2725435
tagged with: jtextpane
tagged with: swing
tagged with: rtf
type: Question
has title: Java JTextPane RTF Save
accepted answer: http://stackoverflow.com/a/2725435
has comment: http://stackoverflow.com/comment/2752018
has answer: http://stackoverflow.com/a/9296179
has body: i have the following code trying to save the contents of a JTextPane as RTF. although a file is created in the following code but it is empty! any tips regarding what am i doing wrong? (as usual dont forget im a beginner!) if (option == JFileChooser.APPROVE_OPTION) { //////////////////////////////////////////////////////////////////////// //System.out.println(chooser.getSelectedFile().getName()); //System.out.println(chooser.getSelectedFile().getAbsoluteFile()); /////////////////////////////////////////////////////////////////////////// StyledDocument doc = (StyledDocument)textPaneHistory.getDocument(); RTFEditorKit kit = new RTFEditorKit(); BufferedOutputStream out; try { out = new BufferedOutputStream(new FileOutputStream(chooser.getSelectedFile().getName())); kit.write(out, doc, doc.getStartPosition().getOffset(), doc.getLength()); } catch (FileNotFoundException e) { } catch (IOException e){ } catch (BadLocationException e){ } } EDIT: HTMLEditorKit if i use HTMLEditorKit it works and thats what i really wanted. SOLVED!
has comment: http://stackoverflow.com/comment/2752075
score: 3
possible better answer: http://stackoverflow.com/a/9296179
downvote count: 0
has answer: http://stackoverflow.com/a/15356797
favorite count: 0
answer count: 4
type: AnsweredQuestion
upvote count: 3
tagged with: java

http://stackoverflow.com/a/2687585
has comment: http://stackoverflow.com/comment/2715467
downvote count: 1
has comment: http://stackoverflow.com/comment/2715526
has comment: http://stackoverflow.com/comment/2724289
has comment: http://stackoverflow.com/comment/2715721
upvote count: 10
has comment: http://stackoverflow.com/comment/2710244
score: 9
has body: First thing is first: your classes should start with a capital letter per the Java Naming Conventions: Class names should be nouns, in mixed case with the first letter of each internal word capitalized. Try to keep your class names simple and descriptive. Use whole words-avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML). Second: Try to break down the code into coherent sections and organize them around some common feature that you're dealing with... perhaps around the functionality or the model you're programming. The (basic) model for the server is that the only thing it does is receive socket connections... the server relies on a handler to handle those connections and that's it. If you try to build that model it would look something like this: class Server{ private final ServerSocket serverSocket; private final ExecutorService pool; public Server(int port, int poolSize) throws IOException { serverSocket = new ServerSocket(port); pool = Executors.newFixedThreadPool(poolSize); } public void serve() { try { while(true) { pool.execute(new Handler(serverSocket.accept())); } } catch (IOException ex) { pool.shutdown(); } } } class Handler implements Runnable { private final Socket socket; Handler(Socket socket) { this.socket = socket; } public void run() { // receive the datagram packets } } Third: I would recommend that you look at some existing examples. Multi-threaded Client/Server Applications: http://www.ase.md/~aursu/ClientServerThreads.html Doug Lea: http://www.developer.com/java/ent/article.php/3645111/Java-5s-BlockingQueue.htm (thanks to John) http://gee.cs.oswego.edu/dl/cpj/index.html (still can't find the exact example, but it's there somewhere... if you feel brave look over his allcode.java file) . Concurrency in Practice examples: http://www.javaconcurrencyinpractice.com/listings.html Java Concurrency Tutorials: http://java.sun.com/docs/books/tutorial/essential/concurrency/ Updated pe…
has comment: http://stackoverflow.com/comment/7559547
has comment: http://stackoverflow.com/comment/7553705
has comment: http://stackoverflow.com/comment/2711840
answers question: http://stackoverflow.com/q/2687238
type: Answer
has comment: http://stackoverflow.com/comment/2714879
has comment: http://stackoverflow.com/comment/2708726

http://stackoverflow.com/q/2777005
has answer: http://stackoverflow.com/a/2777391
type: Question
upvote count: 4
has answer: http://stackoverflow.com/a/66383590
downvote count: 0
score: 4
has body: Do you know of any free Java library which support the HTTP pipelining option of HTTP/1.1 ( http://en.wikipedia.org/wiki/HTTP_pipelining ) ?
favorite count: 0
answer count: 5
has answer: http://stackoverflow.com/a/3552389
accepted answer: http://stackoverflow.com/a/2777391
possible better answer: http://stackoverflow.com/a/2777347
has answer: http://stackoverflow.com/a/5706428
tagged with: sockets
has answer: http://stackoverflow.com/a/2777347
has title: Java based HTTP Client which supports Pipelining
tagged with: http
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/comment/2803315
has text: Sorry, the example in the comment was wrong. In your case you should use `import static com.example.PowerTools.*;`, thus including the classname which contains the static methods. Also see the tutorial.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2768994
type: Comment

http://stackoverflow.com/comment/2750571
has text: Have you done any troubleshooting? Debugging? Are you running this in an IDE? I'd recommend editing your question to add more information.
comment on: http://stackoverflow.com/q/2723809
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/comment/8191347
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2741276
has text: I'm curious if you tried hasMoreResults on the Statement (false indicating there is no resultset to return)?
score: 0

http://stackoverflow.com/q/2603274
has title: How can I run a function before current function using annotations?
answer count: 4
has answer: http://stackoverflow.com/a/2603317
type: AnsweredQuestion
downvote count: 0
score: 1
favorite count: 0
type: Question
accepted answer: http://stackoverflow.com/a/2603317
possible better answer: http://stackoverflow.com/a/2603322
has answer: http://stackoverflow.com/a/2603635
has answer: http://stackoverflow.com/a/2603322
tagged with: java
has body: Is there any way for using an annotation for running a function before currently called function, something like this: public void doSomethingEarlier() { } @DoSomethingEarlier public void doSomething() { } So I want to call doSomethin() function, and before executing this function I want to automatically run doSomethingEarlier() function.
tagged with: annotations
upvote count: 1
has answer: http://stackoverflow.com/a/2603342

http://stackoverflow.com/q/2643470
favorite count: 0
has body: I need to add paginator for my Hibernate application. I applied it to some of my database operations which I perform using Criteria by setting Projection.count().This is working fine. But when I use hql to query, I can't seem to get and efficient method to get the result count. If I do query.list().size() it takes lot of time and I think hibernate does load all the objects in memory. Can anyone please suggest an efficient method to retrieve the result count when using hql?
type: UnansweredQuestion
tagged with: orm
upvote count: 1
linked to: http://stackoverflow.com/q/168084
type: Question
has comment: http://stackoverflow.com/comment/2661819
score: 1
tagged with: java
tagged with: hibernate
tagged with: pagination
has title: Hibernate Hql find result size for paginator
has answer: http://stackoverflow.com/a/2646388
tagged with: hql
has answer: http://stackoverflow.com/a/2643561
answer count: 2
downvote count: 0

http://stackoverflow.com/a/2772710
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2756160
upvote count: 2
type: Answer
answers question: http://stackoverflow.com/q/2756160
score: 2
downvote count: 0
has body: For an explanation about the MIDP security model, see answers to StackOverflow questions Application Error Occurs in Nokia 6300 and Privileged operations in netbeans mobility. If the certificate you used to sign your MIDlet wasn't on the phone, just adding it to the phone may not be enough. You probably need to add the goDaddy certificate to the MIDP runtime "trusted third party" security domain. Somehow. I'm not convinced that's possible on a Nokia 3110 Classic.

http://stackoverflow.com/a/3695888
type: Answer
upvote count: 3
accepted answer of: http://stackoverflow.com/q/2622694
answers question: http://stackoverflow.com/q/2622694
score: 3
has body: I had the same problem. This is how I solved it: When I launch ant release, there is this line in the output: [setup] Importing rules file: tools/ant/ant_rules_r3.xml. I edited ant_rules_r3.xml and replaced "ascii" with "UTF8".
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/3896214

http://stackoverflow.com/a/20797324
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/2758612
downvote count: 0
score: 1
has body: It seems problem is not in JDK bug 6602600 ( it was solved at 2010-05-22), but in incorrect call of sleep(10) in circle. Addition note, that the main Thread must give directly CHANCE to other threads to realize thier tasks by invoke SLEEP(0) in EVERY branch of outer circle. It is better, I think, to use Thread.yield() instead of Thread.sleep(0) The result corrected part of previous problem code is such like this: ....................... ........................ Thread.yield(); if (i % 1000== 0) { System.out.println(i + "/" + counter.get()+ "/"+service.toString()); } // // while (i &gt; counter.get()) { // Thread.sleep(10); // } It works correctly with amount of outer counter up to 150 000 000 tested circles.

http://stackoverflow.com/q/2759289
has answer: http://stackoverflow.com/a/2759493
upvote count: 6
type: AnsweredQuestion
tagged with: java
type: Question
has body: Trying to tail / parse some log files. Entries start with a date then can span many lines. This works, but does not ever see new entries to file. File inputFile = new File("C:/test.txt"); InputStream is = new FileInputStream(inputFile); InputStream bis = new BufferedInputStream(is); //bis.skip(inputFile.length()); Scanner src = new Scanner(bis); src.useDelimiter("\n2010-05-01 "); while (true) { while(src.hasNext()){ System.out.println("[ " + src.next() + " ]"); } } Doesn't seem like Scanner's next() or hasNext() detects new entries to file. Any idea how else I can implement, basically, a tail -f with custom delimiter. ok - using Kelly's advise i'm checking &amp; refreshing the scanner, this works. Thank you !! if anyone has improvement suggestions plz do! File inputFile = new File("C:/test.txt"); InputStream is = new FileInputStream(inputFile); InputStream bis = new BufferedInputStream(is); //bis.skip(inputFile.length()); Scanner src = new Scanner(bis); src.useDelimiter("\n2010-05-01 "); while (true) { while(src.hasNext()){ System.out.println("[ " + src.next() + " ]"); } Thread.sleep(50); if(bis.available() &gt; 0){ src = new Scanner(bis); src.useDelimiter("\n2010-05-01 "); } }
accepted answer: http://stackoverflow.com/a/2759493
has comment: http://stackoverflow.com/comment/2791111
tagged with: tail
answer count: 1
downvote count: 0
has title: Java Scanner won't follow file
favorite count: 0
tagged with: java.util.scanner
tagged with: io
score: 6
has comment: http://stackoverflow.com/comment/2791138

http://stackoverflow.com/a/2722815
has comment: http://stackoverflow.com/comment/2749727
has body: You can go as suggested by Mark, or convert them to String to get the single digits: int test[]={10212,10202,11000,11000,11010}; ArrayList&lt;Integer&gt; test2 = new ArrayList&lt;Integer&gt;(); for (int i : test) { String str = String.valueOf(i); for (int j = 0; j &lt; str.length(); ++j) test2.add((int)(str.charAt(j)-'0')); } As more memory efficient approach that still involves string would be to keep all the digits as just one string and calculate the int value on the fly: class Digits { String str; Digits(int[] nums) { StringBuilder sb = new StringBuilder(); for (int i : nums) sb.append(String.valueOf(i)); str = sb.toString(); } int length() { return str.length(); } int nth(int i) { return (int)(str.charAt(i)-'0'); } } Mind that CheesePls solution is the right one because it uses math as it is intended to be used. Mine is just for noobs (and just to give another approach to the problem)..
type: Answer
has comment: http://stackoverflow.com/comment/2749107
score: 6
upvote count: 7
answers question: http://stackoverflow.com/q/2722742
downvote count: 1
has comment: http://stackoverflow.com/comment/2749171
has comment: http://stackoverflow.com/comment/2750768
has comment: http://stackoverflow.com/comment/2749135
has comment: http://stackoverflow.com/comment/2749395

http://stackoverflow.com/comment/97794920
type: QuestionComment
comment on: http://stackoverflow.com/q/2712618
has text: What makes you think a different port is used?
type: Comment
score: 0

url
tags question: http://stackoverflow.com/q/2661849
tags question: http://stackoverflow.com/q/2742076
tags question: http://stackoverflow.com/q/2659000
tags question: http://stackoverflow.com/q/2601780
tag name: url
tags question: http://stackoverflow.com/q/2624655
tags question: http://stackoverflow.com/q/2619833
tags question: http://stackoverflow.com/q/2676288
tags question: http://stackoverflow.com/q/2723829
tags question: http://stackoverflow.com/q/2680837
tags question: http://stackoverflow.com/q/2661884
tags question: http://stackoverflow.com/q/2644011
tags question: http://stackoverflow.com/q/2609199
type: Tag

http://stackoverflow.com/q/2761177
has comment: http://stackoverflow.com/comment/2793309
has comment: http://stackoverflow.com/comment/2793360
favorite count: 0
has comment: http://stackoverflow.com/comment/2793152
has answer: http://stackoverflow.com/a/2761406
answer count: 4
score: 8
tagged with: terracotta
downvote count: 0
has body: Is Terracotta a distributed cache?
upvote count: 8
possible better answer: http://stackoverflow.com/a/5208511
has comment: http://stackoverflow.com/comment/2793148
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2793168
has answer: http://stackoverflow.com/a/5208511
has answer: http://stackoverflow.com/a/2761256
has comment: http://stackoverflow.com/comment/2794799
has answer: http://stackoverflow.com/a/10672517
accepted answer: http://stackoverflow.com/a/2761256
has comment: http://stackoverflow.com/comment/2793330
tagged with: java
has title: Is Terracotta a distributed cache?
tagged with: distributed-caching
has comment: http://stackoverflow.com/comment/2793141
type: Question

http://stackoverflow.com/comment/12230328
score: 0
type: Comment
has text: Which link doesn't work? I just tried them all and they seem ok.
comment on: http://stackoverflow.com/a/2745182
type: AnswerComment

http://stackoverflow.com/q/2633323
upvote count: 4
has answer: http://stackoverflow.com/a/2633444
downvote count: 0
has answer: http://stackoverflow.com/a/2633401
favorite count: 0
tagged with: listener
accepted answer: http://stackoverflow.com/a/2633401
answer count: 4
score: 4
type: AnsweredQuestion
has body: I have a GUI that is issuing commands to a web server based on slider values. Some of these sliders are "coupled" on the web server, so changing one of them may also change another one. The coupling is accomplished by the web server returning a list of the values that were set based on the the issued command. So I can easily set the appropriate sliders based on this response, but the issue is that doing this causes the ChangeListener to be fired and then a command is issued to the web server again. Ideally, the "coupling" should be well behaved and avoid infinite loops, but that is a potential concern and send all those extra events seems unnecessary. The two solutions I could think of were: Temporarily removing the listeners, changing the value, and then putting them back. Add a "manual" flag to let the listener know that it should ignore the change. Neither of those seems like the ideal solution to me, but is one of them "better" than the other? Or is there a third solution that I'm not considering?
tagged with: java
has answer: http://stackoverflow.com/a/65025940
tagged with: swing
type: Question
has answer: http://stackoverflow.com/a/3666943
has title: Avoiding unnecessary events and infinite loop in "coupled" JSliders?
possible better answer: http://stackoverflow.com/a/2633444

http://stackoverflow.com/comment/2626390
has text: Processes are *expensive* resource-intensive things. They're not free. A preferences panel is probably minimally demanding. Unless you have a specific need for multiple processes, don't complicate things. Keep it as simple as possible. You're proposing to make things MORE resource intensive in order to make things LESS resource intensive. Don't do that.
type: Comment
type: QuestionComment
score: 3
comment on: http://stackoverflow.com/q/2614890

http://stackoverflow.com/comment/2763398
type: AnswerComment
comment on: http://stackoverflow.com/a/2735153
type: Comment
score: 1
has text: That's a good point, but that's a Collections Framework contract, regardless of `hashCode` formula.

http://stackoverflow.com/comment/2813945
comment on: http://stackoverflow.com/q/2779067
score: 0
type: Comment
has text: OK, and so when you change the coefficient in one of the terms, you're saying that the coefficient in other terms changes to the new value as well? In all the other terms? Just one?
type: QuestionComment

http://stackoverflow.com/comment/2707862
type: AnswerComment
comment on: http://stackoverflow.com/a/2610365
score: 0
has text: I don't really see how that fits the requirement if Java has to be installed (no other installations needed by the user). Seems like a big dependency to me.. launch4j is only for windows (which defeats the Windows Vista and OS X requirement)
type: Comment

list
type: Tag
tags question: http://stackoverflow.com/q/2746026
tags question: http://stackoverflow.com/q/2762093
tags question: http://stackoverflow.com/q/2737643
tags question: http://stackoverflow.com/q/2743467
tags question: http://stackoverflow.com/q/2669695
tag name: list
tags question: http://stackoverflow.com/q/2707440
tags question: http://stackoverflow.com/q/2617369
tags question: http://stackoverflow.com/q/2607289
tags question: http://stackoverflow.com/q/2674621
tags question: http://stackoverflow.com/q/2782893
tags question: http://stackoverflow.com/q/2766465
tags question: http://stackoverflow.com/q/2694517
tags question: http://stackoverflow.com/q/2723781
tags question: http://stackoverflow.com/q/2647232
tags question: http://stackoverflow.com/q/2714353
tags question: http://stackoverflow.com/q/2758971
tags question: http://stackoverflow.com/q/2627018
tags question: http://stackoverflow.com/q/2687599
tags question: http://stackoverflow.com/q/2664800

http://stackoverflow.com/a/2783216
score: 28
type: Answer
downvote count: 0
has body: You still can use Collections.min with a custom Comparator to get the Map.Entry with the lower value: Map<String, Double> map = new HashMap<String, Double>(); map.put("1.1", 1.1); map.put("0.1", 0.1); map.put("2.1", 2.1); Map.Entry<String, Double> min = Collections.min(map.entrySet(), new Comparator<Map.Entry<String, Double>>() { public int compare(Map.Entry<String, Double> entry1, Map.Entry<String, Double> entry2) { return entry1.getValue().compareTo(entry2.getValue()); } }); System.out.printf("%s: %f", min.getKey(), min.getValue()); // 0.1: 0.100000 With Java 8+: Map.Entry<String, Double> min = Collections.min(map.entrySet(), Map.Entry.comparingByValue());
upvote count: 28
answers question: http://stackoverflow.com/q/2776176

http://stackoverflow.com/a/44049310
upvote count: 13
has comment: http://stackoverflow.com/comment/86252390
has comment: http://stackoverflow.com/comment/75129249
type: Answer
answers question: http://stackoverflow.com/q/2686495
score: 13
downvote count: 0
has body: I had the same question and that's what lead me here. Quoting the Doc is not very helpful in this case, as I'm sure OP's question is not about how to use sessions, or what do they do, but why do they really exist, why not combine their capability with Connection. IMHO, this is a meta question. Loosely speaking Sessions are essentially a thread's view into a Connection, Here is what the JMS spec has to say about the relation between a thread and a Session while accessing the later. There are no restrictions on the number of threads that can use a session or any objects it creates. The restriction is that the resources of a session should not be used concurrently by multiple threads. It is up to the user to ensure that this concurrency restriction is met. The simplest way to do this is to use one thread. In the case of asynchronous delivery, use one thread for setup in stopped mode and then start asynchronous delivery. In more complex cases the user must provide explicit synchronization. From the messaging point of view, they hold a logical unit of work. That's why the Transactions got coupled with the Sessions as well. Having said that, quite often there will be 1:1 mapping between a connection and a Session. That's why I think JMSContext got introduced in 2.0. to simplify things. Looking at the date of OP's post I think I am almost a decade late. :D
has comment: http://stackoverflow.com/comment/86231797

http://stackoverflow.com/q/2659366
type: Question
tagged with: interface
has comment: http://stackoverflow.com/comment/65087094
has answer: http://stackoverflow.com/a/2659442
has answer: http://stackoverflow.com/a/2660515
has answer: http://stackoverflow.com/a/45504873
has answer: http://stackoverflow.com/a/2660788
answer count: 13
upvote count: 25
has answer: http://stackoverflow.com/a/2659394
has comment: http://stackoverflow.com/comment/64323672
possible better answer: http://stackoverflow.com/a/2659379
linked to: http://stackoverflow.com/q/2658288
has body: I've been programming in Java for a few courses in the University and I have the following question: Is it methodologically accepted that every class should implement an interface? Is it considered bad practice not to do so? Can you describe a situation where it's not a good idea to use interfaces? Edit: Personally, I like the notion of using Interfaces for everything as a methodology and habit, even if it's not clearly beneficial. Eclipse automatically created a class file with all the methods, so it doesn't waste any time anyway.
has answer: http://stackoverflow.com/a/2659379
has answer: http://stackoverflow.com/a/2660494
tagged with: java
has answer: http://stackoverflow.com/a/2659416
has answer: http://stackoverflow.com/a/2660516
has answer: http://stackoverflow.com/a/2659382
has answer: http://stackoverflow.com/a/2659423
has comment: http://stackoverflow.com/comment/64323696
score: 25
has answer: http://stackoverflow.com/a/2659671
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/825919
downvote count: 0
has answer: http://stackoverflow.com/a/2659404
has title: Java Interfaces Methodology: Should every class implement an interface?
has comment: http://stackoverflow.com/comment/64323719
favorite count: 0
accepted answer: http://stackoverflow.com/a/2659416

http://stackoverflow.com/a/2731764
upvote count: 4
answers question: http://stackoverflow.com/q/2731719
type: Answer
score: 3
has body: yes you can using outer class name with this. outer.this
downvote count: 1

http://stackoverflow.com/a/2625258
answers question: http://stackoverflow.com/q/2619016
accepted answer of: http://stackoverflow.com/q/2619016
has body: So this is what I did: itemList.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { if (e.keyCode == '\r' || e.keyCode == SWT.KEYPAD_CR) { okButtonAction(); } else if (e.keyCode == SWT.ARROW_UP || e.keyCode == SWT.ARROW_DOWN || e.keyCode == SWT.ARROW_LEFT || e.keyCode == SWT.ARROW_RIGHT) { super.keyReleased(e); } else if (e.character &gt; 0) { filterInput.setFocus(); Event event = new Event(); event.type = SWT.KeyDown; event.keyCode = e.keyCode; event.character = e.character; Display.getCurrent().post(event); try { Thread.sleep(10); } catch (InterruptedException ie) { ie.printStackTrace(); } event.type = SWT.KeyUp; Display.getCurrent().post(event); } } }); I read that the Display.post method was there for doing automatic GUI testing, but it works for my purpose here, so I will use it unless anyone can give me a good reason why not??
type: AcceptedAnswer
downvote count: 0
type: Answer
score: 2
upvote count: 2

http://stackoverflow.com/a/2634667
score: 4
type: Answer
has body: A* is the way, if you are scared about efficiency: check it out here. Or if you feel brave you can go for D* here.. both will be more efficient (because they use an heuristic to estimate the distance) but not so hard to implement! BFS is definetely not a good way to implement pathfinding, it's just simple..
has comment: http://stackoverflow.com/comment/2648634
upvote count: 4
answers question: http://stackoverflow.com/q/2634647
downvote count: 0

http://stackoverflow.com/a/2605829
has body: You'd better place the bean as request (or session) attribute and iterate over it using JSTL: &lt;c:forEach items="${bean.ys}" var="item"&gt; &lt;h1&gt;${item.title}&lt;/h1&gt; &lt;/c:forEach&gt;
type: Answer
answers question: http://stackoverflow.com/q/2605801
upvote count: 12
accepted answer of: http://stackoverflow.com/q/2605801
has comment: http://stackoverflow.com/comment/2616300
downvote count: 0
has comment: http://stackoverflow.com/comment/2617384
score: 12
has comment: http://stackoverflow.com/comment/2615941
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2615901

http://stackoverflow.com/a/2694185
type: Answer
has body: There used to be a very small and simple XML parser called NanoXML. It seems not to be developed anymore, but it's still available at http://devkix.com/nanoxml.php
score: 0
answers question: http://stackoverflow.com/q/2694045

count
tags question: http://stackoverflow.com/q/2687599
tag name: count
type: Tag
tags question: http://stackoverflow.com/q/2763659

http://stackoverflow.com/q/2651913
has title: Security issue on web application using Firebug
tagged with: java
answer count: 3
upvote count: 1
has answer: http://stackoverflow.com/a/2651929
type: UnansweredQuestion
has body: I have developed a web application in JSP. I have many JavaScript validation for text validation in the JSP page. During the testing, I enabled Firebug in Firefox and cleared a function that validates and submits to a servlet. The web application allows to submit garbage value of the textfield. How to overcome this? Any solutions?
downvote count: 0
tagged with: jsp
score: 1
has answer: http://stackoverflow.com/a/2651923
favorite count: 0
type: Question
has answer: http://stackoverflow.com/a/2651999

http://stackoverflow.com/q/2743872
accepted answer: http://stackoverflow.com/a/2744516
tagged with: android
has answer: http://stackoverflow.com/a/2744448
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2744516
downvote count: 0
score: 1
tagged with: java
type: Question
has title: How to find the last 7 days Records in sqlite?
possible better answer: http://stackoverflow.com/a/2744448
has body: I would like to know the past 7 days record. I want to write a query for that in where condition. I have very basic knowledge of sqlite. Please help me with this query.
answer count: 2
upvote count: 1
tagged with: sqlite
favorite count: 0

http://stackoverflow.com/q/2742191
possible better answer: http://stackoverflow.com/a/2742216
favorite count: 0
has answer: http://stackoverflow.com/a/2742216
has title: Dates comparisons in java
answer count: 5
has answer: http://stackoverflow.com/a/2742217
score: -3
upvote count: 1
has body: I would like to compare a date to the current date. could you please tell me how to do that in java.
type: AnsweredQuestion
tagged with: java
tagged with: date
has answer: http://stackoverflow.com/a/2742229
type: Question
accepted answer: http://stackoverflow.com/a/2742217
has answer: http://stackoverflow.com/a/2742425
tagged with: comparison
downvote count: 4
has answer: http://stackoverflow.com/a/2742206
has comment: http://stackoverflow.com/comment/2771299

http://stackoverflow.com/comment/6556977
type: QuestionComment
score: 6
type: Comment
has text: What is your use case? What queries will you perform against your data? How large is your data? Is your application read or write heavy?
comment on: http://stackoverflow.com/q/2746201

http://stackoverflow.com/q/2761543
upvote count: 23
answer count: 6
has answer: http://stackoverflow.com/a/2761630
has answer: http://stackoverflow.com/a/15057845
has comment: http://stackoverflow.com/comment/2793605
has title: How to handle large dataset with JPA (or at least with Hibernate)?
has answer: http://stackoverflow.com/a/20787413
favorite count: 0
possible better answer: http://stackoverflow.com/a/20787413
has answer: http://stackoverflow.com/a/12693325
has answer: http://stackoverflow.com/a/12691624
tagged with: jakarta-ee
type: AnsweredQuestion
tagged with: performance
downvote count: 0
tagged with: java
tagged with: hibernate
score: 23
accepted answer: http://stackoverflow.com/a/2761630
linked to: http://stackoverflow.com/q/5067619
has body: I need to make my web-app work with really huge datasets. At the moment I get either OutOfMemoryException or output which is being generated 1-2 minutes. Let's put it simple and suppose that we have 2 tables in DB: Worker and WorkLog with about 1000 rows in the first one and 10 000 000 rows in the second one. Latter table has several fields including 'workerId' and 'hoursWorked' fields among others. What we need is: count total hours worked by each user; list of work periods for each user. The most straightforward approach (IMO) for each task in plain SQL is: 1) select Worker.name, sum(hoursWorked) from Worker, WorkLog where Worker.id = WorkLog.workerId group by Worker.name; //results of this query should be transformed to Multimap&lt;Worker, Long&gt; 2) select Worker.name, WorkLog.start, WorkLog.hoursWorked from Worker, WorkLog where Worker.id = WorkLog.workerId; //results of this query should be transformed to Multimap&lt;Worker, Period&gt; //if it was JDBC then it would be vitally //to set resultSet.setFetchSize (someSmallNumber), ~100 So, I have two questions: how to implement each of my approaches with JPA (or at least with Hibernate); how would you handle this problem (with JPA or Hibernate of course)?
type: Question
has answer: http://stackoverflow.com/a/8257729
has comment: http://stackoverflow.com/comment/2793573
tagged with: jpa

http://stackoverflow.com/a/32021172
has body: Check out the new Google Play Services 7.8 API that includes Barcode tracking: https://developers.google.com/vision/barcodes-overview
type: Answer
upvote count: 4
score: 4
has comment: http://stackoverflow.com/comment/103780103
downvote count: 0
answers question: http://stackoverflow.com/q/2607858

http://stackoverflow.com/q/2705468
tagged with: document
has answer: http://stackoverflow.com/a/2705975
has body: I'm working on application in Java that will maintain database of song lyrics in plain text and print out some songbooks/chordbooks(that is create PDF file from selected songs). I was planing that the Java application will generate source code for pdflatex and after compiling this source user will get PDF file. Lately I've run into a lot of problems because of latex limitation: fixed memory size (some pictures will also be drawn to PDF) - error when exceeded, no way to query end of line or and of page dynamically, it's very hard to override latex placement algorithm in a complex way,... see also some my other questions regarding latex. I come to conclusion that latex is not good option for automated PDF generation. So I need replacement. I need to be able to typeset: Chords over lyrics when the lyrics are in variable char width so I need to be able to measure text width Chord diagrams that means I'll have to draw quite complex pictures Each song on separate double page Different fonts etc. Thanks for all answers
type: Question
accepted answer: http://stackoverflow.com/a/2705555
has answer: http://stackoverflow.com/a/3818337
possible better answer: http://stackoverflow.com/a/2705975
score: 4
favorite count: 0
has answer: http://stackoverflow.com/a/2705555
tagged with: http://stackoverflow.com/tag/pdf
upvote count: 4
tagged with: pdf-generation
tagged with: latex
has title: Alternative to latex / a way to typeset good looking documents from Java to PDF
answer count: 5
has answer: http://stackoverflow.com/a/2714958
has answer: http://stackoverflow.com/a/2824394
has comment: http://stackoverflow.com/comment/2729135
type: AnsweredQuestion
downvote count: 0
tagged with: java

http://stackoverflow.com/q/2780694
has title: Changing order of children of an SWT Composite
accepted answer: http://stackoverflow.com/a/2780964
score: 11
upvote count: 11
type: AnsweredQuestion
tagged with: java
tagged with: swt
type: Question
has answer: http://stackoverflow.com/a/2780964
answer count: 1
downvote count: 0
has body: In my case I have two children of a SashForm, but the question applies to all Composites. class MainWindow { Sashform sashform; Tree child1 = null; Table child2 = null; MainWindow(Shell shell) { sashform = new SashForm(shell, SWT.NONE); } // Not called from constructor because it needs data not available at that time void CreateFirstChild() { ... Tree child1 = new Tree(sashform, SWT.NONE); } void CreateSecondChild() { ... Table child2 = new Table(sashform, SWT.NONE); } } I don't know in advance in what order these methods will be called. How can I make sure that child1 is placed on the left, and child2 on the right? Alternately, is there a way to change their order as children of sashform after they are created? Currently my best idea is to put in placeholders like this: class MainWindow { Sashform sashform; private Composite placeholder1; private Composite placeholder2; Tree child1 = null; Table child2 = null; MainWindow(Shell shell) { sashform = new SashForm(shell, SWT.NONE); placeholder1 = new Composite(sashform, SWT.NONE); placeholder2 = new Composite(sashform, SWT.NONE); } void CreateFirstChild() { ... Tree child1 = new Tree(placeholder1, SWT.NONE); } void CreateSecondChild() { ... Table child2 = new Table(placeholder2, SWT.NONE); } }
favorite count: 0

http://stackoverflow.com/a/2760691
has body: In fact getters a should be synchronized too or fields are to be made volatile. That is because when you get some value, you're probably interested in a most recent version of the value. You see, synchronized block semantics provides not only atomicity of execution (e.g. it guarantees that only one thread executes this block at one time), but also a visibility. It means that when thread enters synchronized block it invalidates its local cache and when it goes out it dumps any variables that have been modified back to main memory. volatile variables has the same visibility semantics.
score: 1
answers question: http://stackoverflow.com/q/2760294
upvote count: 1
downvote count: 0
type: Answer

http://stackoverflow.com/comment/26796118
comment on: http://stackoverflow.com/a/2629393
has text: @jalf - I'm not doubting you particularly, but would just like to find some reference that *actually* describes what's going on
type: Comment
score: 2
type: AnswerComment

http://stackoverflow.com/comment/2822295
type: Comment
comment on: http://stackoverflow.com/a/2783206
score: 2
type: AnswerComment
has text: "I do read the output from the subprocess using getInputStream() a few lines after the code I showed, but the code hangs before it gets there" ... so therefore you should be doing that *first*. In other words in a separate thread. Two threads, one for the output and one for the err.

http://stackoverflow.com/a/2674039
has comment: http://stackoverflow.com/comment/2692925
score: 6
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/2674021
has body: To see if two maps have the same values, you can do the following: Get their Collection&lt;V&gt; values() views Wrap into List&lt;V&gt; Collections.sort those lists Test if the two lists are equals Something like this works (though its type bounds can be improved on): static &lt;V extends Comparable&lt;V&gt;&gt; boolean valuesEquals(Map&lt;?,V&gt; map1, Map&lt;?,V&gt; map2) { List&lt;V&gt; values1 = new ArrayList&lt;V&gt;(map1.values()); List&lt;V&gt; values2 = new ArrayList&lt;V&gt;(map2.values()); Collections.sort(values1); Collections.sort(values2); return values1.equals(values2); } Test harness: Map&lt;String, String&gt; map1 = new HashMap&lt;String,String&gt;(); map1.put("A", "B"); map1.put("C", "D"); Map&lt;String, String&gt; map2 = new HashMap&lt;String,String&gt;(); map2.put("A", "D"); map2.put("C", "B"); System.out.println(valuesEquals(map1, map2)); // prints "true" This is O(N log N) due to Collections.sort. See also: Collection&lt;V&gt; values() To test if the keys are equals is easier, because they're Set&lt;K&gt;: map1.keySet().equals(map2.keySet()) See also: Set&lt;K&gt; keySet()
upvote count: 6
has comment: http://stackoverflow.com/comment/2692914

http://stackoverflow.com/comment/29974484
comment on: http://stackoverflow.com/a/2671560
type: Comment
has text: MINA supports NIO only and not NIO.2.. Netty supports that but their documentation is very bad..
score: 0
type: AnswerComment

http://stackoverflow.com/comment/29576124
comment on: http://stackoverflow.com/a/19882503
type: AnswerComment
has text: It is 3. chmod 777 -R Project_Folder 5. chmod 777 -R Bin_Folder, where the error is showing
score: 0
type: Comment

http://stackoverflow.com/a/2713952
answers question: http://stackoverflow.com/q/2713655
upvote count: 21
type: Answer
has comment: http://stackoverflow.com/comment/29845370
downvote count: 0
has body: Just being different: a recursive solution. Doesn't add any extra spaces. public static String reverse(String s) { int k = s.indexOf(" "); return k == -1 ? s : reverse(s.substring(k + 1)) + " " + s.substring(0, k); } System.out.println("[" + reverse("This is interview question") + "]"); // prints "[question interview is This]" I will also improve on the split solution by using \b instead (it's so obvious!). String[] parts = "Word boundary is better than space".split("\\b"); StringBuilder sb = new StringBuilder(); for (int i = parts.length; i --&gt; 0 ;) { sb.append(parts[i]); } System.out.println("[" + sb.toString() + "]"); // prints "[space than better is boundary Word]"
score: 21

http://stackoverflow.com/comment/70673018
type: AnswerComment
score: 0
has text: On windows 7, after searching for keyword "1.8.0_74", I found multiple registries using regedit in HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft/Java Development Kit/1.8.0_74/ or ../1.8.0_65 and all other installed previously... After deleting one by one registry from bottom to my latest installed java 1.8.0_112, now YourKit java profiler (profiler.exe) works without error: "Error occured while starting C:\Program Files\Java\jdk1.8.0_74\bin\javaw.exe" .
type: Comment
comment on: http://stackoverflow.com/a/17312386

http://stackoverflow.com/a/2707772
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2732596
downvote count: 0
type: Answer
score: 7
upvote count: 7
accepted answer of: http://stackoverflow.com/q/2707729
has body: After looking at the Mozilla Rhino docs, the solution is either to use: importPackage(Packages.jasim) within the script, or to use new Packages.jasim.JSTest() This is not so clear in the Sun docs regarding the importPackage in the ScriptingEngine docs.
answers question: http://stackoverflow.com/q/2707729

http://stackoverflow.com/a/2718131
has body: You don't say how you are passing these records to the database. The best way is to use an array, as this allows the use of Oracle's plenty of nifty FORALL bulk operations. This example package has two procedures. One which populates a collection of T23 records (a table which comprises five numeric columns) and one which bulk inserts records into that table using an array. SQL&gt; create or replace package p23 as 2 type t23_nt is table of t23%rowtype; 3 function pop_array ( p_no in number ) 4 return t23_nt; 5 procedure ins_table ( p_array in t23_nt ); 6 end p23; 7 / Package created. SQL&gt; create or replace package body p23 as 2 3 function pop_array ( p_no in number ) 4 return t23_nt 5 is 6 return_value t23_nt; 7 begin 8 select level,level,level,level,level 9 bulk collect into return_value 10 from dual 11 connect by level &lt;= p_no; 12 return return_value; 13 end pop_array; 14 15 procedure ins_table 16 ( p_array in t23_nt ) 17 is 18 s_time pls_integer; 19 begin 20 21 s_time := dbms_utility.get_time; 22 23 forall r in p_array.first()..p_array.last() 24 insert into t23 25 values p_array(r); 26 27 dbms_output.put_line('loaded ' 28 ||to_char(p_array.count())||' recs in ' 29 ||to_char(dbms_utility.get_time - s_time) 30 ||' csecs'); 31 end ins_table; 32 end p23; 33 / Package body created. SQL&gt; Here is the output from some sample runs: SQL&gt; declare 2 l_array p23.t23_nt; 3 begin 4 l_array := p23.pop_array(500); 5 p23.ins_table(l_array); 6 l_array := p23.pop_array(1000); 7 p23.ins_table(l_array); 8 l_array := p23.pop_array(2500); 9 p23.ins_table(l_array); 10 l_array := p23.pop_array(5000); 11 p23.ins_table(l_array); 12 l_array := p23.pop_array(10000); 13 p23.ins_table(l_array); 14 l_array := p23.pop_array(100000); 15 p23.ins_table(l_array); 16 end; 17 / loaded 500 recs in 0 csecs loaded 1000 recs in 0 csecs loaded 2500 recs in 0 csecs loaded 5000 recs in 1 csecs loaded 10000 recs in 1 csecs loaded 100000 recs in 15 csecs PL/SQL procedure successfully completed. SQL&g…
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/2744539
answers question: http://stackoverflow.com/q/2716818
has comment: http://stackoverflow.com/comment/104119462
has comment: http://stackoverflow.com/comment/104119787
type: Answer
upvote count: 2
has comment: http://stackoverflow.com/comment/104118196

http://stackoverflow.com/comment/2693537
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2672692
has text: for this one, you have to use js only.

http://stackoverflow.com/q/2764697
has title: compareTo and nested Enums
type: AnsweredQuestion
score: 1
tagged with: java
possible better answer: http://stackoverflow.com/a/2764819
has body: in "A Programmers Guide to Java SCJP Certification" I found an example which I can't follow. This the given enum: enum Scale3 { GOOD(Grade.C), BETTER(Grade.B), BEST(Grade.A); enum Grade {A, B, C} private Grade grade; Scale3(Grade grade) { this.grade = grade; } public Grade getGrade() { return grade; } } This is the given expression: Scale3.GOOD.getGrade().compareTo(Scale3.Grade.A) &gt; 0; I don't understand why this expression will be true? The return value will be 2. compareTo() will return a value > 0 if the given object is "less" than the object. Scale3.Grade.A is the "biggest" element of Grades, its ordinal number is 0. Scale3.GOOD is the "biggest" element of Scale3, its ordinal number is also 0. The constructor of Scale3 is called with Scale3.Grade.C, which ordinal number is 2. So the given expression is equal to the following code: Scale3.Grade.C.compareTo(Scale3.Grade.A) &gt; 0; A is "bigger" than C, so shouldn't be the result &lt; 0?
type: Question
has answer: http://stackoverflow.com/a/2764779
accepted answer: http://stackoverflow.com/a/2764779
answer count: 2
upvote count: 1
downvote count: 0
has answer: http://stackoverflow.com/a/2764819
favorite count: 0

http://stackoverflow.com/comment/121656567
has text: instantiate an annotation with method references: https://stackoverflow.com/a/68837852/2158288
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/2786292
score: 0

unix
tags question: http://stackoverflow.com/q/2773266
tags question: http://stackoverflow.com/q/2729038
type: Tag
tags question: http://stackoverflow.com/q/2630775
tags question: http://stackoverflow.com/q/2707793
tags question: http://stackoverflow.com/q/2668796
tag name: unix

http://stackoverflow.com/a/6399269
type: Answer
upvote count: 35
downvote count: 0
answers question: http://stackoverflow.com/q/2744511
has comment: http://stackoverflow.com/comment/7520472
has comment: http://stackoverflow.com/comment/12920477
has comment: http://stackoverflow.com/comment/12920585
score: 35
has body: One interesting aspect about this question is the fact that the Java language forbids overloading methods only by return type. But not the JVM: Note that there may be more than one matching method in a class because while the Java language forbids a class to declare multiple methods with the same signature but different return types, the Java virtual machine does not. This increased flexibility in the virtual machine can be used to implement various language features. For example, covariant returns can be implemented with bridge methods; the bridge method and the method being overridden would have the same signature but different return types. From: Class.getMethod(String, Class...)

http://stackoverflow.com/q/2661343
has body: I have a JCheckBox that should not be checked by the user when a certain other field is empty. So now I want to have an error popup and then reset the checkbox (I've considered disabling the checkbox, but the connection to the other field is non-obvious, and a tooltip text IMO not visible enough). What's the correct way to do that in Swing? Through a PropertyVetoException? Where do I throw it and where do I catch it? My first (probably ugly) idea would be to add a ChangeListener that itself shows the popup and resets the value. Edit: The question is about Nikki (screenshot below), an app I am developing which geotags images and exports them to Google Earth's KMZ format. The checkbox is used to select the images to include in the export. But this requires the images to be gotagged first (which in turn requires either a timestamp, or manual assignment). I don't think this requirement can be made obvious through the UI layout. (source: brazzy.de)
upvote count: 5
has answer: http://stackoverflow.com/a/2661383
has comment: http://stackoverflow.com/comment/2678626
answer count: 3
tagged with: user-interface
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2661352
type: UnansweredQuestion
tagged with: swing
has comment: http://stackoverflow.com/comment/2678781
tagged with: java
type: Question
has title: Best way to implement refusing a value change by the user in Swing?
has answer: http://stackoverflow.com/a/2662945
score: 5

http://stackoverflow.com/a/2638970
answers question: http://stackoverflow.com/q/2638711
has body: DOH! I figured it out. I was missing two things: Property change support is necessary, I forgot to add these lines to the bean with property change support: public void addPropertyChangeListener(PropertyChangeListener pcl) { this.pcs.addPropertyChangeListener(pcl); } public void removePropertyChangeListener(PropertyChangeListener pcl) { this.pcs.removePropertyChangeListener(pcl); } The BeanAdapter constructor takes a second argument to ensure it is getting change events from the bean in question: final BeanAdapter&lt;NumberBean&gt; pNumber = new BeanAdapter&lt;NumberBean&gt;((NumberBean)null, true);
upvote count: 2
type: AcceptedAnswer
type: Answer
score: 2
accepted answer of: http://stackoverflow.com/q/2638711
downvote count: 0

http://stackoverflow.com/comment/2648881
comment on: http://stackoverflow.com/a/2633954
type: AnswerComment
type: Comment
score: 1
has text: @ig0774 So, if I add a finally block like `finally { in.close(); }`, then the associated overhead takes effect? From what I understand of the spec, the finally clause simply adds an extra instruction to the compiled try block to call the finally block as a subroutine before returning normally.

http://stackoverflow.com/a/2772871
answers question: http://stackoverflow.com/q/2772763
upvote count: 2
has body: There is a very important difference between the two. "==" compares object instances. The default equals() implementation does this, also. Please run &amp; analyse the following code sample: public class Person{ String name; public Person(String name){ this.name = name; } //overriding equals public boolean equals( Object obj ) { if( this == obj ) return true; if( obj == null ) return false; if( getClass() != obj.getClass() ) return false; Person other = (Person) obj; if( name == null ) { if( other.name != null ) return false; } else if( !name.equals( other.name ) ) return false; return true; } } ... ... Person john1 = new Person("John"); Person john2 = new Person("John"); System.out.println("john1 == john2:" + (john1 == john2)); System.out.println("john1.equals(john2):" + john1.equals(john2)); As you can see, "==" will return false (the objects are two different instances of Person), whereas equals will return true (because we defined that 2 Persons are equal when they have the same name)
type: Answer
score: 2
downvote count: 0

http://stackoverflow.com/comment/139114666
score: 0
has text: `drainTo(List<Byte>)` worked for me like a charm. `take()` was waaaaaaaay too slow, having to wait 15 seconds to save 1 minute audio, while `drainTo` is instant, even for a 10 minute audio. Actually, the Android Studio doc says about `drainTo`: _This operation may be more efficient than repeatedly polling this queue_. You bet! Thanks!!
type: Comment
comment on: http://stackoverflow.com/a/2645201
type: AnswerComment

http://stackoverflow.com/comment/2714456
comment on: http://stackoverflow.com/a/2692865
type: AnswerComment
has text: The list of files is in `lib\classlist`.
score: 0
type: Comment

http://stackoverflow.com/q/2699181
favorite count: 0
has answer: http://stackoverflow.com/a/2699379
answer count: 4
tagged with: maven-2
tagged with: unit-testing
has answer: http://stackoverflow.com/a/2699628
has answer: http://stackoverflow.com/a/3493174
type: Question
tagged with: spring-mvc
type: AnsweredQuestion
has body: I am trying to unit test a webapp that I am developing in Maven/Eclipse. It is a Spring MVC webapp, and I need some unit tests to test my model controller. To do this, I need to use my webapp config .xml files to inject the controller, however, all my configuration (and other associated files that the configs reference) are in the src/main/webapp directory (as per Maven convention) - there are a lot of files in here that i need to reference in my tests, but they are not available when running the test as they are not on the classpath (Maven only seems to be adding src/main/java, src/test/java, src/main/resources, src/test/resources to the classpath but not src/main/webapps) I do not want to have to copy my entire webapp in to my src/test/resources folder just for the purpose of testing - is there any other way to be able to access them? I can get around this by changing the Eclipse "Run Configurations" to include this folder on the classpath, but that will not work when running the tests from the command line? Has anyone else encountered this? is there a know solution? Thanks!
tagged with: java
possible better answer: http://stackoverflow.com/a/13064579
has answer: http://stackoverflow.com/a/13064579
score: 12
has title: Unit Test in Maven requires access to the src/main/webapp Directory
upvote count: 12
downvote count: 0
accepted answer: http://stackoverflow.com/a/2699628

http://stackoverflow.com/a/2766897
upvote count: 2
has comment: http://stackoverflow.com/comment/2799513
has comment: http://stackoverflow.com/comment/2799726
has body: You're not comparing two Persons, you're comparing two ssids. I would use: myPerson.getSsid().equals(mySsid);
downvote count: 0
has comment: http://stackoverflow.com/comment/2799546
has comment: http://stackoverflow.com/comment/2799548
type: Answer
answers question: http://stackoverflow.com/q/2766855
score: 2

http://stackoverflow.com/a/2633221
answers question: http://stackoverflow.com/q/2633185
type: Answer
has body: Hand written assembly ;-) But for maintainability I would go with either .NET, or a native exe written in delphi/c++ with manual windows API calls.
score: 0

http://stackoverflow.com/a/2780224
upvote count: 1
score: 1
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2780192
accepted answer of: http://stackoverflow.com/q/2780192
type: Answer
has body: Expose them as standards Web Services or RESTful web-services

http://stackoverflow.com/comment/2792710
comment on: http://stackoverflow.com/a/2760752
type: AnswerComment
has text: Hmm does it work hand in hand with another InputMap as I have one that is used for UndoAction and RedoAction (taken from Sun's example)? If you don't add the same key and action to both it should be fine right?
score: 0
type: Comment

http://stackoverflow.com/q/2749378
favorite count: 0
linked to: http://stackoverflow.com/q/7510874
type: UnansweredQuestion
tagged with: web-services
has title: When to use @Singleton in a Jersey resource
linked to: http://stackoverflow.com/q/7121445
has answer: http://stackoverflow.com/a/39552448
tagged with: java
upvote count: 10
type: Question
tagged with: jersey
has comment: http://stackoverflow.com/comment/2779430
score: 10
tagged with: database
has answer: http://stackoverflow.com/a/2877840
has body: I have a Jersey resource that access the database. Basically it opens a database connection in the initialization of the resource. Performs queries on the resource's methods. I have observed that when I do not use @Singleton, the database is being open at each request. And we know opening a connection is really expensive right? So my question is, should I specify that the resource be singleton or is it really better to keep it at per request especially when the resource is connecting to the database? My resource code looks like this: //Use @Singleton here or not? @Path(/myservice/) public class MyResource { private ResponseGenerator responser; private Log logger = LogFactory.getLog(MyResource.class); public MyResource() { responser = new ResponseGenerator(); } @GET @Path("/clients") public String getClients() { logger.info("GETTING LIST OF CLIENTS"); return responser.returnClients(); } ... // some more methods ... } And I connect to the database using a code similar to this: public class ResponseGenerator { private Connection conn; private PreparedStatement prepStmt; private ResultSet rs; public ResponseGenerator(){ Class.forName("org.h2.Driver"); conn = DriverManager.getConnection("jdbc:h2:testdb"); } public String returnClients(){ String result; try{ prepStmt = conn.prepareStatement("SELECT * FROM hosts"); rs = prepStmt.executeQuery(); ... //do some processing here ... } catch (SQLException se){ logger.warn("Some message"); } finally { rs.close(); prepStmt.close(); // should I also close the connection here (in every method) if I stick to per request // and add getting of connection at the start of every method // conn.close(); } return result } ... // some more methods ... } Some comments on best practices for the code will also be helpful.
answer count: 2
downvote count: 0

http://stackoverflow.com/q/2728283
has comment: http://stackoverflow.com/comment/8251111
upvote count: 11
has body: I wrote my Java application in Eclipse. Now I would like to generate a .jar file which can be run on other systems from the command line. Is there a easy way to do it in Eclipse? In particular I am wondering what should I do with the jar files of external library that I use (should it be included into my .jar file?). Moreover, should I generate some manifest files? ADDED: I see the window in which I can choose "Extract required libraries into generated JAR" or "Package required libraries into generated JAR" and so on. I select the first option, I specify export destination but "Next" button is not activated yet. What else should I specify. I am offered to launch a configuration but i do not want to. Every configuration is associated with a fixed set of parameters given in the command line and I do not want that.
has answer: http://stackoverflow.com/a/2728293
type: UnansweredQuestion
score: 11
type: Question
has answer: http://stackoverflow.com/a/4042705
has title: How can I create a self-consistent .jar file with Eclipse?
tagged with: java
tagged with: eclipse
answer count: 2
tagged with: jar
downvote count: 0
favorite count: 0

http://stackoverflow.com/a/2765251
has body: In most programming languages classes elude a lot of the type system. While a class, with its static methods and variables is an object, it very often cannot implement an interface or extend other classes. For that reason, it cannot be used in a polymorphic manner, since it cannot be the subtype of another type. For example, if you have an interface IFooable, that is required by several method signatures of other classes, the class object StaticFoo cannot be used in place of IFooable, whereas FooSingleton.getInstance() can (assuming, FooSingleton implements IFooable). Please note, that, as I commented on Heinzi's answer, a singleton is a pattern to control instantiation. It replaces new Class() with Class.getInstance(), which gives the author of Class more control over instances, which he can use to prevent the creation of unneccessary instances. The singleton is just a very special case of the factory pattern and should be treated as such. Common use makes it rather the special case of global registries, which often ends up bad, because global registries should not be used just willy-nilly. If you plan to provide global helper functions, then static methods will work just fine. The class will not act as class, but rather just as a namespace. I suggest, you preserve high cohesion, or you might end up with weirdest coupling issues. greetz back2dos
score: 7
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2765060
upvote count: 7

http://stackoverflow.com/comment/134661674
comment on: http://stackoverflow.com/a/41447549
type: AnswerComment
has text: Constant can't be part of a contract. Contracts are _performed_, i.e., implemented. Only methods can do that. Constants just exist. "users can only guess what your validating with" -- No, you're supposed to specify what the method will accept, whether or not it involves constants, and putting constants into an interface doesn't make them contractually required. Plus, putting constants properly in a final class doesn't prevent referencing them in your interfaces, implementations, Javadoc, or other docs.
score: 0
type: Comment

http://stackoverflow.com/q/2608068
tagged with: java
possible better answer: http://stackoverflow.com/a/2612258
has body: I get a communication link failure while application tries to establish a connection with DB. [#|2010-04-08T20:09:57.825+0300|SEVERE|glassfish3.0|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=24;_ThreadName=Thread-1;|Cannot connect to database server = com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.|#] Precisely at this string: Statement s = conn.createStatement(); where conn is defined as follows: private static java.sql.Connection conn; For this app I have set a connection pool with default parameters and currently it (app) uses both JPA and direct JDBC queries. Recreation of connection pool gave nothing, connection pool ping gave next message: Ping Connection Pool for pool is Failed. Ping failed Exce ption - Connection could not be allocated because: Communications lin k failure%%%EOL%%%%%%EOL%%%The last packet sent successfully to the s erver was 0 milliseconds ago. The driver has not received any packets from the server. Please check the server.log for more details.%%%EOL %%%Ping failed Exception - Connection could not be allocated because: Communications link failure and flushing the connection pool gave: com.sun.enterprise.admin.cli.CommandException: remote failure: Failed to flush connection pool ... However I can connect to the database from a terminal. Besides I have the same app working on my local machine with identical connection pool settings. Any one has an idea on whats going on or how to solve the trouble?
tagged with: mysql
has title: (Enterprise GlassFish v3 build 11) Communication link problem (MySQL DB)
has answer: http://stackoverflow.com/a/2612258
accepted answer: http://stackoverflow.com/a/2613216
type: Question
has comment: http://stackoverflow.com/comment/2863650
tagged with: glassfish
answer count: 3
tagged with: java-ee-6
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2613216
upvote count: 2
has answer: http://stackoverflow.com/a/50931754
score: 2
type: AnsweredQuestion
tagged with: connection-pooling

http://stackoverflow.com/comment/36558975
type: AnswerComment
type: Comment
has text: @JonHarrop: You lost me there. What do hardware cache lines have to do with GC?
comment on: http://stackoverflow.com/a/2620540
score: 0

http://stackoverflow.com/comment/2730907
comment on: http://stackoverflow.com/a/2697825
score: 0
type: Comment
has text: And i cannot use f:selectItems because inside it i can't put a <h:graphicImage> tag. If i am still not clear please let me know.
type: AnswerComment

http://stackoverflow.com/a/2632051
type: Answer
has body: So, you want to be able to associate multiple values with one key? If so, then just use either a Map&lt;K, Collection&lt;V&gt;&gt;, or Google Collections MultiMap&lt;K, V&gt;
upvote count: 1
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/2632003

code-injection
tags question: http://stackoverflow.com/q/2720948
tag name: code-injection
tags question: http://stackoverflow.com/q/2598423
tags question: http://stackoverflow.com/q/2763279
tags question: http://stackoverflow.com/q/2620739
type: Tag
tags question: http://stackoverflow.com/q/2644292

http://stackoverflow.com/comment/2633129
type: AnswerComment
has text: yeah thats true while deploying it ..i can't even see the messeges while i am running the application on my own pc using sdk.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2620818

http://stackoverflow.com/comment/2788726
comment on: http://stackoverflow.com/q/2757066
score: 0
type: Comment
type: QuestionComment
has text: I found an unexpected deadlock, but I had to "guess" that might be the case from the set of inexplicably stalled processes. There ought to be a better way.

http://stackoverflow.com/comment/39300738
has text: Where do I import LinkedTreeMap from? I can't find it in the Gson code.
comment on: http://stackoverflow.com/a/20537796
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2803022
type: Comment
has text: Use `import static com.example.*;`. Also see [Sun Tutorial](http://java.sun.com/docs/books/tutorial/java/package/usepkgs.html#staticimport). I updated my answer accordingly.
score: 0
comment on: http://stackoverflow.com/a/2768994
type: AnswerComment

http://stackoverflow.com/comment/2740237
type: QuestionComment
score: 0
has text: Your question is not very clear to me. What are the error messages you are getting?
comment on: http://stackoverflow.com/q/2715032
type: Comment

http://stackoverflow.com/a/2678235
score: 3
upvote count: 3
has comment: http://stackoverflow.com/comment/2698045
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2697904
accepted answer of: http://stackoverflow.com/q/2678207
has comment: http://stackoverflow.com/comment/2697702
has body: It "fires" whenever the phase changes. You can make your code in the phase listener be triggered only on certain phases, by adding a condition comparing event.getPhaseId() with PhaseId.RESTORE_VIEW, for example.
answers question: http://stackoverflow.com/q/2678207
type: Answer
has comment: http://stackoverflow.com/comment/2697933

http://stackoverflow.com/comment/2664310
has text: Is that something that could be hosted externally to a particular webapp? i.e. would the listeners .jar be stored outside of the scope of a web app, so other web apps could use it?
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2648494
type: Comment

http://stackoverflow.com/q/2704103
tagged with: jakarta-mail
has answer: http://stackoverflow.com/a/2704304
downvote count: 0
answer count: 1
tagged with: jsp
favorite count: 0
tagged with: file-upload
type: UnansweredQuestion
upvote count: 1
type: Question
has body: I am using Apache commons File upload API to Store the file from JSP to servlets in temp directory, but I don't know what should I do next to send the email as an attachment using javamail API. How can I retrieve those files which is written in temp directory using Apache Fileupload API to send them as attachment to mail Server. How will writing those files either to memory or disk will help me?
score: 1
tagged with: java
has title: How to enable attachment using Apache File upload
tagged with: servlets

http://stackoverflow.com/comment/37616622
score: 2
type: AnswerComment
comment on: http://stackoverflow.com/a/6131369
type: Comment
has text: I agree, but in this case there are caveats, like that you wouldn't be able to provide file and line number anymore, unless you implemented yet another workaround for that. In this case I would have stuck with log4j, until the framework supported the feature - which eventually happened through an extension, see Robert Elliot's more recent answer.

http://stackoverflow.com/comment/3123052
type: AnswerComment
has text: That are interesting points, thank you. But still I think it is a good foundation to know that there is always a fallback solution back to Java while you are learning Groovy.
type: Comment
comment on: http://stackoverflow.com/a/2616501
score: 0

http://stackoverflow.com/a/2710319
type: Answer
has comment: http://stackoverflow.com/comment/2735548
score: 14
has comment: http://stackoverflow.com/comment/24464418
downvote count: 0
answers question: http://stackoverflow.com/q/2710300
has comment: http://stackoverflow.com/comment/2735634
has body: You can do all sorts of interesting things with case fall-through. For example, lets say you want to do a particular action for all cases, but in a certain case you want to do that action plus something else. Using a switch statement with fall-through would make it quite easy. switch (someValue) { case extendedActionValue: // do extended action here, falls through to normal action case normalActionValue: case otherNormalActionValue: // do normal action here break; } Of course, it is easy to forget the break statement at the end of a case and cause unexpected behavior. Good compilers will warn you when you omit the break statement.
upvote count: 14

http://stackoverflow.com/q/2635292
has answer: http://stackoverflow.com/a/48279973
has answer: http://stackoverflow.com/a/62384232
accepted answer: http://stackoverflow.com/a/2635361
favorite count: 0
tagged with: binary-tree
has answer: http://stackoverflow.com/a/35214423
tagged with: recursion
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2635333
upvote count: 3
has title: How do I remove the leaves of a binary tree?
tagged with: java
has answer: http://stackoverflow.com/a/2635325
type: Question
has answer: http://stackoverflow.com/a/27799753
answer count: 8
tagged with: algorithm
has answer: http://stackoverflow.com/a/2635318
has body: I'm trying to remove all of the leaves. I know that leaves have no children, this is what I have so far. public void removeLeaves(BinaryTree n){ if (n.left == null &amp;&amp; n.right == null){ n = null; } if (n.left != null) removeLeaves(n.left); if (n.right != null) removeLeaves(n.right); }
possible better answer: http://stackoverflow.com/a/2635325
tagged with: data-structures
has answer: http://stackoverflow.com/a/2635361
score: 3
downvote count: 0

http://stackoverflow.com/a/10541987
score: 1
upvote count: 1
has body: The process I followed is Close eclipse Explore to the folder Delete it
answers question: http://stackoverflow.com/q/2660961
downvote count: 0
type: Answer

http://stackoverflow.com/q/2771623
has answer: http://stackoverflow.com/a/2788232
tagged with: http://stackoverflow.com/tag/pdf
tagged with: xhtmlrenderer
downvote count: 0
answer count: 1
favorite count: 0
has title: xhtmlrenderer xhtml to pdf font problem
accepted answer: http://stackoverflow.com/a/2788232
tagged with: http://stackoverflow.com/tag/html
type: AnsweredQuestion
tagged with: fonts
upvote count: 3
tagged with: java
type: Question
score: 3
has body: I'm using org.xhtmlrenderer.pdf.ITextRenderer to convert my (x)html page to pdf using Java. I've got most of it working, except the font part. I'm using verdana in my page and the pdf is rendered using default font. I have added the verdana.ttf to my jar and use the following code: DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc = builder.parse(new StringBufferInputStream(html)); File tmpFontFile = new File(TEMP_FOLDER + "/verdana.ttf"); if(!tmpFontFile.exists()) { tmpFontFile.createNewFile(); InputStream fontIs = getClass().getResourceAsStream("/com/mycompany/util/font/verdana.ttf"); OutputStream fontOs = new FileOutputStream(tmpFontFile); byte buf[] = new byte[1024]; int len; while((len = fontIs.read(buf)) &gt; 0) fontOs.write(buf,0,len); fontOs.close(); fontIs.close(); } ITextRenderer renderer = new ITextRenderer(); renderer.getFontResolver().addFont( tmpFontFile.getAbsolutePath(), BaseFont.IDENTITY_H ,BaseFont.EMBEDDED); renderer.setDocument(doc, null); String outputFile = TEMP_FOLDER + "/mypdf.pdf"; OutputStream os = new FileOutputStream(outputFile); renderer.layout(); renderer.createPDF(os); os.close(); What am I missing here? Thanks, Bart

http://stackoverflow.com/a/2758646
answers question: http://stackoverflow.com/q/2758468
type: Answer
score: 6
upvote count: 6
has body: I'm pretty sure IUnknown and IDispatch existed before Java... But that's COM, which isn't really a language.
downvote count: 0

http://stackoverflow.com/a/28306286
downvote count: 0
has body: If there are only two references to test and you are using Java 8, you could use Object o = null; Object p = "p"; Object r = Optional.ofNullable( o ).orElse( p ); System.out.println( r ); // p If you import static Optional the expression is not too bad. Unfortunately your case with "several variables" is not possible with an Optional-method. Instead you could use: Object o = null; Object p = null; Object q = "p"; Optional&lt;Object&gt; r = Stream.of( o, p, q ).filter( Objects::nonNull ).findFirst(); System.out.println( r.orElse(null) ); // p
has comment: http://stackoverflow.com/comment/119100557
type: Answer
upvote count: 73
answers question: http://stackoverflow.com/q/2768054
score: 73

http://stackoverflow.com/comment/2737938
has text: It works fine on my FTP server, except that I don't call client.configure(...)
type: Comment
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/2712967

http://stackoverflow.com/comment/110439147
comment on: http://stackoverflow.com/q/2758224
has text: Assertions are disabled by default because prior to Java 1.4 it was perfectly legal to use the word “assert” for naming variables, methods, etc. This potentially creates a naming clash when using an older code with newer JVM versions. Therefore, for backward compatibility, the JVM disables assertion validation by default.
type: Comment
type: QuestionComment
score: 2

http://stackoverflow.com/comment/42914673
has text: Hi guys! What if i want to keep + in the string and remove all other characters?
type: Comment
score: 1
comment on: http://stackoverflow.com/a/2717431
type: AnswerComment

http://stackoverflow.com/comment/2644436
type: Comment
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/2623694
has text: Additional thought: While I have already expressed agreement with those who say that such a thing should be carefully documented, it occurs to me that this is probably less of a problem than I at first thought: If someone is using an iterator -- or any other construct -- without knowing what it is supposed to return, he's in for trouble no matter what!

http://stackoverflow.com/comment/2819900
score: 42
type: AnswerComment
comment on: http://stackoverflow.com/a/2784576
type: Comment
has text: +1 for mentioning that it should return `int` and that you'd better to use `Date#compareTo()` for this. Why this isn't upvoted above the other answer is beyond me. This link may also be useful: [Object Ordering Tutorial at Sun.com](http://java.sun.com/docs/books/tutorial/collections/interfaces/order.html).

http://stackoverflow.com/comment/58527956
type: AnswerComment
comment on: http://stackoverflow.com/a/16883281
has text: how can we revert back to default. I am doing something like this: http://pastebin.com/qJqbEBqE
type: Comment
score: 0

http://stackoverflow.com/q/2625031
score: 2
upvote count: 2
type: Question
possible better answer: http://stackoverflow.com/a/2625049
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2625055
has answer: http://stackoverflow.com/a/2625049
tagged with: java
has answer: http://stackoverflow.com/a/2625231
tagged with: this
downvote count: 0
has title: Java: static-non-static-this problem
favorite count: 0
tagged with: static
has answer: http://stackoverflow.com/a/2625073
has body: $ javac TestFilter.java TestFilter.java:19: non-static variable this cannot be referenced from a static context for(File f : file.listFiles(this.filterFiles)){ ^ 1 error $ sed -i 's@this@TestFilter@g' TestFilter.java $ javac TestFilter.java $ java TestFilter file1 file2 file3 TestFilter.java import java.io.*; import java.util.*; public class TestFilter { private static final FileFilter filterFiles; // STATIC! static{ filterFiles = new FileFilter() { // Not Static below. When static, an error: // "accept(java.io.File) in cannot implement // accept(java.io.File) in java.io.FileFilter; // overriding method is static" // // I tried to solve by the change the problem at the bottom. public boolean accept(File file) { return file.isFile(); } }; } // STATIC! public static void main(String[] args){ HashSet&lt;File&gt; files = new HashSet&lt;File&gt;(); File file = new File("."); // IT DID NOT WORK WITH "This" but with "TestFilter". // Why do I get the error with "This" but not with "TestFilter"? for(File f : file.listFiles(TestFilter.filterFiles)){ System.out.println(f.getName()); files.add(f); } } } Update: define "current object" Constructor created, object created but the this does not refer to the current object "test". It works when I change this to "test" but it does not work with "this". Why? $ javac TestFilter.java TestFilter.java:28: non-static variable this cannot be referenced from a static context for(File f : this.getFiles()){ ^ 1 error $ cat TestFilter.java import java.io.*; import java.util.*; public class TestFilter { private static final FileFilter filterFiles; private HashSet&lt;File&gt; files; static{ filterFiles = new FileFilter() { public boolean accept(File file) { return file.isFile(); } }; } TestFilter(){ files = new HashSet&lt;File&gt;(); File file = new File("."); for(File f : file.listFiles(filterFiles)){ files.add(f); } } public static void main(String[] args){ // CONSTRUCTOR with no pars invoked and object "test" created here! TestFilter test = n…
accepted answer: http://stackoverflow.com/a/2625231
answer count: 5
tagged with: non-static
has comment: http://stackoverflow.com/comment/2638130
has answer: http://stackoverflow.com/a/2625324

http://stackoverflow.com/a/2869948
score: 6
accepted answer of: http://stackoverflow.com/q/2784791
has comment: http://stackoverflow.com/comment/62346062
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2924273
type: Answer
answers question: http://stackoverflow.com/q/2784791
upvote count: 6
has body: You have to ensure that the version number of the class is at least 49 (see the visitLdcInsn on this ASM Javadoc page).
has comment: http://stackoverflow.com/comment/62277173

http://stackoverflow.com/a/2658046
has body: What happens when an exception is thrown while creating the BufferedReader object? The stream managed by the InputStreamReader object is not closed until some time in the future when the garbage collector decides to destroy the object. You will likely have similar problems if an exception is thrown while creating the InputStreamReader object.
score: 5
type: Answer
answers question: http://stackoverflow.com/q/2658022
upvote count: 5
has comment: http://stackoverflow.com/comment/2675766
downvote count: 0

http://stackoverflow.com/comment/2618907
type: AnswerComment
score: 0
type: Comment
has text: @Wiz: That was also one of the reasons I wrote another one myself to clarify the one and other more, even in simple terms and with practical examples and solutions. But.. It are really not that *much* errors in Joel's article as you seem to insinuate?
comment on: http://stackoverflow.com/a/2608252

http://stackoverflow.com/a/2646047
upvote count: 1
has body: private static String to2DigitsHex(byte[] bs) { String s = new BigInteger(bs).toString(16); return s.length()%2==0? s : "0"+s; }
answers question: http://stackoverflow.com/q/2645974
downvote count: 0
type: Answer
score: 1

http://stackoverflow.com/q/2690198
favorite count: 0
has title: Servlets: forwarding to a resource in a different webapp
has answer: http://stackoverflow.com/a/2690226
type: AnsweredQuestion
upvote count: 3
tagged with: java
type: Question
score: 3
accepted answer: http://stackoverflow.com/a/2690226
has body: I'm trying to construct a java web app along modular principles, with some common resources (JSPs, mainly) in one WAR, and some custom resources in another. This means JSPs scattered across different WARs. Now JavaEE frowns upon this sort of shenanigans, and wants you to put everything in one place. My current workaround to this is to have an Eclipse-triggered Ant script which copies the content of one WAR into the other, but this is not a pleasant solution (it's fragile and too IDE-dependent). Ideally, what I'd like to be able to do is for a servlet to forward to a JSP located in a different WAR to one in which it is itself deployed. This would allow greater freedom in how I assemble my WARs. However, the RequestDispatcher does not seem to support such things. Another possibility is to use &lt;c:import&gt;, which does allow resources to be imported from a different WAR (with some caveats). This would probably allow me to have a "hook" JSP in one WAR, which then drags in the required JSP from another. This is a bit clunky, though, and the fact that &lt;c:import&gt; permits it shows that the underlying servlet API does also. But how do I access that functionality via the RequestDispatcher in a servlet?
tagged with: servlets
answer count: 1
downvote count: 0

http://stackoverflow.com/comment/2642198
score: 3
type: AnswerComment
comment on: http://stackoverflow.com/a/2624237
type: Comment
has text: @Derek I am not advocating the rethrow of a RuntimeException. I merely provided that as an example of how one could "simulate" an IOException as being unchecked if for some reason that is desired behavior (which I can't think of a reasonable example where it would be). Similarly for using System.exit as an alternative for failed recovery (perhaps I should have also included the sarcastic "//OH NO!!!!!" for the RuntimeException example). In any case I believe the proper strategy is to catch, attempt to recover if possible, and then rethrow, or return an appropriate value from the method.

http://stackoverflow.com/comment/113473191
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2686268
type: AnswerComment
has text: @Kdeveloper, I tried using the same code but my application listener for failed events is not getting invoked. I just did not add the listener for successful events. Can you please help me?

http://stackoverflow.com/q/2607786
has answer: http://stackoverflow.com/a/2612859
has body: I'm developing a utility class to handle Actions from Java Swing components; I would like to know if there is a way of checking if a given method name (that will be accessed by reflections) exists in compile time, and show a compiler error if not? --update Ok, looks like I was not clear, lets talk about the details: I have a class called TomAction that I use to simplify simple actions declarations in my project. Instead of write something like: class MyClass { public MyClass() { Icon icon = null; // putting null to simplify the example JButton btn = new JButton(new AbstractAction("Click to go!", icon) { public void actionPerformed(ActionEvent ev) { try { go(); } catch (Exception e) { e.printStackTrace(); String msg = "Fail to execute 'go' task."; JOptionPane.showMessageDialog(null, msg, "Fail", JOptionPane.ERROR_MESSAGE); } } }); } private void go() { // do task } } ..I just write: class MyClass { public MyClass() { String msg = "Fail to execute 'go' task."; Icon icon = null; // putting null to simplify the example TomAction act = new TomAction("go", this, "Click to go!", msg, icon); JButton btn = new JButton(act); } private void go() { // do task } } ..and the program have the same behaviour. The problem is that if I type a wrong method name as argument to TomAction, I will see it just in runtime. I would like to see it in compile time. Got it? :) By the way, this class is working very fine, I just want to do this enhancement. --update studing the Annotations approach
has comment: http://stackoverflow.com/comment/2633100
upvote count: 5
tagged with: java
has answer: http://stackoverflow.com/a/2607806
has comment: http://stackoverflow.com/comment/2618045
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/2607834
has answer: http://stackoverflow.com/a/2607972
has comment: http://stackoverflow.com/comment/2631300
favorite count: 0
has answer: http://stackoverflow.com/a/2607996
has comment: http://stackoverflow.com/comment/2622805
type: Question
has comment: http://stackoverflow.com/comment/2624215
answer count: 8
possible better answer: http://stackoverflow.com/a/2607815
score: 5
has answer: http://stackoverflow.com/a/2607815
tagged with: reflection
has answer: http://stackoverflow.com/a/2613685
has comment: http://stackoverflow.com/comment/6124127
has title: Java: Check if a given method name exist in compile time
accepted answer: http://stackoverflow.com/a/2607972
has answer: http://stackoverflow.com/a/2619265

http://stackoverflow.com/q/2738021
has body: I know recently Spring 3.0 was released which brought about a nice new set of features and ease of web development with their MVC package. However are there any new frameworks on the horizon and/or new versions of other frameworks that a web developer should have their eyes on? I heard about the Stripes framework, but it seems as though development has stopped. It also seems grails has a new release coming out as well which that looks like it is just an update to support the new features in the latest groovy release.
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2738512
has answer: http://stackoverflow.com/a/2738512
has answer: http://stackoverflow.com/a/2738654
accepted answer: http://stackoverflow.com/a/2738043
type: Question
tagged with: java
has title: Are there any new/updated Java web development frameworks to watch for?
answer count: 6
upvote count: 4
downvote count: 0
has answer: http://stackoverflow.com/a/2738152
score: 4
has answer: http://stackoverflow.com/a/2738043
favorite count: 0
has answer: http://stackoverflow.com/a/2757849
has answer: http://stackoverflow.com/a/2738585

http://stackoverflow.com/comment/2765439
score: 0
type: AnswerComment
has text: @kgiannakakis Tomcat can be integrated with Eclipse IDE by the exe installation as well!
type: Comment
comment on: http://stackoverflow.com/a/2735559

http://stackoverflow.com/a/2764474
type: Answer
answers question: http://stackoverflow.com/q/2764054
downvote count: 0
has body: One of the most common pitfalls is the infamous n+1 selects problem. By default, Hibernate doesn't load data you didn't ask for. This reduces memory consumptions but exposes you to the n+1 selects problem which can be avoided by switching to the right fetching strategy to retrieve all the data you need to load objects in their appropriately initialized state. But also don't fetch too much or you'll run into the opposite problem, the cartesian product issue: instead of executing to many SQL statements, you may end up creating statements that retrieve too much data. That's the whole point of the tuning: finding the middle between not enough and too much data for each use case of your application (or at least, for the one that require to be tuned). My recommendations: first activate SQL logging at Hibernate's level run the critical use cases (the 20% used 80% of the time) or even all of them if you have that luxury identify suspicious queries and optimize the fetch plan, check if indices are used appropriately, etc involve your DBA
score: 18
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/39187693
has comment: http://stackoverflow.com/comment/2815410
accepted answer of: http://stackoverflow.com/q/2764054
upvote count: 18

http://stackoverflow.com/comment/2693274
score: 0
type: Comment
has text: actually that doesn't really answer my question whether it makes sense to use an additional layer between my OO app and the db in order not to have to re-implement too much. :)
type: AnswerComment
comment on: http://stackoverflow.com/a/2674381

http://stackoverflow.com/comment/99180621
has text: This solution also doen't take into account is* getters unlike bean Introspector in the accepted answer.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/20330416
type: Comment

http://stackoverflow.com/comment/2682591
type: Comment
type: QuestionComment
score: 1
has text: Please take a look at the editing help http://stackoverflow.com/editing-help so that you can format your questions a little better.
comment on: http://stackoverflow.com/q/2664633

http://stackoverflow.com/comment/2731464
score: 0
has text: oh BTW.. thank you for the formatting!
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/2707531

http://stackoverflow.com/comment/2624494
has text: I thought Apache was like MIT, no?
type: AnswerComment
comment on: http://stackoverflow.com/a/2613477
type: Comment
score: 0

http://stackoverflow.com/comment/2746775
type: Comment
has text: Can you connect to the server via another mysql client such as the mysql query browser? How about with another user?
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/2720716

http://stackoverflow.com/comment/2678993
score: 0
type: Comment
has text: Does deleting Table_B directly delete the members in Table_C, or is this only an issue when you set the Table_B link to null in Table_A?
type: QuestionComment
comment on: http://stackoverflow.com/q/2661579

http://stackoverflow.com/comment/14441980
type: Comment
has text: This will not work. Different strings can have the same hashcode and the `==` operator compares object references. So it will never be true with two `new` instances. The correct answer is to use `equals`.
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/11036803

http://stackoverflow.com/q/2759199
has answer: http://stackoverflow.com/a/6724943
has comment: http://stackoverflow.com/comment/2790978
tagged with: java
has answer: http://stackoverflow.com/a/2759252
has comment: http://stackoverflow.com/comment/2791725
accepted answer: http://stackoverflow.com/a/2759291
has comment: http://stackoverflow.com/comment/2794202
has answer: http://stackoverflow.com/a/2759284
has comment: http://stackoverflow.com/comment/2791308
upvote count: 27
tagged with: assert
has comment: http://stackoverflow.com/comment/2790969
has answer: http://stackoverflow.com/a/2759291
possible better answer: http://stackoverflow.com/a/2759264
favorite count: 0
has answer: http://stackoverflow.com/a/2759279
has answer: http://stackoverflow.com/a/2759835
has body: While poking around the questions, I recently discovered the assert keyword in Java. At first, I was excited. Something useful I didn't already know! A more efficient way for me to check the validity of input parameters! Yay learning! But then I took a closer look, and my enthusiasm was not so much "tempered" as "snuffed-out completely" by one simple fact: you can turn assertions off.* This sounds like a nightmare. If I'm asserting that I don't want the code to keep going if the input listOfStuff is null, why on earth would I want that assertion ignored? It sounds like if I'm debugging a piece of production code and suspect that listOfStuff may have been erroneously passed a null but don't see any logfile evidence of that assertion being triggered, I can't trust that listOfStuff actually got sent a valid value; I also have to account for the possibility that assertions may have been turned off entirely. And this assumes that I'm the one debugging the code. Somebody unfamiliar with assertions might see that and assume (quite reasonably) that if the assertion message doesn't appear in the log, listOfStuff couldn't be the problem. If your first encounter with assert was in the wild, would it even occur to you that it could be turned-off entirely? It's not like there's a command-line option that lets you disable try/catch blocks, after all. All of which brings me to my question (and this is a question, not an excuse for a rant! I promise!): What am I missing? Is there some nuance that renders Java's implementation of assert far more useful than I'm giving it credit for? Is the ability to enable/disable it from the command line actually incredibly valuable in some contexts? Am I misconceptualizing it somehow when I envision using it in production code in lieu of statements like if (listOfStuff == null) barf();? I just feel like there's something important here that I'm not getting. *Okay, technically speaking, they're actually off by default; you have to go out of your w…
has comment: http://stackoverflow.com/comment/132417956
has answer: http://stackoverflow.com/a/2759261
has comment: http://stackoverflow.com/comment/2791368
has answer: http://stackoverflow.com/a/2759264
has answer: http://stackoverflow.com/a/2759260
has title: Is Java assert broken?
score: 25
type: AnsweredQuestion
answer count: 12
has comment: http://stackoverflow.com/comment/7965046
downvote count: 2
has answer: http://stackoverflow.com/a/2759282
tagged with: language-features
has comment: http://stackoverflow.com/comment/2790903
tagged with: design-by-contract
has answer: http://stackoverflow.com/a/2759444
type: Question
has answer: http://stackoverflow.com/a/2759285

http://stackoverflow.com/q/2645975
has answer: http://stackoverflow.com/a/2650003
type: UnansweredQuestion
tagged with: servlets
has body: Can I write a module/filter that gets put into the processing pipleline in Tomcat BEFORE the web application even gets run? Something that I could turn on/off for each web application that tomcat is handling. is this possible? So basically it would be a re-usable filter that hooks into the web pipeline that could alter the requests behavior or perform/modify the requests. One example would be to log all ip's, or redirect based on the url, block the request, etc.
tagged with: pipeline
tagged with: tomcat
type: Question
has comment: http://stackoverflow.com/comment/2665424
answer count: 2
score: 0
tagged with: java
has title: Can I write a module/filter that gets fired before the web app get's run in Tomcat?
has answer: http://stackoverflow.com/a/2648494

http://stackoverflow.com/a/2601359
upvote count: 3
type: AcceptedAnswer
type: Answer
accepted answer of: http://stackoverflow.com/q/2601233
answers question: http://stackoverflow.com/q/2601233
downvote count: 0
score: 3
has body: Many of these features are "syntactic sugar". Meaning the language has new features, but it compiles to the same bytecode. So no, you shouldn't suffer in performance. Same bytecode on an updated VM. "J2SE 5.0 is strongly compatible with previous versions of the Java 2 platform. Almost all existing programs should run on J2SE 5.0 without modification. However, there are some minor potential source and binary incompatibilities in the JRE and JDK that involve rare circumstances and "corner cases" that we are documenting here for completeness." -Sun/Oracle http://java.sun.com/j2se/1.5.0/compatibility.html#incompatibilities Also, depending on who coded your 1.4 classes, they may have had intimate knowledge of a particular VM/gc implementation and optimized for that. Not likely, but who knows. The best way to know hos something performs is to run &amp; profile. "Measure, don't guess."

http://stackoverflow.com/a/2681964
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/2702003
answers question: http://stackoverflow.com/q/2681816
upvote count: 1
has comment: http://stackoverflow.com/comment/2702132
has body: ConcurrentModificationException is not the only sign of something being not thread safe. If for example in method #1 someCollection is also an ArrayList, you will never have a ConcurrentModificationException (see the code). However, data integrity is at risk - if the source ArrayList is altered during its copying, only some of the changes may be reflect in the copy (and not necessarily the oldest changes!). In other words, atomicity is not guaranteed (unless the source is specifically designed for it, such as with CopyOnWriteArrayList). EDIT: actually, assumning that you don't synchronize your threads properly, copying an array with one thread while another thread updates references in it is problematic in the Java Memory Model, and theoretically can result in unpredictable behavior.
score: 1
has comment: http://stackoverflow.com/comment/2701639

http://stackoverflow.com/comment/2619809
has text: But if you think about it, should you ask a student for their grades? they are not the most objective person and in fact many lie. the 'proper' person to ask it the school
score: 1
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2609352

http://stackoverflow.com/comment/2735499
type: AnswerComment
comment on: http://stackoverflow.com/a/2709840
type: Comment
has text: Hi Pascal Thivent, i provider to EclipseLink in my persistence.xml and everything worked fine. But still i have another doubt, that i asked to cletus also :- Basically, what happens is say there are employee and department tables. Department table has employee collection. So if i persist employee record, then it is seen in database but not in collection of employees in department until i explicitly add it to the collection of employees. Is this necessary step? if i have 10 tables relating to one entity. Do i have to add it to collection of all 10 tables? That's too tedious?
score: 3

http://stackoverflow.com/comment/2755672
comment on: http://stackoverflow.com/a/2728143
score: 0
type: AnswerComment
has text: @Bozho I see what you were saying now.
type: Comment

http://stackoverflow.com/comment/2801479
type: AnswerComment
score: 0
has text: You lose the ability to hot deploy the actual Singleton, but not the rest of the application. So, once primary development has occurred, yea, it's a truth about the implementation, but likely not an actual real world issue. The key is ensuring that the application lifecycle works properly in terms of starting up and tearing down the Singleton and the resources it holds. It's not a horrible burden. Finally, the Singleton can be little more than a static reference pointing to the actual, sophisticated logic within the application itself.
type: Comment
comment on: http://stackoverflow.com/a/2767812

swing
tags question: http://stackoverflow.com/q/2672316
tags question: http://stackoverflow.com/q/2724063
tags question: http://stackoverflow.com/q/2712414
tags question: http://stackoverflow.com/q/2786089
tags question: http://stackoverflow.com/q/2712921
tags question: http://stackoverflow.com/q/2652194
tags question: http://stackoverflow.com/q/2601251
tags question: http://stackoverflow.com/q/2612639
tags question: http://stackoverflow.com/q/2761047
tags question: http://stackoverflow.com/q/2711092
tags question: http://stackoverflow.com/q/2775550
tags question: http://stackoverflow.com/q/2688148
tags question: http://stackoverflow.com/q/2738338
tags question: http://stackoverflow.com/q/2749191
tags question: http://stackoverflow.com/q/2757023
tags question: http://stackoverflow.com/q/2723073
tags question: http://stackoverflow.com/q/2653949
tags question: http://stackoverflow.com/q/2708725
tags question: http://stackoverflow.com/q/2708272
tags question: http://stackoverflow.com/q/2687139
tags question: http://stackoverflow.com/q/2696285
tags question: http://stackoverflow.com/q/2784063
tags question: http://stackoverflow.com/q/2665662
tags question: http://stackoverflow.com/q/2656234
tags question: http://stackoverflow.com/q/2684049
tags question: http://stackoverflow.com/q/2680828
tags question: http://stackoverflow.com/q/2662750
tags question: http://stackoverflow.com/q/2670360
tags question: http://stackoverflow.com/q/2712732
tags question: http://stackoverflow.com/q/2645775
tags question: http://stackoverflow.com/q/2783795
tags question: http://stackoverflow.com/q/2661343
tags question: http://stackoverflow.com/q/2689792
tags question: http://stackoverflow.com/q/2775306
tags question: http://stackoverflow.com/q/2785007
tags question: http://stackoverflow.com/q/2633582
tags question: http://stackoverflow.com/q/2744283
tags question: http://stackoverflow.com/q/2711854
tags question: http://stackoverflow.com/q/2706209
tags question: http://stackoverflow.com/q/2781391
tags question: http://stackoverflow.com/q/2616448
tags question: http://stackoverflow.com/q/2743177
tags question: http://stackoverflow.com/q/2729642
tags question: http://stackoverflow.com/q/2736665
tags question: http://stackoverflow.com/q/2705040
tags question: http://stackoverflow.com/q/2625506
tags question: http://stackoverflow.com/q/2783611
tags question: http://stackoverflow.com/q/2770672
tags question: http://stackoverflow.com/q/2622995
tags question: http://stackoverflow.com/q/2619901
tags question: http://stackoverflow.com/q/2662208
tags question: http://stackoverflow.com/q/2752593
tags question: http://stackoverflow.com/q/2624721
tags question: http://stackoverflow.com/q/2666758
tags question: http://stackoverflow.com/q/2672667
tags question: http://stackoverflow.com/q/2759840
tags question: http://stackoverflow.com/q/2775601
tags question: http://stackoverflow.com/q/2633323
tags question: http://stackoverflow.com/q/2657947
type: Tag
tags question: http://stackoverflow.com/q/2600960
tags question: http://stackoverflow.com/q/2668790
tags question: http://stackoverflow.com/q/2655929
tags question: http://stackoverflow.com/q/2725141
tags question: http://stackoverflow.com/q/2632033
tags question: http://stackoverflow.com/q/2751502
tags question: http://stackoverflow.com/q/2712001
tags question: http://stackoverflow.com/q/2776425
tags question: http://stackoverflow.com/q/2655756
tags question: http://stackoverflow.com/q/2638019
tags question: http://stackoverflow.com/q/2655513
tags question: http://stackoverflow.com/q/2710015
tags question: http://stackoverflow.com/q/2605523
tags question: http://stackoverflow.com/q/2742270
tags question: http://stackoverflow.com/q/2622680
tags question: http://stackoverflow.com/q/2654948
tags question: http://stackoverflow.com/q/2710065
tags question: http://stackoverflow.com/q/2754306
tags question: http://stackoverflow.com/q/2669502
tags question: http://stackoverflow.com/q/2675903

http://stackoverflow.com/a/3162092
upvote count: 3
has body: I created a SmartComboFieldEditor class to allow me to elegantly get and set the value of a ComboFieldEditor using the backing data store behind the scenes. package wat.core.plugin; import org.eclipse.jface.preference.ComboFieldEditor; import org.eclipse.swt.widgets.Composite; public class SmartComboFieldEditor extends ComboFieldEditor { public SmartComboFieldEditor(String name, String labelText, String[][] entryNamesAndValues, Composite parent) { super(name, labelText, entryNamesAndValues, parent); } public String getSelectedValue() { doStore(); return getPreferenceStore().getString(getPreferenceName()); } public void setSelectedValue(String newValue) { getPreferenceStore().setValue(getPreferenceName(), newValue); doLoad(); } } Then you can override the propertyChange and performOK methods like so: public void propertyChange(PropertyChangeEvent event) { super.propertyChange(event); if (event.getSource() == combo1) { if (combo1.getSelectedValue().equals("Some Value")) { combo2.setSelectedValue("Some Other Value"); } } }
accepted answer of: http://stackoverflow.com/q/2665906
answers question: http://stackoverflow.com/q/2665906
type: AcceptedAnswer
downvote count: 0
score: 3
type: Answer

http://stackoverflow.com/comment/2816654
comment on: http://stackoverflow.com/a/2781453
score: 0
type: AnswerComment
type: Comment
has text: thanks a lot, ill try this. yes its not a optimal solution, but in my android project i don't see a way to avoid this

http://stackoverflow.com/q/2663426
has answer: http://stackoverflow.com/a/2663523
has body: I was reading about threads and found that we can't call the start method twice on the same thread instance. But I didn't understand the exact reason for the same. So why can't we call it twice or even more times?
has answer: http://stackoverflow.com/a/45147432
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2685525
downvote count: 0
possible better answer: http://stackoverflow.com/a/2663550
tagged with: java
has comment: http://stackoverflow.com/comment/2685258
type: Question
has answer: http://stackoverflow.com/a/40130966
has answer: http://stackoverflow.com/a/32383981
score: 20
has title: Why can't we call the start method twice on a same instance of the Thread object?
has comment: http://stackoverflow.com/comment/2681650
has answer: http://stackoverflow.com/a/2663550
accepted answer: http://stackoverflow.com/a/2663523
has comment: http://stackoverflow.com/comment/2685244
favorite count: 0
upvote count: 20
has comment: http://stackoverflow.com/comment/35190375
answer count: 5

http://stackoverflow.com/comment/82773274
score: 0
comment on: http://stackoverflow.com/a/4837230
type: AnswerComment
has text: Perfect code previously I was getting the same issue in Android 5.0 but not in above one but this code working for all OS version.
type: Comment

http://stackoverflow.com/a/71447090
score: 1
has body: Text blocks Text Blocks feature arrived in Java 15. For details, see JEP 378: Text Blocks. Enclose your material in a pair of triple QUOTATION MARK characters. String html = """ Hello, world """; Your IDE has likely been updated to be savvy in assisting you with editing text blocks. For example, IntelliJ offers support.
answers question: http://stackoverflow.com/q/2678483
upvote count: 1
type: Answer
downvote count: 0

http://stackoverflow.com/comment/11487612
type: Comment
comment on: http://stackoverflow.com/a/2726008
type: AnswerComment
has text: Helpful code and mind the small letter in intent.getParcelableExtra... Thanks a lot
score: 0

http://stackoverflow.com/q/2754272
score: 1
upvote count: 1
type: Question
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2785512
has answer: http://stackoverflow.com/a/2754309
tagged with: java
has answer: http://stackoverflow.com/a/2754369
possible better answer: http://stackoverflow.com/a/2754309
answer count: 2
downvote count: 0
tagged with: jsp
has body: I currently have a JSP page with a Form for the user to enter their name, but what I want is to get the user forwarded to a different JSP page after form submission and to carry on their name to be used. I don't want to use JSTL EL just simple JSP uses. I was thinking of using a bean storing the detail in a session but how would it work. Thanks.
tagged with: javabeans
favorite count: 0
has comment: http://stackoverflow.com/comment/2790985
accepted answer: http://stackoverflow.com/a/2754369
has title: JSP: Use information from one page to another

http://stackoverflow.com/comment/2723463
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2700746
type: Comment
has text: Yes, as far as I know, when an exception is caught it really is caught. But runtime exceptions can fall through (they are unchecked exceptions).

http://stackoverflow.com/comment/2739043
score: 2
type: Comment
type: QuestionComment
has text: @CPerkins: well, "the question" -> "noitseuq eht" -> "question the" still works, and I suspect that is what Jack meant since answerers have already posted your way.
comment on: http://stackoverflow.com/q/2713655

http://stackoverflow.com/a/49375414
type: Answer
answers question: http://stackoverflow.com/q/2762093
upvote count: 17
score: 17
has body: If you are looking for a handy way to test the equality of two collections, you can use org.apache.commons.collections.CollectionUtils.isEqualCollection, which compares two collections regardless of the ordering.
downvote count: 0

http://stackoverflow.com/comment/42828599
type: Comment
score: 1
comment on: http://stackoverflow.com/a/2707938
type: AnswerComment
has text: It's not surprising (as I've just understood from the accepted answer) as `\z` matches only at the "real" end of the string. And your string is not yet finished after `StackOverflow` because of the newline.

http://stackoverflow.com/a/21180198
has comment: http://stackoverflow.com/comment/49324031
downvote count: 2
has comment: http://stackoverflow.com/comment/40716258
has comment: http://stackoverflow.com/comment/61929396
score: 15
has comment: http://stackoverflow.com/comment/59502274
upvote count: 17
answers question: http://stackoverflow.com/q/2758224
has body: Here's the most common use case. Suppose you're switching on an enum value: switch (fruit) { case apple: // do something break; case pear: // do something break; case banana: // do something break; } As long as you handle every case, you're fine. But someday, somebody will add fig to your enum and forget to add it to your switch statement. This produces a bug that may get tricky to catch, because the effects won't be felt until after you've left the switch statement. But if you write your switch like this, you can catch it immediately: switch (fruit) { case apple: // do something break; case pear: // do something break; case banana: // do something break; default: assert false : "Missing enum value: " + fruit; }
has comment: http://stackoverflow.com/comment/138972079
type: Answer
has comment: http://stackoverflow.com/comment/103438713

http://stackoverflow.com/comment/52516253
type: AnswerComment
has text: Do not miss the space between annotation and parenthesis - took me some time to find! @aspects.MyParamAnnotation (*)
type: Comment
comment on: http://stackoverflow.com/a/2766981
score: 0

http://stackoverflow.com/comment/2792261
type: Comment
score: 1
has text: +1 I like the explanation of how it goes about finding the match
type: AnswerComment
comment on: http://stackoverflow.com/a/2759826

http://stackoverflow.com/a/2706710
answers question: http://stackoverflow.com/q/2706529
score: 3
upvote count: 3
has body: Your code is a little too far off base to easily repair. For starters, a three-level nested loop is completely unnecessary; also, you don't fetch array elements by writing value++ (maybe you are getting confused with the C convention of using *ptr++ to walk an array). Start again from first principles. I'm assuming this is homework, so I'm not going to just write it for you. But here's the basic outline. The number of result elements depends on the input array rather than the dimensions of the output matrix, so your algorithm should loop over the input elements. For each element, some basic math on its index, i, will tell you where it belongs (row and col) in the output matrix. Assign array[i] to matrix[row][col]. For bonus points, note that the last row is often shorter than the other rows. Allocating matrix = new int [...][a] will produce [[1, 2, 3], [4, 0, 0]] instead of the stated requirement. Fix this by allocating just the outer array of arrays &mdash; matrix = new int [...][] &mdash; and allocating each sub-array individually, making a special case of the last row using modulus arithmetic.
downvote count: 0
type: Answer

http://stackoverflow.com/comment/2755675
comment on: http://stackoverflow.com/a/2728143
score: 0
type: AnswerComment
has text: @Bozho : yes. As for exception : no, my method does not throw exception, it only uses methods already throwing (like code sample I provided)
type: Comment

http://stackoverflow.com/comment/2699067
has text: About GET; So, I should be the both entities for me to know the encoding of the coming request? But what if I expect some request from external entity that says "expect from me `GB2312` unless I send in something different". So how can I know what will be that `something different` as If I were him, I'll consider the encoding specified in the `meta` tag is that `something` different??
comment on: http://stackoverflow.com/a/2677184
type: AnswerComment
type: Comment
score: 0

http://stackoverflow.com/a/2758362
has body: If your choice is between Java or Scala, you should probably go with Scala. Spring, Hibernete, etc. works just fine with Scala, so if you can use it right now. Tooling for Scala isn't too bad in IntelliJ at this point. It's not like it was 6 months to a year ago. However, I must caution you... Java is a pretty bloated platform at this point for strictly web development. I was a hardcore Java software architect for 9 years, and have been doing Scala recently, so I have a bias towards these platforms. Even still, if all you want to do is make an app that provides modest functionality over a database, you should just use Grails, or even Rails (although Grails will probably fit your skillset better). I wouldn't recommend doing Lift for Scala unless you already know functional programming.
upvote count: 11
score: 11
has comment: http://stackoverflow.com/comment/2791753
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2753722
type: Answer
accepted answer of: http://stackoverflow.com/q/2753722

http://stackoverflow.com/q/2647154
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/2662628
score: 3
downvote count: 0
has title: Java Package, Project , NoSuchMethod error
favorite count: 0
has comment: http://stackoverflow.com/comment/2662549
has body: I have 2 projects linked and these 2 projects each have a package under them. XProject -> XPackage -> XClass -> X1Method(); X2Method(); YProject -> YPackage -> YClass -> Y1Method(); I'm trying to call X1 and X2 methods from Y1 Method. I can call X1 Method but when I call X2 method I get a runtime error (java.lang.NoSuchMethodError:) All methods are public and there is nothing wrong with method names. It is just nonsense to have one of them working while other is giving runtime errors. Any help would be appreciated. Thanks.
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/2662555
tagged with: nosuchmethoderror
has answer: http://stackoverflow.com/a/2647182
has answer: http://stackoverflow.com/a/2647187
upvote count: 3
tagged with: java
tagged with: eclipse
tagged with: jakarta-ee

http://stackoverflow.com/q/2662043
has answer: http://stackoverflow.com/a/2662238
answer count: 3
upvote count: 7
downvote count: 1
favorite count: 0
has body: I have several Java classes which implement the strategy pattern. Each class has variable number parameters of different types: interface Strategy { public data execute(data); } class StrategyA implements Strategy { public data execute(data); } class StrategyB implements Strategy { public StrategyB(int paramA, int paramB); public data execute(data); } class StrategyC implements Strategy { public StrategyC(int paramA, String paramB, double paramC); public data execute(data); } Now I want that the user can enter the parameters in some kind of UI. The UI should be chosen at runtime, i.e. the strategies should be independent of it. The parameter dialog should not be monolithic and there should be the possibility to make it behave and look different for each strategy and UI (e.g. console or Swing). How would you solve this problem?
type: UnansweredQuestion
score: 6
tagged with: design-patterns
has title: Parametrized Strategy Pattern
tagged with: model-view-controller
tagged with: oop
tagged with: java
has answer: http://stackoverflow.com/a/2662157
tagged with: strategy-pattern
type: Question
has answer: http://stackoverflow.com/a/2774998

http://stackoverflow.com/comment/2663107
has text: Also, you forgot to double up the backslashes for Java's string-literal handling. And the question marks (making the quantifiers reluctant) aren't doing anything useful.
comment on: http://stackoverflow.com/a/2647383
type: AnswerComment
type: Comment
score: 1

http://stackoverflow.com/q/2775401
has body: I've doubled checked my API key is right and that is right I doubled checked that it was correct. Here is my source and XML could anyone check to see what is wrong. Also I make sure I have internet. <?xml version="1.0" encoding="utf-8"?> <uses-permission android:name="android.permissions.INTERNET"/> <uses-permission android:name="android.permissions.ACCESS_FINE_LOCATION"/> <uses-library android:name="com.google.android.maps" /> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> <uses-sdk android:minSdkVersion="4"/> package edu.elon.cs.mobile; import com.google.android.maps.MapActivity; import com.google.android.maps.MapView; import android.os.Bundle; public class LandNav extends MapActivity{ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.landnav); } @Override protected boolean isRouteDisplayed() { return false; } }
downvote count: 0
has comment: http://stackoverflow.com/comment/2810495
type: Question
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2777068
tagged with: android
score: 1
favorite count: 0
tagged with: http://stackoverflow.com/tag/xml
has comment: http://stackoverflow.com/comment/2810915
has title: Does anyone know why my maps only show grid
upvote count: 1
answer count: 1
accepted answer: http://stackoverflow.com/a/2777068
tagged with: java

http://stackoverflow.com/comment/2643742
type: Comment
comment on: http://stackoverflow.com/a/2629876
has text: Just go through all paths covered by the webapp's classpath, check if you don't see version collisions in JAR files with same classes. Maybe those libraries are in the `/JRE/lib` or `/JRE/lib/ext`.
score: 0
type: AnswerComment

http://stackoverflow.com/q/2622690
answer count: 3
possible better answer: http://stackoverflow.com/a/17809754
has title: ITL (iTunes Library) Format
favorite count: 0
score: 13
has answer: http://stackoverflow.com/a/17809754
accepted answer: http://stackoverflow.com/a/2888005
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2622870
tagged with: itunes
tagged with: java
tagged with: data-formats
downvote count: 1
has answer: http://stackoverflow.com/a/2888005
type: Question
has body: I´m developing a Java solution for manage an iTunes Library (ITL file). The ITL format is a propietary one. I'm looking for an implementation or a documentation about ITL format but Google can't find anything useful. Does anyone have experience about that? Where to find more information? Thanks in advance.
upvote count: 14

http://stackoverflow.com/comment/88222556
type: AnswerComment
type: Comment
has text: PECS is counter intuitive, If I am taking something from the list so I am consuming items or producing?
comment on: http://stackoverflow.com/a/2723538
score: 2

http://stackoverflow.com/a/51117234
answers question: http://stackoverflow.com/q/2663115
score: 0
type: Answer
has body: Here is the solution for detecting the cycle. public boolean hasCycle(ListNode head) { ListNode slow =head; ListNode fast =head; while(fast!=null &amp;&amp; fast.next!=null){ slow = slow.next; // slow pointer only one hop fast = fast.next.next; // fast pointer two hops if(slow == fast) return true; // retrun true if fast meet slow pointer } return false; // return false if fast pointer stop at end }

http://stackoverflow.com/a/2717507
has body: I would scan IP range and test Socket connection to port 80 with a code like this: try { s = new Socket(addr,80); System.out.println("Webserver found on IP:" + addr ); s.close(); } catch (IOException ex) { System.out.println("Webserver NOT found on IP:" + addr ); }
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/2743527
answers question: http://stackoverflow.com/q/2717459

http://stackoverflow.com/comment/8127415
score: 0
has text: Get rid of the jms in op 1 and just send it via spawned curl/http to a rest endpoint and you can cut one piece (JMS/MDB) of conf/complexity out.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2643791

http://stackoverflow.com/a/2674394
answers question: http://stackoverflow.com/q/2674325
type: Answer
has comment: http://stackoverflow.com/comment/2693300
has body: In Java you can not have a class name that is the same as a package name. That means the JDT package must have enforced that rule only in 3.4 See bug 63668 for instance. As Nate comments: A class named Exception won't prevent you from creating package exception. Case matters. Also remember the full name of a class includes the package it's in. So a.b.SomeClass (class name) is different from x.y.SomeClass (package name). There would be no name collision here. The class name and the package name have to match in both case and package to cause this error. See his more accurate answer.
has comment: http://stackoverflow.com/comment/2693177
score: 4
upvote count: 4
has comment: http://stackoverflow.com/comment/2700668
downvote count: 0
has comment: http://stackoverflow.com/comment/2693190
has comment: http://stackoverflow.com/comment/2697640

http://stackoverflow.com/comment/2725238
score: 2
comment on: http://stackoverflow.com/a/2694903
has text: I don't use Eclipse, so your difficulty is somehow tied to how you are attaching the JAR to your Eclipse project. Outside of Eclipse, it's automatic. Since it's been a couple of months since I last taught my course, I am rusty on the Eclipse steps -- sorry!
type: AnswerComment
type: Comment

http://stackoverflow.com/q/2721546
has comment: http://stackoverflow.com/comment/84971933
linked to: http://stackoverflow.com/q/5199359
has answer: http://stackoverflow.com/a/2721557
accepted answer: http://stackoverflow.com/a/2721557
tagged with: generics
possible better answer: http://stackoverflow.com/a/2721602
type: AnsweredQuestion
has title: Why don't Java Generics support primitive types?
downvote count: 2
tagged with: primitive
type: Question
has answer: http://stackoverflow.com/a/2721672
tagged with: java
score: 301
has answer: http://stackoverflow.com/a/2721602
upvote count: 303
has body: Why do generics in Java work with classes but not with primitive types? For example, this works fine: List&lt;Integer&gt; foo = new ArrayList&lt;Integer&gt;(); but this is not allowed: List&lt;int&gt; bar = new ArrayList&lt;int&gt;();
has answer: http://stackoverflow.com/a/49686666
favorite count: 0
has answer: http://stackoverflow.com/a/47867819
answer count: 5

http://stackoverflow.com/q/2622694
tagged with: android
tagged with: internationalization
type: AnsweredQuestion
upvote count: 3
has answer: http://stackoverflow.com/a/3695888
type: Question
score: 3
has title: android: getting rid of "warning: unmappable character for encoding ascii"
possible better answer: http://stackoverflow.com/a/7460320
tagged with: java
has answer: http://stackoverflow.com/a/11429681
has answer: http://stackoverflow.com/a/7460320
has answer: http://stackoverflow.com/a/61498752
tagged with: encoding
downvote count: 0
accepted answer: http://stackoverflow.com/a/3695888
has body: I'm compiling using android tools without eclipse. I compile launching "ant debug" from command line. I have found many many instructions around the web about how to remove with annoying warning, but I haven't been able to make any of them work. I've tried -D option, I've tried randomly tweaking build.* files, I've tried exporting an environment variable... nothing. I guess some of these methods just don't work, and some others would work but I've been doing them incorrectly. Anything is possible and I can't stand it any more: any advice on how to do it?
favorite count: 0
answer count: 5
has answer: http://stackoverflow.com/a/7203092

http://stackoverflow.com/comment/2612883
comment on: http://stackoverflow.com/q/2603323
has text: Could you show where the object `b` comes from in your code? Is it persistent?
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/68081115
score: 0
type: Answer
answers question: http://stackoverflow.com/q/2685524
has body: The number you want to do a perfect square test on is A. B is the integer square root of A and the .sqrt() function returns the integer lower floor of the square root. The Boolean of B*B=A is returned. The Boolean return is "true" if it is a perfect square and "false" if it is not a perfect square. public static Boolean PerfectSQR(BigInteger A) { BigInteger B = A.sqrt(); return B.multiply(B).equals(A); } An alternative is to use the sqrtAndRemainder() function. If the remainder, B[1], is zero it is a perfect square. The boolean TRUE then is returned as shown below. public static Boolean PerfectSQR(BigInteger A) { BigInteger [] B=A.sqrtAndRemainder(); return B[1].equals(BigInteger.ZERO); }

http://stackoverflow.com/q/2741797
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2742873
score: 2
upvote count: 2
has body: I'm migrating my apps from WebSphere to JBoss. I would like to know if JBoss 4.2.3 GA supports JDK 1.4.2. Many thanks in advance.
tagged with: java
type: Question
type: AnsweredQuestion
tagged with: jdk1.4
accepted answer: http://stackoverflow.com/a/2742873
tagged with: jboss
has title: Does Jboss 4.2.3.GA support JDK 1.4.2?
answer count: 1

http://stackoverflow.com/comment/5386289
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2748720
type: Comment
has text: Can you elaborate what you mean by the term "lazy" in the sentence[1]? [1] "It looks to me like you might have nested the Format class and interface inside FormatBig as a convenience so that you only have to edit and compile one file. That is lazy. Alternatively, if you are doing it to organize your code, learn how to use Java packages."

http://stackoverflow.com/comment/2679817
comment on: http://stackoverflow.com/q/2662333
score: 0
has text: Also why are Vectors bad? What should I be using instead?
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2776149
type: Question
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2776338
has answer: http://stackoverflow.com/a/39794263
tagged with: ssl
has title: Error accessing a Web Service with SSL
has body: I have a program that is supposed to send a file to a web service, which requires an SSL connection. I run the program as follows: SET JAVA_HOME=C:\Program Files\Java\jre1.6.0_07 SET com.ibm.SSL.ConfigURL=ssl.client.props "%JAVA_HOME%\bin\java" -cp ".;Test.jar" ca.mypackage.Main This was works fine, but when I change the first line to SET JAVA_HOME=C:\Program Files\IBM\SDP\runtimes\base_v7\java\jre I get the following error: com.sun.xml.internal.ws.client.ClientTransportException: HTTP transport error: java.net.SocketException: java.lang.ClassNotFoundException: Cannot find the specified class com.ibm.websphere.ssl.protocol.SSLSocketFactory at com.sun.xml.internal.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:119) at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:140) at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:86) at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:593) at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:552) at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:537) at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:434) at com.sun.xml.internal.ws.client.Stub.process(Stub.java:247) at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(SEIStub.java:132) at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:242) at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:222) at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:115) at $Proxy26.fileSubmit(Unknown Source) at com.testing.TestingSoapProxy.fileSubmit(TestingSoapProxy.java:81) at ca.mypackage.Main.main(Main.java:63) Caused by: java.net.SocketException: java.lang.ClassNotFoundException: Cannot find the specified class com.ibm.websphere.ssl.protocol.SSLSocketFactory at javax.net.ssl.DefaultSSLSocketFactory.a(SSLSocketFactory.java:7) at javax.net.s…
possible better answer: http://stackoverflow.com/a/2776828
downvote count: 0
answer count: 7
has answer: http://stackoverflow.com/a/38321197
has answer: http://stackoverflow.com/a/2776828
favorite count: 0
has answer: http://stackoverflow.com/a/6488179
tagged with: ibm-jdk
has answer: http://stackoverflow.com/a/9438133
upvote count: 13
tagged with: ibm-jvm
has answer: http://stackoverflow.com/a/2776338
tagged with: java
score: 13
has answer: http://stackoverflow.com/a/29370246
tagged with: web-services

http://stackoverflow.com/a/2697830
type: Answer
has body: Some frameworks such as BEA KODO (Implementation of the Java Data Objects specification) use bytecode manipulation to "enhance" Plain Old Java Objects and add the persistence logic, based on an XML description. Thus, database mapping information is then automatically generated on the bytecode.
score: 0
answers question: http://stackoverflow.com/q/2697657

http://stackoverflow.com/a/2743421
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/2773340
has body: I worked on the same project once long back where the project had be done with FoxPro and then we migrated that project to Java with MySQL. We had the data in Excel sheets or .txt files, so we created tables as exact replica of the FoxPro data and transferred the data from the Excel/CSV /txt to MySQL using the Import data feature. Once we did this, I think further you can take care from MySQL Data. But remember work will take some time, and we need to be patient.
upvote count: 1
answers question: http://stackoverflow.com/q/2743383
type: Answer

http://stackoverflow.com/q/2763422
has body: I need to include about 1 MByte of data in a Java application, for very fast and easy access in the rest of the source code. My main background is not Java, so my initial idea was to convert the data directly to Java source code, defining 1MByte of constant arrays, classes (instead of C++ struct) etc., something like this: public final/immutable/const MyClass MyList[] = { { 23012, 22, "Hamburger"} , { 28375, 123, "Kieler"} }; However, it seems that Java does not support such constructs. Is this correct? If yes, what is the best solution to this problem? NOTE: The data consists of 2 tables with each about 50000 records of data, which is to be searched in various ways. This may require some indexes later, with significant more records, maybe 1 million records, saved this way. I expect the application to start up very fast, without iterating through these records.
tagged with: java
score: 16
has answer: http://stackoverflow.com/a/2763600
has answer: http://stackoverflow.com/a/2763428
has answer: http://stackoverflow.com/a/2763529
upvote count: 16
type: Question
has answer: http://stackoverflow.com/a/2763665
has answer: http://stackoverflow.com/a/12294408
answer count: 11
has answer: http://stackoverflow.com/a/2765666
accepted answer: http://stackoverflow.com/a/2763513
possible better answer: http://stackoverflow.com/a/2763523
has answer: http://stackoverflow.com/a/2763523
downvote count: 0
favorite count: 0
has title: Large amount of constants in Java
has answer: http://stackoverflow.com/a/2763707
has answer: http://stackoverflow.com/a/2763449
tagged with: android
has answer: http://stackoverflow.com/a/2763743
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2763513

http://stackoverflow.com/a/6452879
upvote count: 1
answers question: http://stackoverflow.com/q/2636144
downvote count: 0
type: Answer
score: 1
has body: See this; it might be beneficial: #!/bin/sh echo "ENTER DATA BASE NAME:" read dbname echo "ENTER DATABASE USER NAME:" read dbuser echo "ENTER DATASE PASSWORD:" read dbpassword mysqldump -u $dbuser -p$dbpassword $dbname&gt;$dbname".sql"

http://stackoverflow.com/comment/2653097
type: QuestionComment
has text: This answer will be helpful http://stackoverflow.com/questions/767372/java-string-equals-versus/767379#767379
score: 0
comment on: http://stackoverflow.com/q/2638801
type: Comment

http://stackoverflow.com/comment/2879694
comment on: http://stackoverflow.com/a/2786524
score: 0
type: Comment
has text: Is this solution dependent on packaging?
type: AnswerComment

http://stackoverflow.com/comment/2809971
has text: Alright, got the answer. JPA context needs to be loaded before the actual delete. The quick fix was to call getEntityManager().getReference() and then invoke the delete/remove. Thank you everyone for reading the thread.
comment on: http://stackoverflow.com/q/2775507
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/a/2739256
type: Answer
score: 1
upvote count: 2
answers question: http://stackoverflow.com/q/2738827
downvote count: 1
has body: Clearly the interface designer is at fault for not considering the possibility that doSomething() may fail. Ideally he should have either allowed IOException to be thrown (if he suspected that IO wouldbe invovled) or a SomethingException (checked) which you could use to wrap your IOException. If the interface designer is available to you, talk to them and ask what they expected to happen in the case of failure. Maybe they can change the interface: or maybe it is acceptable to fail silently according to the interface's contract. Failing all of these you are reduced to a choice of failing silently (possibly recording but not responding to the problem) or throwing a RuntimeException which may terminate the process.

http://stackoverflow.com/comment/2779825
comment on: http://stackoverflow.com/a/2749730
has text: Yes, Serializable is ok (but it's just a constraint, it doesn't really mean anything)! In any case you could do like PartlyCloudy suggests, if you don't have many kinds of different packets with different params/types of params.
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/117007096
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/43625582
has text: This is outdated, set up for Servlet 2.3. Current spec is 4.0.1 and moving to 5 soon.

http://stackoverflow.com/comment/2666620
has text: I lost by a 6 seconds.. (I just made up that number).
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2646059

http://stackoverflow.com/a/2699250
has comment: http://stackoverflow.com/comment/2757896
has body: You could implement a utility method: public final class IOUtil { private IOUtil() {} public static void closeQuietly(Closeable... closeables) { for (Closeable c : closeables) { if (c != null) try { c.close(); } catch(Exception ex) {} } } } Then your code would be reduced to: try { copy(in, out); } finally { IOUtil.closeQuietly(in, out); } Additional I imagine there'll be a method like this in a 3rd party open-source library. However, my preference is to avoid unnecessary library dependencies unless I'm using a large portion of its functionality. Hence I tend to implement simple utility methods like this myself.
has comment: http://stackoverflow.com/comment/2751601
has comment: http://stackoverflow.com/comment/2721777
has comment: http://stackoverflow.com/comment/2751244
answers question: http://stackoverflow.com/q/2699209
has comment: http://stackoverflow.com/comment/2757542
has comment: http://stackoverflow.com/comment/2721769
has comment: http://stackoverflow.com/comment/2721801
type: Answer
has comment: http://stackoverflow.com/comment/2722317
has comment: http://stackoverflow.com/comment/2723186
has comment: http://stackoverflow.com/comment/2721746
score: 32
has comment: http://stackoverflow.com/comment/2721827
downvote count: 1
has comment: http://stackoverflow.com/comment/2721771
upvote count: 33

http://stackoverflow.com/a/2625231
type: AcceptedAnswer
score: 6
type: Answer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2625031
has body: Why do I get the error with "this" but not with "TestFilter"? this is used to refer to "instance" attributes or method ( among others ). Instance means a new object exist and each object ( instance ) have a copy of the given attribute. The class name ( in your case TestFilter ) is used to refer to "class" attributes or methods ( those who do not require an instance to extist. So, in your first line you're declaring filterFiles as a class attribute ( you don't require an instance for that. See: private static final FileFilter filterFiles; This means, you declare class attribute named: filterFiles of type FileFilter which is private and whose reference can't be changed ( because it is final). Since it is a class attribute you may access it in the main method ( which is a class level method ). This both will work: for(File f : file.listFiles(TestFilter.filterFiles)){ and for(File f : file.listFiles(filterFiles)){ But for(File f : file.listFiles(this.filterFiles)){ Won't, because this refers to the current instance, but since you're in a class level method ( main ) there is no instance, so, there is no this or in compiler words: non-static variable this cannot be referenced from a static context Instance attributes are unique per instance. Class level attribute are unique per class. Consider the following class: import static java.lang.System.out; class Employee { // class level counter. It exist regardless of the instances created. public static int employeeCount = 0; // instance attribute. Each one is different from others instances private String employeeName; // Class level method, can be invoked without instance. public static Employee createEmployee( String withName ) { Employee e = new Employee(); // Set the name to the instance e.employeeName = withName; // Increments the class counter Employee.employeeCount++; return e; } // Object constructor. public Employee() { out.println("Constructor invoked!!! A new object has born, yeah!"); } // Instance method "toString…
answers question: http://stackoverflow.com/q/2625031
upvote count: 6
has comment: http://stackoverflow.com/comment/2638438

http://stackoverflow.com/comment/2624391
has text: I will post the code.. sadly this is a 2000 line file that was generated by HyperJaxB! Thanks for your help..
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2611536
type: AnswerComment

http://stackoverflow.com/a/2597985
type: Answer
answers question: http://stackoverflow.com/q/2597965
score: 2
has body: It does not enforce whether the implementer will do a deep or shallow copy.
has comment: http://stackoverflow.com/comment/2606949
upvote count: 3
has comment: http://stackoverflow.com/comment/13594223
downvote count: 1

http://stackoverflow.com/a/33891524
answers question: http://stackoverflow.com/q/2607858
score: 0
type: Answer
has body: I have it working with this: repositories { mavenCentral() maven { url "https://raw.github.com/embarkmobile/zxing-android-minimal/mvn-repo/maven-repository/" } } compile 'com.google.zxing:core:3.2.1' compile 'com.embarkmobile:zxing-android-minimal:2.0.0@aar' compile 'com.embarkmobile:zxing-android-integration:2.0.0@aar' I recommend using the IntentIntegrator IntentIntegrator integrator = new IntentIntegrator(getActivity()); integrator.forSupportFragment(this).initiateScan(); The requestCode comes back with IntentIntegrator.REQUEST_CODE No need to install a separate scanner

http://stackoverflow.com/comment/2613159
type: Comment
has text: Ahh true, I've tried ruby on rails - are the spring/hibernate etc. like that? Where you don't really code any SQL queries, you call helper methods which do the majority of that for you? I'm just reading the hibernate site now - I literally threw it all together in netbeans, now I need to work my way through it all (and a few books / tutorials) to see how it all works!
type: AnswerComment
comment on: http://stackoverflow.com/a/2603277
score: 0

http://stackoverflow.com/comment/2730412
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2706054
has text: Reformatted and cited; please revert if incorrect.

http://stackoverflow.com/comment/97401105
has text: BTW, there is a way to alter default SSL factory via command line without modifying the app: https://stackoverflow.com/questions/2762080/how-to-ignore-expired-certificates-from-outside-a-java-application/55334566#55334566
type: AnswerComment
comment on: http://stackoverflow.com/a/2752455
score: 0
type: Comment

http://stackoverflow.com/comment/39430881
type: Comment
has text: There should be something between `long` and BigInteger. BigInteger is way too bulky.
comment on: http://stackoverflow.com/a/2776432
score: 0
type: AnswerComment

http://stackoverflow.com/q/2631345
upvote count: 3
tagged with: java
tagged with: error-handling
type: Question
has title: Java: custom-exception-error
has answer: http://stackoverflow.com/a/2631377
has body: $ javac TestExceptions.java TestExceptions.java:11: cannot find symbol symbol : class test location: class TestExceptions throw new TestExceptions.test("If you see me, exceptions work!"); ^ 1 error Code import java.util.*; import java.io.*; public class TestExceptions { static void test(String message) throws java.lang.Error{ System.out.println(message); } public static void main(String[] args){ try { // Why does it not access TestExceptions.test-method in the class? throw new TestExceptions.test("If you see me, exceptions work!"); }catch(java.lang.Error a){ System.out.println("Working Status: " + a.getMessage() ); } } }
answer count: 2
downvote count: 0
possible better answer: http://stackoverflow.com/a/2631362
has answer: http://stackoverflow.com/a/2631362
favorite count: 0
tagged with: custom-errors
accepted answer: http://stackoverflow.com/a/2631377
type: AnsweredQuestion
score: 3

http://stackoverflow.com/a/2627045
accepted answer of: http://stackoverflow.com/q/2626731
score: 4
type: Answer
has body: I'm not familiar with MemoryImageSource. Here's the first 16 300 digits of π, repeated in a BufferedImage and using your color table. import java.awt.Dimension; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.List; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; public class PiRaster extends JPanel { private static final int W = 30; private static final int H = 30; private static List&lt;Integer&gt; pi = new ArrayList&lt;Integer&gt;(); BufferedImage image; private int[] clut = { 0x000000, 0x787878, 0x008B00, 0x00008B, 0x008B8B, 0x008B00, 0xCDCD00, 0xFF4500, 0x8B0000, 0xFF0000 }; public PiRaster() { this.setPreferredSize(new Dimension(W * 16, H * 10)); String s = "" + "31415926535897932384626433832795028841971693993751" + "05820974944592307816406286208998628034825342117067" + "98214808651328230664709384460955058223172535940812" + "84811174502841027019385211055596446229489549303819" + "64428810975665933446128475648233786783165271201909" + "14564856692346034861045432664821339360726024914127"; for (int i = 0; i &lt; s.length(); i++) { pi.add(s.charAt(i) - '0'); } } @Override public void paintComponent(Graphics g) { if (image == null) { image = (BufferedImage) createImage(W, H); int i = 0; for (int row = 0; row &lt; H; row++) { for (int col = 0; col &lt; W; col++) { image.setRGB(col, row, clut[pi.get(i)]); if (++i == pi.size()) { i = 0; } } } } g.drawImage(image, 0, 0, getWidth(), getHeight(), null); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new PiRaster()); frame.pack(); frame.setVisible(true); } }); } }
upvote count: 4
answers question: http://stackoverflow.com/q/2626731
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/2678356
upvote count: 3
has answer: http://stackoverflow.com/a/34288630
downvote count: 0
has answer: http://stackoverflow.com/a/2679987
accepted answer: http://stackoverflow.com/a/2679987
type: Question
type: AnsweredQuestion
score: 3
has title: How to create a new Active Directory Account from Java (via JNDI)?
tagged with: jndi
tagged with: java
possible better answer: http://stackoverflow.com/a/34288630
tagged with: active-directory
answer count: 2
has body: Is it possible to create a new user in AD rom Java via JNDI? I tried via trusty Google but nothing came up - maybe I was googling using the wrong terminology (JNDI Active Directory Create User). Any tips will be create appreciated. Current status: I have connected to AD via my Java code and can change attributes of existing AD accounts; next I would like to be able to create AD users from Java/JNDI. I am using http://forums.sun.com/thread.jspa?threadID=582103 and I made sure my account had the correct privileges to create an AD account and I am using LDAPS.
favorite count: 0

on-the-fly
type: Tag
tag name: on-the-fly
tags question: http://stackoverflow.com/q/2603064

http://stackoverflow.com/a/2657144
type: Answer
upvote count: 9
answers question: http://stackoverflow.com/q/2657131
has comment: http://stackoverflow.com/comment/2674338
downvote count: 0
score: 9
has comment: http://stackoverflow.com/comment/2674926
has body: Try: class SumSet&lt;E extends Addable&lt;E&gt;&gt; implements Set&lt;E&gt; { I don't know if this is exactly what you mean but basically the problem is that you're using Addable in the declaration of SumSet as a raw type. That strips off all generic parameter types and makes Addable appear to SumSet as: interface Addable { Object add(Object x); Object sub(Object y); Object zero(); } Obviously Object is not an E, hence the error. See What is the raw type? from the Java Generics FAQ. On a side note public is unnecessary on methods in interface definitions.

http://stackoverflow.com/comment/8172007
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/2718416
type: Comment
has text: I am starting to lean away from ICEpdf... we pay for it, but every time so far where a PDF file hasn't rendered correctly, it turns out to be a "new feature", at which point they give a quote for an immense amount of money for a custom fix. Not a great experience so far... but I guess it works for "most" files.

http://stackoverflow.com/a/2766135
answers question: http://stackoverflow.com/q/2765482
upvote count: 7
has comment: http://stackoverflow.com/comment/2814192
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2814216
downvote count: 0
has body: I use a regexps for such tasks. In your case it should look something like this: String str = "today is tuesday"; return str.matches(".*?\\bt\\b.*?"); // returns "false" String str = "today is t uesday"; return str.matches(".*?\\bt\\b.*?"); // returns "true" A short explanation: . matches any character, *? is for zero or more times, \b is a word boundary. More information on regexps can be found here or specifically for java here
type: Answer
accepted answer of: http://stackoverflow.com/q/2765482
score: 7

http://stackoverflow.com/comment/2669270
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/2653040
type: Comment
has text: Too much code to look at for such a question, comments are not much helping and BTW. it is called nested class, not sub class, that is something different.

http://stackoverflow.com/comment/117714700
has text: Forgive me for not realizing that this thread is about Java since nowhere in does it say Java in the thread. I thought we were talking C# since C# also contains the BigInteger class.
type: Comment
comment on: http://stackoverflow.com/a/2685668
type: AnswerComment
score: 0

http://stackoverflow.com/comment/28406414
comment on: http://stackoverflow.com/a/9291992
type: Comment
has text: Thanks for `UIManager.getDefaults().getColor("Button.focus")`. I didn't need any custom painting for my task, so I've just used `BorderFactory.createLineBorder` with the color taken from the `UIManager`.
type: AnswerComment
score: 0

http://stackoverflow.com/q/2615890
has title: Determining the size of the current cursor
score: 1
tagged with: java
tagged with: swt
upvote count: 1
tagged with: cursor
type: Question
has answer: http://stackoverflow.com/a/2733339
has body: I am writing a an swt app that has an embeded GLCanvas and I wanted to be able to find out the size of the current cursor, is this possible? And if I cannot get it from JOGL then is it possible from either swt or awt?
has answer: http://stackoverflow.com/a/2616169
answer count: 2
downvote count: 0
favorite count: 0
tagged with: jogl
type: UnansweredQuestion

http://stackoverflow.com/q/2717013
possible better answer: http://stackoverflow.com/a/2930335
type: Question
has answer: http://stackoverflow.com/a/2930335
tagged with: processing
tagged with: modeling
has title: Can we count Processing as Environment for Mathematical Modelling and Programming?
accepted answer: http://stackoverflow.com/a/2717836
tagged with: math
tagged with: java
score: 0
answer count: 2
has body: Can we count Processing as Environment for Mathematical Modelling and Programming? And If yes can we do the same for Eclipse (Java)?
has comment: http://stackoverflow.com/comment/2743263
has comment: http://stackoverflow.com/comment/2743934
has answer: http://stackoverflow.com/a/2717836
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2743435

http://stackoverflow.com/a/2764050
answers question: http://stackoverflow.com/q/2764031
has body: I'm not sure I understand your problem, but here is a guess. I suspect you do the actual print wrong. If the variable is called username and "username" is printed instead of the content of username it seems you need to do something like print("" + username + ""); instead of print("username"); In jsp you could also simply write <%= username %> If the problem concerns treatment of html-entities you may find the following interesting: http://www.rgagnon.com/javadetails/java-0306.html
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/2796771

http://stackoverflow.com/comment/57051141
has text: How to set values in Headers if I wanted to do that ?
type: Comment
comment on: http://stackoverflow.com/a/24624966
type: AnswerComment
score: 0

http://stackoverflow.com/q/2765636
tagged with: runnable
downvote count: 0
answer count: 1
favorite count: 0
type: UnansweredQuestion
tagged with: sockets
tagged with: android
tagged with: multithreading
type: Question
has title: Sockets, Threads and Services in android, how to make them work together?
has body: I am facing a probleme with threads and sockets I cant figure it out, if someone can help me please i would really appreciate. There are the facts : I have a service class NetworkService, inside this class I have a Socket attribute. I would like it be at the state of connected for the whole lifecycle of the service. To connect the socket I do it in a thread, so if the server has to timeout, it would not block my UI thread. Problem is, into the thread where I connect my socket everything is fine, it is connected and I can talk to my server, once this thread is over and I try to reuse the socket, in another thread, I have the error message Socket is not connected. Questions are : - Is the socket automatically disconnected at the end of the thread? - Is their anyway we can pass back a value from a called thread to the caller ? Thanks a lot, Here is my code public class NetworkService extends Service { private Socket mSocket = new Socket(); private void _connectSocket(String addr, int port) { Runnable connect = new connectSocket(this.mSocket, addr, port); new Thread(connect).start(); } private void _authentification() { Runnable auth = new authentification(); new Thread(auth).start(); } private INetwork.Stub mBinder = new INetwork.Stub() { @Override public int doConnect(String addr, int port) throws RemoteException { _connectSocket(addr, port); _authentification(); return 0; } }; class connectSocket implements Runnable { String addrSocket; int portSocket; int TIMEOUT=5000; public connectSocket(String addr, int port) { addrSocket = addr; portSocket = port; } @Override public void run() { SocketAddress socketAddress = new InetSocketAddress(addrSocket, portSocket); try { mSocket.connect(socketAddress, TIMEOUT); PrintWriter out = new PrintWriter(mSocket.getOutputStream(), true); out.println("test42"); Log.i("connectSocket()", "Connection Succesful"); } catch (IOException e) { Log.e("connectSocket()", e.getMessage()); e.printStackTrace(); } } } class authentification impleme…
upvote count: 5
tagged with: java
has answer: http://stackoverflow.com/a/2766775
score: 5

http://stackoverflow.com/a/7093129
type: Answer
upvote count: 3
has body: You haven't defined a target to call: <foreach param="instance" list="a,b,c,d,e" target="processListItem" /> alternatively:
score: 3
downvote count: 0
answers question: http://stackoverflow.com/q/2608935

http://stackoverflow.com/q/2751733
answer count: 8
has comment: http://stackoverflow.com/comment/8219866
tagged with: enums
has answer: http://stackoverflow.com/a/28149269
has answer: http://stackoverflow.com/a/15727845
has comment: http://stackoverflow.com/comment/44669808
upvote count: 220
accepted answer: http://stackoverflow.com/a/2751896
has comment: http://stackoverflow.com/comment/16608876
tagged with: jpa
downvote count: 0
has answer: http://stackoverflow.com/a/17263424
has body: I'm looking for the different ways to map an enum using JPA. I especially want to set the integer value of each enum entry and to save only the integer value. @Entity @Table(name = "AUTHORITY_") public class Authority implements Serializable { public enum Right { READ(100), WRITE(200), EDITOR (300); private int value; Right(int value) { this.value = value; } public int getValue() { return value; } }; @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "AUTHORITY_ID") private Long id; // the enum to map : private Right right; } A simple solution is to use the Enumerated annotation with EnumType.ORDINAL: @Column(name = "RIGHT") @Enumerated(EnumType.ORDINAL) private Right right; But in this case JPA maps the enum index (0,1,2) and not the value I want (100,200,300). Th two solutions I found do not seem simple... First Solution A solution, proposed here, uses @PrePersist and @PostLoad to convert the enum to an other field and mark the enum field as transient: @Basic private int intValueForAnEnum; @PrePersist void populateDBFields() { intValueForAnEnum = right.getValue(); } @PostLoad void populateTransientFields() { right = Right.valueOf(intValueForAnEnum); } Second Solution The second solution proposed here proposed a generic conversion object, but still seems heavy and hibernate-oriented (@Type doesn't seem to exist in Java EE): @Type( type = "org.appfuse.tutorial.commons.hibernate.GenericEnumUserType", parameters = { @Parameter( name = "enumClass", value = "Authority$Right"), @Parameter( name = "identifierMethod", value = "toInt"), @Parameter( name = "valueOfMethod", value = "fromInt") } ) Is there any other solutions ? I've several ideas in mind but I don't know if they exist in JPA: use the setter and getter methods of right member of Authority Class when loading and saving the Authority object an equivalent idea would be to tell JPA what are the methods of Right enum to convert enum to int and int to enum Because I'm using Spring, is there any way to…
favorite count: 0
has title: Map enum in JPA with fixed values?
has comment: http://stackoverflow.com/comment/8219867
has answer: http://stackoverflow.com/a/58750103
has answer: http://stackoverflow.com/a/25940489
tagged with: spring
possible better answer: http://stackoverflow.com/a/21073312
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/25246982
score: 220
has answer: http://stackoverflow.com/a/21073312
tagged with: java
tagged with: orm
has answer: http://stackoverflow.com/a/2751896
type: Question

http://stackoverflow.com/q/2702218
has title: Creating custom Android project templates in Eclipse?
tagged with: eclipse
answer count: 1
downvote count: 0
favorite count: 0
type: UnansweredQuestion
tagged with: android
score: 2
has answer: http://stackoverflow.com/a/2702959
upvote count: 2
tagged with: java
type: Question
has body: Every app I make starts out with a number of common base classes, interfaces, utility classes and a basic package structure that has been working for me. Is there a way for me to set up a project template in Eclipse that will give me all of the basic Android project stuff PLUS a bunch of custom packages, classes and interfaces? I guess I could just put all of this stuff into one or more libraries as opposed to creating a whole project template, so if you have a preferred approach or information/links/etc on how to do any of the above, please share (I'm relatively inexperienced with Eclipse, so the more detail the better). Thanks.

http://stackoverflow.com/a/2940179
downvote count: 1
score: 2
upvote count: 3
answers question: http://stackoverflow.com/q/2661110
has body: I would say it is bad. while (!b) { // do something } reads much better than while (b != true) { // do something }
type: Answer

http://stackoverflow.com/a/2744850
downvote count: 1
has body: instanceof is another option.
type: Answer
answers question: http://stackoverflow.com/q/2744812
score: 0
upvote count: 1

http://stackoverflow.com/comment/2815303
comment on: http://stackoverflow.com/q/2780442
type: Comment
has text: "I dont want users to kill that process?" are you asking us what you want :-|
type: QuestionComment
score: 1

http://stackoverflow.com/comment/2752404
has text: The cascade was really a shotgun approach to try to get the transient property to persist. It doesn't have to be on the Details record
score: 0
comment on: http://stackoverflow.com/q/2725111
type: Comment
type: QuestionComment

http://stackoverflow.com/a/4100491
upvote count: 2
type: Answer
has body: Do you have a copy of FoxPro? You can save the database as an HTML file, if you want. Then, from HTML, you can save to any format you want. I recently did this to save a FoxPro table as an Excel spreadsheet (not that I'd suggest using that for your Java code). If you plan on using Java, once you have access to the data, why not use one of Java's native storage types?
answers question: http://stackoverflow.com/q/2743383
score: 2
downvote count: 0

http://stackoverflow.com/comment/2714025
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2692445
has text: Possible duplicate : http://stackoverflow.com/questions/2675666/help-needed-in-formatting-date-in-java

http://stackoverflow.com/comment/2760335
has text: here's the difference I think - servlet.jar and hibernate.jar are of different nature. servlet.jar is something that is "provided", because the server implements a certain version of the servlet api. And even if you put servlet-3.0.jar, it won't work. But hibernate is another thing - you don't (or shouldn't) rely on the container for that.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2730432

http://stackoverflow.com/q/2748039
type: AnsweredQuestion
has title: Interface between two related JPA entities
upvote count: 2
tagged with: java-ee-5
has answer: http://stackoverflow.com/a/2748336
answer count: 1
tagged with: jpa
accepted answer: http://stackoverflow.com/a/2748336
favorite count: 0
score: 2
tagged with: ejb-3.0
downvote count: 0
tagged with: java
tagged with: orm
has body: The scenario is as below (tables shown) Delivery table ------ id channelId type 10 100 fax 20 200 email Fax table ---- id number 100 1234567 101 1234598 Email table ----- id email 200 a@a.com 201 b@b.com basically a one to one relationship between the delivery and the channel entity but since each concrete channel(fax, email) has different members I want to create a generic interface (channel) between the two entities and use it for the @OneToOne relationship. Seems to me a simple scenario where lot of you might have already gone through but I'm unable to succeed. I tried putting that targetEntity thing but no use. Still says "delivery references an unknown entity" Any ideas? thanks in advance
type: Question

http://stackoverflow.com/q/2711894
tagged with: java
has answer: http://stackoverflow.com/a/2712156
tagged with: image
answer count: 3
score: 2
has answer: http://stackoverflow.com/a/2711927
downvote count: 0
favorite count: 0
has body: I would like to create a gif image of a filled red circle on a green background. What is the easiest way to do it in Java?
has answer: http://stackoverflow.com/a/2711932
upvote count: 2
type: UnansweredQuestion
has title: How can I create an image with Java?
type: Question

http://stackoverflow.com/a/6953155
has body: I think you are making it a bit too tough on yourself, a priority queue is efficiently implemented with array-based heaps: simpler and more efficient (read: contiguous memory areas).
upvote count: 0
type: Answer
downvote count: 1
has comment: http://stackoverflow.com/comment/34596853
answers question: http://stackoverflow.com/q/2702913
score: -1

http://stackoverflow.com/comment/2611676
comment on: http://stackoverflow.com/q/2600523
has text: I don't have the code, this happens in a library from the weblogic server (xbean.jar). In the method XmlBeans.typeSystemForClassLoader(ClassLoader, String) a NPE happens, because the first parameter is null. This is all I found out so far.
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/2701602
type: Answer
score: 1
has body: Yes, It is always nice to configure service beans as spring beans. In the web layer you need to take care of instantiating the needed service objects. Another option is to make the web layer classes also as spring beans and inject the necessary service layer spring beans. From the testing point of view also, this type of design is very helpful when we use Spring testing framework.
upvote count: 1
answers question: http://stackoverflow.com/q/2690146
accepted answer of: http://stackoverflow.com/q/2690146
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/74627660
comment on: http://stackoverflow.com/a/2773558
type: AnswerComment
type: Comment
score: 2
has text: link is broken; working one: https://github.com/junit-team/junit4/issues/79

http://stackoverflow.com/a/2733246
answers question: http://stackoverflow.com/q/2732865
score: 0
has body: Thanks you so much everyone I solved my problem this way: model = new TableProg(elements); table.setModel(model); in the loop
type: Answer

http://stackoverflow.com/comment/2815405
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2780442
has text: Most users won't even know that it exists; let alone have any reason to kill it.
score: 0

http://stackoverflow.com/comment/39980683
has text: I would nitpick that there is no such thing as "automated acceptance." Acceptance is performed by the Business side. You may want to implement automated E2E tests as a matter of self-preservation. Even if the tests matched the user stories perfectly, it would still be the responsibility of the business to check for correctness and own the acceptance decision. We found the show stopper for sophisticated tested was the difficulty in setting up the database to handle various conditions. This sort of automation is not cheap and it is not easy beyond the trivial case.
comment on: http://stackoverflow.com/q/2694529
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/2696460
accepted answer of: http://stackoverflow.com/q/2696450
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2718621
answers question: http://stackoverflow.com/q/2696450
type: Answer
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/2718689
has body: Check the folder that you have the project files stored inside of, are they set to hidden? Also you can try reseting your workstation.Go to window then reset perspective. I hope that helps it may not.

http://stackoverflow.com/a/2607972
type: AcceptedAnswer
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/2607786
score: 3
upvote count: 3
answers question: http://stackoverflow.com/q/2607786
has comment: http://stackoverflow.com/comment/3912712
has body: You could use annotation instead of string literal to denote the invoked action and then use APT to verify that the method exists. APT is invoked automatically by the javac. http://java.sun.com/javase/6/docs/technotes/tools/windows/javac.html#processing http://java.sun.com/j2se/1.5.0/docs/guide/apt/GettingStarted.html http://java.sun.com/j2se/1.5.0/docs/guide/apt/mirror/overview-summary.html By taking your example, I would suggest design as follows - you put a binding annotation in code and add the action instantiation code in the annotation processor. The actions in that case need to be class members which is a good practice anyway. Make sure you use resource bundles for icons and text and you'll save a lot of grief in the long run: class MyClass { // the keys should be looked up from resource bundle @TomActionBinding("go", "text-key", "msg-key", "icon-key"); Action act; public MyClass() { JButton btn = new JButton(act); } private void go() { // do task } }

http://stackoverflow.com/a/2599635
has body: you just need to cast the result MyCollection mycollection = (MyCollection) somehandler.getCollection(); edit : or change the return type of getCollection() to a MyCollection
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/2608376
answers question: http://stackoverflow.com/q/2599623

http://stackoverflow.com/a/2635946
answers question: http://stackoverflow.com/q/2635839
type: AcceptedAnswer
downvote count: 0
upvote count: 142
accepted answer of: http://stackoverflow.com/q/2635839
score: 142
type: Answer
has comment: http://stackoverflow.com/comment/2650131
has body: The distinction is rather easy: extending TestCase is the way unit tests were written in JUnit 3 (of course it's still supported in JUnit 4) using the @Test annotation is the way introduced by JUnit 4 Generally you should choose the annotation path, unless compatibility with JUnit 3 (and/or a Java version earlier than Java 5) is needed. The new way has several advantages: The @Test annotation is more explicit and is easier to support in tools (for example it's easy to search for all tests this way) Multiple methods can be annotated with @Before/@BeforeClass and @After/@AfterClass providing more flexibility Support for @Rule annotations on things like ExpectedException Support for the @Ignored annotation Support for alternative test runners using @RunWith To test for expected exceptions in a JUnit 3 TestCase you'd have to make the text explicit. public void testMyException() { try { objectUnderTest.myMethod(EVIL_ARGUMENT); fail("myMethod did not throw an Exception!"); } catch (MyException e) { // ok! // check for properties of exception here, if desired } } JUnit 5 introduced yet another API change, but still uses annotations. The new @Test annotation is org.junit.jupiter.api.Test (the "old" JUnit 4 one was org.junit.Test), but it works pretty much the same as the JUnit 4 one.
has comment: http://stackoverflow.com/comment/82546392
has comment: http://stackoverflow.com/comment/2652458
has comment: http://stackoverflow.com/comment/2651915
has comment: http://stackoverflow.com/comment/2650143

http://stackoverflow.com/q/2774326
downvote count: 0
has title: Quartz: triggering multiple jobs
has answer: http://stackoverflow.com/a/2776842
answer count: 3
favorite count: 0
has body: In Quarts, can I use a single trigger to schedule multiple jobs, so that all the jobs gets executed in parallel. What is the best way to do this. Example, every hour execute Jobs j1, j2, ..., jn in parallel. Assuming that there is no dependency between the jobs.
type: UnansweredQuestion
score: 6
upvote count: 6
has answer: http://stackoverflow.com/a/31556430
tagged with: java
tagged with: quartz-scheduler
has answer: http://stackoverflow.com/a/2775788
type: Question

http://stackoverflow.com/a/2732359
upvote count: 4
score: 4
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2732295
type: Answer
accepted answer of: http://stackoverflow.com/q/2732295
has body: In the method watchProgram, all Java knows is that the argument is an InfoItem. That argument may or may not be an Item, and thus it may or may not have that method changeRecorded. Since Java can't guarantee that the object has that method, it can't insert the code to call the method when the class is compiled. As far as the Java compiler is concerned, the method changeRecorded doesn't exist in the argument item. Usually when you run into a situation like this, it's a sign that you shouldn't really be calling that changeRecorded method in the first place. Think very carefully about why you think you need it and how you could change your own code to work without using it. For instance, if someone were to call your watchProgram method with some other implementation of InfoItem that doesn't have a changeRecorded method, what should watchProgram do? If, after some careful thought, you decide that it really is necessary for you to call the changeRecorded method when the passed-in argument is an instance of Item, you can use a cast to do so: watchProgram(InfoItem item) { // do stuff if (item instanceof Item) { // thanks to ruslan for if statement Item castedItem = (Item)item; castedItem.changeRecorded(); } // do stuff } But as I said, this sort of thing should be used sparingly. The whole point of object-oriented programming (specifically, polymorphism) is to make it so you don't have to do this.

http://stackoverflow.com/q/2741276
score: 1
tagged with: java
has title: Is there a way to find out a database cursor is open or not in Java?
type: Question
tagged with: plsql
downvote count: 0
has answer: http://stackoverflow.com/a/2741294
favorite count: 0
answer count: 5
has answer: http://stackoverflow.com/a/2741293
tagged with: jdbc
has answer: http://stackoverflow.com/a/2741609
has comment: http://stackoverflow.com/comment/8191346
has answer: http://stackoverflow.com/a/2741329
type: UnansweredQuestion
upvote count: 1
has comment: http://stackoverflow.com/comment/8191347
has body: Is there a way in JDBC to find out the cursor opened or not in JAVA. We are getting an exception when tried to access an un opened cursor. java.sql.SQLException: Cursor is closed. Here is what is happening. The Stored proc is designed this way. the proc returns the cursor and a couple of other columns. For some conditions, the DB guy is not opening the cursor and returns only the other remaining column outside of the cursor. So when the Java code tries to get cursor, it throws this exception. I know, I can catch the exception and proceed further with the remaining columns. But I was wondering is there a different (may be better) way to handle this? Or just need to open the cursor in the stored proc, even if there is nothing to return as part of the cursor?
has answer: http://stackoverflow.com/a/2744220

http://stackoverflow.com/comment/127785000
has text: Despite your Edit, the question that we should all *want* to have answered is "What behavior does Java guarantee `HashSet` for iteration order?", or, more specifically, "Given a specific set of elements, does Java guarantee a **deterministic** iteration order for `HashSet`?" For the OP, this is important because you cannot guarantee that your code will always be run by a specific Java JDK.
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/2704597

http://stackoverflow.com/a/2612770
answers question: http://stackoverflow.com/q/2612434
score: 3
upvote count: 3
has body: The reason a lot of commercial enterprises use Java (and similar high level languages) is that it (they) make it easier to write complex, robust and relatively efficient applications that are maintainable in the long term. With C or C++, large scale applications of the same level of complexity requires more effort (developer years). The software also tends to be more fragile because programmers with average skills make more mistakes in C / C++ than in Java (et al), and those mistakes tend to be more insidious (e.g. buffer overruns) and to have more serious consequences. It is claimed that C / C++ is more efficient than Java and other managed languages. While this is demonstrably true for some small (lines of code) applications, it is rather difficult to demonstrate for large (e.g. 100k+ SLOC) applications ... because nobody writes such applications to the same design in multiple languages. Besides, in most kinds of software, the speed of an application is less important than things such as cost of development, cost of maintenance, system reliability and so on. Often, the only hard performance criterion is that the software runs fast enough to be tolerable. A lot of young programmers find this hard to grasp, and hard to accept, but the folks who pay our salaries think about these things differently ...
downvote count: 0
type: Answer

http://stackoverflow.com/a/2670817
has comment: http://stackoverflow.com/comment/2689437
type: Answer
score: 1
upvote count: 1
has body: In Groovy, those braces constitute a closure literal. So, no can do. Personally, I'd consider having to give up anonymous blocks for getting closures a very good deal.
answers question: http://stackoverflow.com/q/2670785
downvote count: 0

http://stackoverflow.com/a/2676790
downvote count: 0
has comment: http://stackoverflow.com/comment/11874888
has comment: http://stackoverflow.com/comment/42430396
has comment: http://stackoverflow.com/comment/2695738
has comment: http://stackoverflow.com/comment/2696205
has comment: http://stackoverflow.com/comment/74126872
score: 12
has body: You should annotate your classes with the @Entity(access = AccessType.FIELD) and annotate your attributes. This should solve your problem. The setter is the best way to support refactoring. And what's the problem with having the little setter there.
answers question: http://stackoverflow.com/q/2676689
has comment: http://stackoverflow.com/comment/2696754
type: Answer
upvote count: 12

http://stackoverflow.com/q/2730200
type: Question
tagged with: indexing
possible better answer: http://stackoverflow.com/a/2730369
tagged with: java
tagged with: bigdecimal
answer count: 2
tagged with: lucene
favorite count: 0
tagged with: search-engine
score: 8
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/2730369
has answer: http://stackoverflow.com/a/2731834
accepted answer: http://stackoverflow.com/a/2731834
has title: How to index BigDecimal values in Lucene 3.0.1
has body: I have some BigDecimal values which should be indexed for searching. Lucene has NumericField but it has setters only for long, double, float and int. I could store it as a String but then I would not benefit from NumericRangeQuery. How you have stored your BigDecimals? Any best practices to share?
upvote count: 8

http://stackoverflow.com/comment/2810412
type: Comment
score: 2
comment on: http://stackoverflow.com/q/2775113
has text: Who cares if it is argumentative? It is a great question and we can all learn better ways of making our code more readable because of it.
type: QuestionComment

http://stackoverflow.com/q/2774320
tagged with: diacritics
answer count: 3
has comment: http://stackoverflow.com/comment/2808124
has answer: http://stackoverflow.com/a/2774365
has answer: http://stackoverflow.com/a/5203440
has answer: http://stackoverflow.com/a/2774370
has comment: http://stackoverflow.com/comment/2808276
accepted answer: http://stackoverflow.com/a/2774370
favorite count: 0
linked to: http://stackoverflow.com/q/5157141
has title: How to know if a string contains accents
type: AnsweredQuestion
tagged with: java
score: 10
upvote count: 10
type: Question
has body: How to know if a string contains accents?
possible better answer: http://stackoverflow.com/a/2774365
downvote count: 0
tagged with: string
tagged with: unicode

http://stackoverflow.com/a/2668076
has body: You can do this using the MapView's MapController. You get the MapController using MapView.getController(), then you can attempt to set the correct zoom using MapController.zoomToSpan(). I also tend to use ItemizedOverlay's getLatSpanE6() and getLonSpanE6() to make this simpler. An example: MapView map = (MapView) findViewById(R.id.Map); MapController mc = map.getController(); mc.zoomToSpan(overlay.getLatSpanE6(), overlay.getLonSpanE6()); It is important to note their caveat: Because the zoom can only achieve discrete levels, and because the aspect ratio of the map may not match the ratio given, the quality of the fit may vary. The only thing we guarantee is that, after the zoom, at least one of the new latitude or the new longitude will be within a factor of 2 from the corresponding parameter. Edit: In order to also get the map to zoom on the correct place, you have to use MapController.setCenter().
type: Answer
accepted answer of: http://stackoverflow.com/q/2666922
downvote count: 0
answers question: http://stackoverflow.com/q/2666922
has comment: http://stackoverflow.com/comment/2686692
has comment: http://stackoverflow.com/comment/2692208
score: 9
has comment: http://stackoverflow.com/comment/2686371
has comment: http://stackoverflow.com/comment/9278328
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2686163
upvote count: 9

http://stackoverflow.com/comment/2695783
type: Comment
type: QuestionComment
has text: it would be accessed from the other decompile() only..
comment on: http://stackoverflow.com/q/2676829
score: 0

http://stackoverflow.com/comment/2991866
score: 1
has text: I agree and respect your explanation at the top. But cause this blog search-able over net, I wanted to suggest a different scenario and when cascades are not to be handled by code, it can be done this way. Will modify my part as well.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2817636

http://stackoverflow.com/a/2754554
answers question: http://stackoverflow.com/q/2754515
has comment: http://stackoverflow.com/comment/2785782
type: Answer
has body: I think your problem is that Java won't let you update the GUI from another thread than the GUI thread itself. This causes grief to everybody at some point, but fortunately a reasonably convenient workaround is provided. The idea is to pass the code that does the updating as a Runnable to the method SwingUtilities.invokeAndWait or SwingUtilities.invokeLater. Here's an example. To run your GA at maximum speed and exploit parallelism, I guess invokeLater would be appropriate. EDIT: Oh wait, camickr's solution hints that you're doing something else: You're running the GA in the GUI's thread. Well, that can only do one or the other, calculate or display. So the true solution would combine both changes: Run the GA in a separate thread (you could run it in the thread used by main() after you've instantiated the GUI); and Use invokeLater to communicate updates to the GUI thread (which camickr calls the EDT, or Event Dispatch Thread).
downvote count: 0
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/2785684
accepted answer of: http://stackoverflow.com/q/2754515
type: AcceptedAnswer

http://stackoverflow.com/a/2614922
accepted answer of: http://stackoverflow.com/q/2614890
downvote count: 2
has body: What you're describing sounds like Premature Optimisation. If you're writing something other than a toy application, it's important to be confident that your optimisations are actually addressing a real problem. Is your program running slowly? If so, have you run it through a profiler or otherwise identified where the poor performance is happening? If you have identified that what you want to do will address your performance issue, I suggest you look at running the components concurrently in different threads, not different processes. Then your components can avoid blocking each other, you will be able to take advantage of multi-core processors and you do not take on the complexity and performance overhead of inter-process communication over network sockets and the like.
has comment: http://stackoverflow.com/comment/2887362
score: 9
has comment: http://stackoverflow.com/comment/2626290
has comment: http://stackoverflow.com/comment/2868351
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2614890
type: Answer
upvote count: 11

http://stackoverflow.com/comment/2698811
type: Comment
has text: Your driver could load the MySQL driver (or just construct it directly, which isn't really significantly more coupled the `forName`ing from a literal string.
comment on: http://stackoverflow.com/a/2679164
score: 0
type: AnswerComment

http://stackoverflow.com/q/2647232
has answer: http://stackoverflow.com/a/2647253
has body: I have a java.util.ArrayList&lt;Item&gt; and an Item object. Now, I want to obtain the number of times the Item is stored in the arraylist. I know that I can do arrayList.contains() check but it returns true, irrespective of whether it contains one or more Items. Q1. How can I find the number of time the Item is stored in the list? Q2. Also, If the list contains more than one Item, then how can I determine the index of other Items because arrayList.indexOf(item) returns the index of only first Item every time?
has comment: http://stackoverflow.com/comment/2662909
has answer: http://stackoverflow.com/a/2647402
score: 7
tagged with: java
has answer: http://stackoverflow.com/a/2647759
answer count: 6
type: Question
has answer: http://stackoverflow.com/a/56244897
downvote count: 0
has title: Count the occurrences of items in ArrayList
favorite count: 0
has comment: http://stackoverflow.com/comment/2662692
has answer: http://stackoverflow.com/a/2952881
tagged with: arraylist
has answer: http://stackoverflow.com/a/2647265
tagged with: list
type: UnansweredQuestion
upvote count: 7

http://stackoverflow.com/a/2624210
answers question: http://stackoverflow.com/q/2624192
upvote count: 190
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2624192
has comment: http://stackoverflow.com/comment/138454383
downvote count: 6
has comment: http://stackoverflow.com/comment/54190814
has comment: http://stackoverflow.com/comment/28021065
type: Answer
score: 184
has comment: http://stackoverflow.com/comment/27386005
has comment: http://stackoverflow.com/comment/122793805
has body: Usually hashes wouldn't do sums, otherwise stop and pots will have the same hash. and you wouldn't limit it to the first n characters because otherwise house and houses would have the same hash. Generally hashs take values and multiply it by a prime number (makes it more likely to generate unique hashes) So you could do something like: int hash = 7; for (int i = 0; i &lt; strlen; i++) { hash = hash*31 + charAt(i); }
has comment: http://stackoverflow.com/comment/118908499

http://stackoverflow.com/a/2745345
has comment: http://stackoverflow.com/comment/2775119
has comment: http://stackoverflow.com/comment/2775048
answers question: http://stackoverflow.com/q/2744753
has comment: http://stackoverflow.com/comment/2774690
has comment: http://stackoverflow.com/comment/2774888
has comment: http://stackoverflow.com/comment/2774964
has body: Is the sample line representative? An editor for some rule based language (ACLs)? How about going for a full Information Extraction/named entity recognition solution, the one that will be able to recognize entities (keywords, ip addresses, etc)? You don't have to write everything from scratch, there're existing tools and libraries. UPDATE: Here's a piece of Snort code that I believe does the parsing: Function ParseRule() if (*args == '(') { // "Preprocessor Rule detected" } else { /* proto ip port dir ip port r*/ toks = mSplit(args, " \t", 7, &amp;num_toks, '\\'); /* A rule might not have rule options */ if (num_toks &lt; 6) { ParseError("Bad rule in rules file: %s", args); } .. } otn = ParseRuleOptions(sc, rtn, roptions, rule_type, protocol); .. mSplit is defined in mstring.c, a function to split a string into tokens. In your case, ParseRuleOptions should return one for the whole string inside brackets I guess. UPDATE 2: btw, is your first example correct, since in snort, you can add options to rules? For example this is a valid rule being written (options section not completed): alert tcp any any -&gt; 192.168.1.0/24 111 (content:"|00 01 86 a5|"; &lt;caret&gt; In some cases you can have either 6 or 7 'words', so your algorithm should have a bit more knowledge, right?
score: 0
type: Answer

http://stackoverflow.com/comment/117226873
type: Comment
comment on: http://stackoverflow.com/a/2615834
has text: It's inclusive of `fromIndex` for anyone wondering.
type: AnswerComment
score: 0

http://stackoverflow.com/comment/28084651
has text: The recursive checkbox caught me out, it's a bit counter-intuitive for that behavior to be disabled by default.
type: AnswerComment
comment on: http://stackoverflow.com/a/12201561
type: Comment
score: 9

http://stackoverflow.com/a/2754170
has comment: http://stackoverflow.com/comment/19423701
downvote count: 0
has body: Propagation.REQUIRED (documented here) will create a new transaction (if none exists for the current thread), or will join an existing transaction (if one exists). When the method exits, then the transaction will be completed (if entering the method caused a transaction to be created), or will leave the transaction open (if a transaction already existed when the method was entered). In other, words, it's symmetrical, and will leave the thread's transactional state in the same state it was before the method was entered.
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2785218
accepted answer of: http://stackoverflow.com/q/2754160
has comment: http://stackoverflow.com/comment/2785148
type: Answer
answers question: http://stackoverflow.com/q/2754160
has comment: http://stackoverflow.com/comment/2785164
score: 24
upvote count: 24

http://stackoverflow.com/a/26372240
score: 7
has comment: http://stackoverflow.com/comment/62499926
upvote count: 7
answers question: http://stackoverflow.com/q/2598129
type: Answer
downvote count: 0
has body: This is my solution. The algorithm is mainly the same as the one in the book "Cracking the code interview" where this exercise comes from, but I tried to improve it a bit and make the code more understandable: public static void removeDuplicates(char[] str) { // if string has less than 2 characters, it can't contain // duplicate values, so there's nothing to do if (str == null || str.length < 2) { return; } // variable which indicates the end of the part of the string // which is 'cleaned' (all duplicates removed) int tail = 0; for (int i = 0; i < str.length; i++) { boolean found = false; // check if character is already present in // the part of the array before the current char for (int j = 0; j < i; j++) { if (str[j] == str[i]) { found = true; break; } } // if char is already present // skip this one and do not copy it if (found) { continue; } // copy the current char to the index // after the last known unique char in the array str[tail] = str[i]; tail++; } str[tail] = '\0'; } One of the important requirements from the book is to do it in-place (as in my solution), which means that no additional data structure should be used as a helper while processing the string. This improves performance by not wasting memory unnecessarily.

http://stackoverflow.com/comment/2613235
has text: Grails looks really interesting - will give this a look and grab the netbeans plugin. Thanks :)
type: AnswerComment
comment on: http://stackoverflow.com/a/2603443
score: 0
type: Comment

http://stackoverflow.com/comment/2818624
type: Comment
comment on: http://stackoverflow.com/a/2781586
type: AnswerComment
score: 0
has text: @Knowing me knowing you - OK, so this is a console app then. Got it. Even still, if you as the programmer need to come along and debug this, I'd want the actual exception object (with associated method and stack trace) to look at, you know?

http://stackoverflow.com/a/2772533
type: Answer
has body: I've not tested this myself, but it it supposed to work. Get the image element from the design, change it's size, then compile the altered design. BufferedImage img = ImageIO.read(new File(wo_image_path)); height = img.getHeight(); width = img.getWidth(); jasperSubDesign = JasperManager.loadXmlDesign(context.getRealPath("/WEB-INF/reports/decoration_sheet_header.jrxml")); JRDesignImage image = (JRDesignImage)jasperSubDesign.getPageHeader().getElementByKey("wo_image"); image.setX(3); image.setY(69); image.setHeight(new Long(height - Math.round(height*.35)).intValue()); image.setWidth(new Long(width - Math.round(width*.35)).intValue()); JasperCompileManager.compileReportToFile(jasperSubDesign, context.getRealPath("/WEB-INF/reports/decoration_sheet_header.jasper")); From Jasperforge
has comment: http://stackoverflow.com/comment/2807637
answers question: http://stackoverflow.com/q/2772352
score: 0
has comment: http://stackoverflow.com/comment/2806437

http://stackoverflow.com/comment/2806984
type: AnswerComment
comment on: http://stackoverflow.com/a/2772937
type: Comment
has text: how to query ? i dont want to my query vendor specific ?
score: 0

http://stackoverflow.com/comment/2726569
score: 0
type: Comment
has text: Unfortunately, because `Object.clone` is protected, the only way you can do that with objects of unknown type is to invoke `clone` by reflection. :-P And if you're gonna use reflection, you may as well reflect on the factory method, or even the constructor. :-P
comment on: http://stackoverflow.com/a/2702670
type: AnswerComment

http://stackoverflow.com/comment/2755938
type: Comment
has text: I don't see a difference there. Foo(IDataStore store) and Foo(DataStore store) can do the same thing, just in one case the interface name is prefixed with I. You can still pass it a DatabaseDataStore or FileSystemDataStore, they just implement IDataStore with an I prefix.
type: AnswerComment
score: 2
comment on: http://stackoverflow.com/a/2728123

http://stackoverflow.com/a/7515938
type: Answer
has body: EDIT: With the recently released Junit 4.10, you can use RuleChain to chain rules correctly (see at the end). You could introduce another private field without the @Rule annotation, then you can reorder your code as you wish: public class FolderRuleOrderingTest { private TemporaryFolder privateFolder = new TemporaryFolder(); @Rule public MyNumberServer server = new MyNumberServer(privateFolder); @Rule public TemporaryFolder folder = privateFolder; @Test public void testMyNumberServer() throws IOException { server.storeNumber(10); assertEquals(10, server.getNumber()); } ... } The cleanest solution is to have a compound rule, but the above should work. EDIT: With the recently released Junit 4.10, you can use RuleChain to chain rules correctly: public static class UseRuleChain { @Rule public TestRule chain = RuleChain .outerRule(new LoggingRule("outer rule")) .around(new LoggingRule("middle rule")) .around(new LoggingRule("inner rule")); @Test public void example() { assertTrue(true); } } writes the log starting outer rule starting middle rule starting inner rule finished inner rule finished middle rule finished outer rule
upvote count: 49
has comment: http://stackoverflow.com/comment/70476020
score: 49
has comment: http://stackoverflow.com/comment/55039202
has comment: http://stackoverflow.com/comment/55066037
has comment: http://stackoverflow.com/comment/55065961
downvote count: 0
answers question: http://stackoverflow.com/q/2730365

http://stackoverflow.com/a/2699854
upvote count: 40
score: 39
answers question: http://stackoverflow.com/q/2699788
type: Answer
has body: With the following code you can check if an object is a class that extends Event but isn't an Event class instance itself. if(myObject instanceof Event &amp;&amp; myObject.getClass() != Event.class) { // then I'm an instance of a subclass of Event, but not Event itself } By default instanceof checks if an object is of the class specified or a subclass (extends or implements) at any level of Event.
has comment: http://stackoverflow.com/comment/2722479
downvote count: 1

ant
tags question: http://stackoverflow.com/q/2738574
tags question: http://stackoverflow.com/q/2745262
tags question: http://stackoverflow.com/q/2766640
tags question: http://stackoverflow.com/q/2614378
tags question: http://stackoverflow.com/q/2753795
tags question: http://stackoverflow.com/q/2766104
tags question: http://stackoverflow.com/q/2695438
tags question: http://stackoverflow.com/q/2715542
type: Tag
tags question: http://stackoverflow.com/q/2721888
tags question: http://stackoverflow.com/q/2779559
tags question: http://stackoverflow.com/q/2618281
tags question: http://stackoverflow.com/q/2608935
tags question: http://stackoverflow.com/q/2677288
tags question: http://stackoverflow.com/q/2754664
tags question: http://stackoverflow.com/q/2703607
tags question: http://stackoverflow.com/q/2716646
tags question: http://stackoverflow.com/q/2715764
tag name: ant
tags question: http://stackoverflow.com/q/2690143
tags question: http://stackoverflow.com/q/2666794
tags question: http://stackoverflow.com/q/2631082
tags question: http://stackoverflow.com/q/2769758
tags question: http://stackoverflow.com/q/2679066
tags question: http://stackoverflow.com/q/2786004
tags question: http://stackoverflow.com/q/2633956
tags question: http://stackoverflow.com/q/2768903
tags question: http://stackoverflow.com/q/2716400
tags question: http://stackoverflow.com/q/2692421
tags question: http://stackoverflow.com/q/2723486
tags question: http://stackoverflow.com/q/2780263
tags question: http://stackoverflow.com/q/2758289
tags question: http://stackoverflow.com/q/2677831
tags question: http://stackoverflow.com/q/2686226
tags question: http://stackoverflow.com/q/2754631
tags question: http://stackoverflow.com/q/2624545

http://stackoverflow.com/comment/2608114
comment on: http://stackoverflow.com/a/2598455
score: 0
type: AnswerComment
type: Comment
has text: Companies making TVs (or devices that plug into TVs such as Blu-Ray players) with browsers (or software to install on those devices) include Sony, Samsung, Phillips, Opera, Cello, IP Vision, and dozens of others.

http://stackoverflow.com/comment/43468815
comment on: http://stackoverflow.com/a/18486615
type: AnswerComment
has text: Yes @JoeBlow, it's recommended to use match_parent instead of fill_parent from API 2.4/3.0 onwards
score: 0
type: Comment

http://stackoverflow.com/comment/10641105
comment on: http://stackoverflow.com/a/2703107
has text: I was wondering about the Link Grammer Parser performance but I see in your paper you've covered it under the RelEx parser.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/2703641
type: Answer
upvote count: 1
has body: The command interpreter in JNode does command completion that is aware of each command's syntax and command argument semantics. It does not deal with spelling/typing mistakes, but if you use completion they are less of a problem.
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/2703511

http://stackoverflow.com/a/2605602
downvote count: 0
score: 1
has body: Just to get you started I googled something for you: http://www.java2s.com/Code/Java/Database-SQL-JDBC/JavadatabaseandSwing.htm I hope that helps.
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/2605523

http://stackoverflow.com/q/2649997
has answer: http://stackoverflow.com/a/2650042
has answer: http://stackoverflow.com/a/2650032
type: AnsweredQuestion
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/2650042
tagged with: null
has comment: http://stackoverflow.com/comment/2666098
downvote count: 0
favorite count: 0
possible better answer: http://stackoverflow.com/a/2650036
score: 14
has answer: http://stackoverflow.com/a/2650036
tagged with: jdbc
has body: I swear this used to work, but it's not in this case. I'm trying to match col1, col2 and col3, even if one or more of them is null. I know that in some languages I've had to resort to circumlocutions like ((? is null AND col1 is null) OR col1 = ?). Is that required here? PreparedStatement selStmt = getConn().prepareStatement( "SELECT * " + "FROM tbl1 " + "WHERE col1 = ? AND col2 = ? and col3 = ?"); try { int col = 1; setInt(selStmt, col++, col1); setInt(selStmt, col++, col2); setInt(selStmt, col++, col3); ResultSet rs = selStmt.executeQuery(); try { while (rs.next()) { // process row } } finally { rs.close(); } } finally { selStmt.close(); } // Does the equivalient of stmt.setInt(col, i) but preserves nullness. protected static void setInt(PreparedStatement stmt, int col, Integer i) throws SQLException { if (i == null) stmt.setNull(col, java.sql.Types.INTEGER); else stmt.setInt(col, i); }
has answer: http://stackoverflow.com/a/28099002
answer count: 4
upvote count: 14
has title: Binding a null variable in a PreparedStatement

http://stackoverflow.com/a/2650032
downvote count: 0
has body: Generally something being equal to NULL is always false (even NULL, so SELECT * FROM tbl WHERE NULL=NULL; will be an empty set), so you probably do need to do it the long way if you want to accept null equality like that
type: Answer
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/2666089
answers question: http://stackoverflow.com/q/2649997

http://stackoverflow.com/a/2660033
has comment: http://stackoverflow.com/comment/2844524
type: Answer
has body: Yes a thread is needed (or you wait/block until the copy is finished) for copying the InputStream to the OutputStream. Check the org.apache.commons.net.io.Util class for several helper methods to copy the data.
downvote count: 0
has comment: http://stackoverflow.com/comment/2678831
has comment: http://stackoverflow.com/comment/2678570
score: 3
answers question: http://stackoverflow.com/q/2659996
upvote count: 3

http://stackoverflow.com/comment/70205653
comment on: http://stackoverflow.com/a/2665420
type: Comment
has text: Beware, this solution makes it quite a bit harder to focus the window. It's a dialog, which means it won't appear as an open program in Windows. If the user focuses another window, such as a web browser, to re-focus the dialog, the user would have to minimize all other programs.
score: 0
type: AnswerComment

http://stackoverflow.com/a/2754960
upvote count: 1
score: 1
has body: Your problem is that everytime you add something to the FlexTable it has to re-render the whole page and repaint. Try creating a new FlexTable, populating it, when it is fully populated, get rid of the old one and put the new one there.
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2754035

http://stackoverflow.com/comment/2788847
type: QuestionComment
score: 1
has text: Are you shure that casting your proxy to OriginalClass works? In my understanding if you created the proxy for the OriginalInterface you shouldn't be able to cast to OriginalClass
type: Comment
comment on: http://stackoverflow.com/q/2757314

http://stackoverflow.com/q/2725495
tagged with: tomcat
has body: For a company that has their stack built on Apache Tomcat and JSP what would be the best web service platform to be leveraged by that infrastructure that would be consumed by .NET client. From the .NET side I know the answer would be Windows Communication Foundation (WCF) but I'm not sure from the other side.
favorite count: 0
has answer: http://stackoverflow.com/a/2726872
has title: Most interoperable web service platform for Apache Tomcat JSP platform to be consumed by .NET
type: AnsweredQuestion
score: 1
tagged with: java
upvote count: 1
tagged with: web-services
type: Question
accepted answer: http://stackoverflow.com/a/2726872
answer count: 1
downvote count: 0
tagged with: .net
tagged with: jsp

http://stackoverflow.com/a/2629758
type: Answer
has comment: http://stackoverflow.com/comment/65238571
has comment: http://stackoverflow.com/comment/65391225
has comment: http://stackoverflow.com/comment/65238679
has comment: http://stackoverflow.com/comment/65406934
has comment: http://stackoverflow.com/comment/19718545
has comment: http://stackoverflow.com/comment/65400625
has comment: http://stackoverflow.com/comment/2650391
upvote count: 47
has comment: http://stackoverflow.com/comment/65392928
has body: Java doesn't have pointers; Java has references. It's a fine point, but a pointer has extra operations that you may (or may not) typically use; a reference lacks these operations because the operations may be unsafe. For example, if you use a pointer to index the first element of an array like so: int squares[] = {1, 4, 9, 16, 25, 36, 49}; int* intPointer = squares; you may want to dereference the pointer and get the value "1", but you may also: intPointer++ and after you do that, when you dereference the pointer you will get the value "4". A second intPointer++; will, when dereferenced, give you the value "9". This is because the ++ operation moves the pointer one "unit" ahead in memory. The issue comes from the weaknesses in the C / C++ typechecking system (C++ must maintain compatibilty with C, so it allows the same issues). The pointer stores an address in memory and the ++ operation adds the appropriate number of bytes to the address. On many systems ++ing an int adds four bytes, but if the pointer was a char pointer ++ing it should only add one byte. Note that since the underlying data type of a pointer is an address in memory, the following is legal (but not recommended): char* charPointer = squares; charPointer++; void* voidPointer = squares; voidPointer++; Since pointers are addresses in memory, they might represent (correctly) any bit of memory in the computer, but they are only properly dereferenced when the underlying data maches the type and alignment of the pointer. For pointers that aren't managed by lots of code to make them safe, this means you might stray off the data type (or alignment) of the desired information and a dereference might end in disaster. Attempting to fix this issue with custom code tends to slow down one pointers badly enough that you notice performance issues, and it opens the doors for adding errors in the custom "pointer management" code. Java side steps all of these issues by returning a reference. A reference does not refer t…
downvote count: 0
has comment: http://stackoverflow.com/comment/2655137
has comment: http://stackoverflow.com/comment/19708974
has comment: http://stackoverflow.com/comment/2650381
has comment: http://stackoverflow.com/comment/47198884
answers question: http://stackoverflow.com/q/2629357
has comment: http://stackoverflow.com/comment/65400026
has comment: http://stackoverflow.com/comment/65232437
score: 47

http://stackoverflow.com/a/29369534
has comment: http://stackoverflow.com/comment/52206049
type: Answer
downvote count: 1
score: -1
upvote count: 0
has body: public class Match { void comp(String s1, String s2) { char[] charArray1 = s1.toCharArray(); char[] charArray2 = s2.toCharArray(); int length1 = charArray1.length; int length2 = charArray2.length; int flag = 0; if (length1 == length2) { for (int i = 0; i &lt;= length1 - 1; i++) { if (charArray1[i] == charArray2[i]) { System.out.println("index are matched:" + " " + charArray1[i] + " " + "in index-" + i); } else { flag = 1; System.out.println("index are not matched:" + " " + charArray1[i] + " " + "in index-" + i); System.out.println("index are not matched:" + " " + charArray2[i] + " " + "in index-" + i); } } } else { System.out.println("Your string are not matched by length"); } if (flag == 0) { System.out.println("Your string matched with other String"); } else { System.out.println("Your string are not matched"); } } public static void main(String[] args) { java.util.Scanner sc = new java.util.Scanner(System.in); System.out.println("Enter the 1st String:"); String s1 = sc.nextLine(); System.out.println("Enter the 2nd string"); String s2 = sc.nextLine(); Match m = new Match(); m.comp(s1, s2); } }
answers question: http://stackoverflow.com/q/2612976

http://stackoverflow.com/a/2634727
type: Answer
has body: Interesting. I believe you are on the right track. Only that I would try to extend/modify the property tag so that the new behaviour is explicitly set in the jsp code. I mean, I would not like that each in the web app automatically gets the new behaviour, because perhaps there are some bean properties for which I want the original struts2 behaviour. I would prefer to have a new tag nane (eg: ... or something shorter) or a new attribute (eg ) Perhaps this helps: http://bodez.wordpress.com/2009/03/13/customising-struts2-jsp-tags/
score: 0
answers question: http://stackoverflow.com/q/2634004

http://stackoverflow.com/comment/2656353
type: QuestionComment
comment on: http://stackoverflow.com/q/2641624
has text: ehm ... self explainatory -.-
score: 1
type: Comment

http://stackoverflow.com/q/2688148
has title: Java Swing Table questions
has body: Hey guys, working on an event calendar. I'm having some trouble getting my column heads to display.. here is the code private JTable calendarTable; private DefaultTableModel calendarTableModel; final private String [] days = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; ////////////////////////////////////////////////////////////////////// /* Setup the actual calendar table */ calendarTableModel = new DefaultTableModel() { public boolean isCellEditable(int row, int col){ return false; } }; // setup columns for(int i = 0; i &lt; 7; i++) calendarTableModel.addColumn(days[i]); calendarTable = new JTable(calendarTableModel); calendarTable.getTableHeader().setResizingAllowed(false); calendarTable.getTableHeader().setReorderingAllowed(false); calendarTable.setColumnSelectionAllowed(true); calendarTable.setRowSelectionAllowed(true); calendarTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); calendarTable.setRowHeight(105); calendarTableModel.setColumnCount(7); calendarTableModel.setRowCount(6); Also, Im sort of new with tables.. how can I make the rowHeight split between the max size of the table?
has comment: http://stackoverflow.com/comment/2709072
downvote count: 0
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/2688365
has comment: http://stackoverflow.com/comment/2709101
has comment: http://stackoverflow.com/comment/2709115
type: AnsweredQuestion
score: 1
tagged with: java
accepted answer: http://stackoverflow.com/a/2688365
upvote count: 1
tagged with: swing
type: Question
has comment: http://stackoverflow.com/comment/2709105

http://stackoverflow.com/q/2730183
downvote count: 0
tagged with: applet
favorite count: 0
has answer: http://stackoverflow.com/a/2730303
upvote count: 6
type: AnsweredQuestion
has title: What's wrong with my object tag to embed a Java Applet?
tagged with: java
accepted answer: http://stackoverflow.com/a/2730303
score: 6
type: Question
has body: Here is my object tag. &lt;object classid="java:my.full.class.Name.class" height="360" width="320"&gt; &lt;param name="type" value="application/x-java-applet"&gt; &lt;param name="archive" value="applets.jar"&gt; &lt;param name="file" value="/report_files/1-1272041330710YAIwK"&gt; &lt;param name="codebase" value="/applets"&gt; &lt;/object&gt; When I run this in firefox it just shows up with an Error, click for details. The java console shows absolutely nothing. And at the bottom of fire fox is says "Applet my.full.class.Name notloaded". The Name.class file is in the applets.jar file. I can type the URL /applets/applets.jar and access the jar file. So whats wrong? EDIT: I can access the param file as well, although I don't believe that is the issue. EDIT: I updated the tag because I noticed in my HTML logs it wasn't looking in the right place. Still nothing though
possible better answer: http://stackoverflow.com/a/6845945
has answer: http://stackoverflow.com/a/6845945
answer count: 2

http://stackoverflow.com/q/2696237
tagged with: protege
has title: Local & Remote OWL/SPARQL queries with Jena
has body: I want to create a simple application using Jena and SPARQL, that inserts, deletes, updates, and queries some OWL/RDF data. I worked on Protégé to create the ontology and noticed SPARQL in it, but I want to run SPARQL queries programatically with Jena in Java. I saw “Using Jena to create a SPARQL query on DBpedia” and I know how to use SPARQL with Jena, but I want to upload it to server or to work on localhost or whatever. SPARQL doesn't support operations like update or insert, but only querying. Are there any other languages/methods that support these operations, or should I manipulate data manually in java in each application? How can I upload my ontology, preferably with something related to Protégé? I tried Protege2Joseki but couldn't get it to work. Are RDF-stores just for RDF? I am working on OWL files. For example, if I am using MySQL as an RDF-store, would it also work for OWL concepts?
answer count: 1
accepted answer: http://stackoverflow.com/a/2872636
linked to: http://stackoverflow.com/q/2267333
tagged with: owl
tagged with: sparql
type: AnsweredQuestion
score: 0
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/2872636
tagged with: jena

http://stackoverflow.com/a/2663960
upvote count: 1
answers question: http://stackoverflow.com/q/2663941
has comment: http://stackoverflow.com/comment/2682037
has comment: http://stackoverflow.com/comment/2681870
has comment: http://stackoverflow.com/comment/2682020
downvote count: 0
has body: your if (stopPlayback == 1 ) will only be run once -- you'll have to enclose it in a while(true) loop to make sure it keeps being evaluated, make sure you add a pause as well otherwise you will burn a lot of unnecessary cycles. Update: I was assuming you ran a second thread to watch on the stopPlayback value - I now see this is not the case. Why don't you just call the c.stop() from your ActionListener?
type: Answer
score: 1
has comment: http://stackoverflow.com/comment/2682059

http://stackoverflow.com/a/2758556
has comment: http://stackoverflow.com/comment/2790257
answers question: http://stackoverflow.com/q/2758531
type: Answer
has comment: http://stackoverflow.com/comment/2790387
has comment: http://stackoverflow.com/comment/2790169
accepted answer of: http://stackoverflow.com/q/2758531
has comment: http://stackoverflow.com/comment/2790243
has comment: http://stackoverflow.com/comment/2790352
has comment: http://stackoverflow.com/comment/2790220
upvote count: 6
has comment: http://stackoverflow.com/comment/2790274
has comment: http://stackoverflow.com/comment/2790305
has body: What you are asking for is the instanceof operator. if (object instanceof SomeClass) { // do something } else if (object instanceof SomeOtherClass) { // do something else } However, this is not a good practice. Instead you may use the so called double-dispatch. Make the object that is passed conform to an interface which defines the operation in terms of the other class. So: public interface ThrowableItem { void throwAt(Wall wall); } public class Wall { void accept(ThrowableItem item) { item.throwAt(this); } } And then provide the appropriate implementations within Ball and Bomb (both of which implement ThrowableItem) Take a look at the Visitor pattern - you can move the operations to a WallVisitor which knows how to handle the colisions for each object.
has comment: http://stackoverflow.com/comment/2790488
type: AcceptedAnswer
downvote count: 0
score: 6

http://stackoverflow.com/comment/2718721
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2696496
score: 0
has text: Next time, give people examples of methods you already have attempted. It would appear more that you actually put in some efforts before you asked the question.

http://stackoverflow.com/comment/2738982
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/2713655
score: 1
has text: @jack, I think your first word was meant to be "split", yes?

http://stackoverflow.com/q/2694470
has comment: http://stackoverflow.com/comment/2716217
tagged with: random
score: 2
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2694516
possible better answer: http://stackoverflow.com/a/2694490
downvote count: 0
has answer: http://stackoverflow.com/a/2694523
favorite count: 0
type: Question
has comment: http://stackoverflow.com/comment/2716258
upvote count: 2
has answer: http://stackoverflow.com/a/2694482
has answer: http://stackoverflow.com/a/2694496
has comment: http://stackoverflow.com/comment/2716337
has answer: http://stackoverflow.com/a/2694516
has answer: http://stackoverflow.com/a/2694501
answer count: 7
has body: Here's my import statement: import java.util.*; Here it is in main: Random Rand = new Random() ; Here it is in a public void method : int a = 0 ; while (!done) { int a = Rand.nextInt(10) ; if (debug) stuff ; if (possibles[a]==1) done = true ; } Here's the error message i get: TicTacToe.java:85: cannot find symbol symbol : method nextInt(int) location: class Rand a = Rand.nextInt(10) ; ^ Whats going wrong here? it seems like i've done everything right to me.
has title: Whats wrong with my Random?
tagged with: java
has answer: http://stackoverflow.com/a/2694490
has answer: http://stackoverflow.com/a/2694514

http://stackoverflow.com/a/2678381
has body: // getContent() returns the complete text to strip. // String s = getContent(); // Find the start of the XML content using the &lt;?xml prefix. // int xmlIndex = s.indexOf( "&lt;?xml" ); // Strip the non-XML header. // s = s.substring( xmlIndex ); // Find the last closing angle-bracket; should indicate end of the XML. // xmlIndex = s.lastIndexOf( "&gt;" ); // Strip everything after the closing angle-bracket. // s = s.substring( 0, xmlIndex );
type: AcceptedAnswer
type: Answer
score: 8
has comment: http://stackoverflow.com/comment/2698180
downvote count: 0
answers question: http://stackoverflow.com/q/2678299
upvote count: 8
accepted answer of: http://stackoverflow.com/q/2678299

http://stackoverflow.com/comment/2623944
comment on: http://stackoverflow.com/a/2612982
type: Comment
has text: they are, but in some cases it might be sufficient - I don't know whether his is such. That's why added the suggestion about a new class, where equals and hashcode are implemented properly.
type: AnswerComment
score: 0

http://stackoverflow.com/q/2652028
score: 1
has answer: http://stackoverflow.com/a/41254603
has body: I have the following situation: Label label = new Label(); label.setText("bla"); RoundedRectangle fig = new RoundedRectangle(); fig.add(label); FlowLayout layout = new FlowLayout(); layout.setStretchMinorAxis(true); fig.setLayoutManager(layout); fig.setOpaque(true); That works only to center the label vertical or horizontal by using layout.setHorizontal(true/false); , but not together. Any idea how to make it work ?
favorite count: 0
has title: How to center Label vertical and horizontal in draw2d Figure?
has answer: http://stackoverflow.com/a/2971613
type: Question
possible better answer: http://stackoverflow.com/a/41254603
accepted answer: http://stackoverflow.com/a/2971613
answer count: 2
upvote count: 1
tagged with: java
tagged with: figure
tagged with: draw2d
type: AnsweredQuestion
tagged with: layout
downvote count: 0

http://stackoverflow.com/q/2779067
has answer: http://stackoverflow.com/a/2779164
answer count: 5
accepted answer: http://stackoverflow.com/a/2779150
has comment: http://stackoverflow.com/comment/2813954
tagged with: immutability
tagged with: cloning
tagged with: linked-list
tagged with: defensive-copy
upvote count: 1
linked to: http://stackoverflow.com/q/279507
has comment: http://stackoverflow.com/comment/2813936
has comment: http://stackoverflow.com/comment/2813801
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/2326758
has comment: http://stackoverflow.com/comment/2813970
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/2779150
has comment: http://stackoverflow.com/comment/2813945
linked to: http://stackoverflow.com/q/2597965
type: Question
has answer: http://stackoverflow.com/a/2779188
has title: LinkedList insert tied to inserted object
downvote count: 0
has answer: http://stackoverflow.com/a/2779111
has comment: http://stackoverflow.com/comment/2813928
favorite count: 0
has answer: http://stackoverflow.com/a/2779123
possible better answer: http://stackoverflow.com/a/2779164
has body: I have code that looks like this: public class Polynomial { List&lt;Term&gt; term = new LinkedList&lt;Term&gt;(); and it seems that whenever I do something like term.add(anotherTerm), with anotherTerm being... another Term object, it seems anotherTerm is referencing the same thing as what I've just inserted into term so that whenever I try to change anotherTerm, term.get(2) (let's say) get's changed too. How can I prevent this from happening? Since code was requested: //since I was lazy and didn't want to go through the extra step of Polynomial.term.add public void insert(Term inserting) { term.add(inserting); } Code calling the insert method: poly.insert(anotherTerm); Code creating the anotherTerm Term: Term anotherTerm = new Term(3, 7.6); //sets coefficient and power to 3 and 7.6 New code calling the insert method: poly.insert((Term)anotherTerm.clone()); Which unfortunately still doesn't work due to clone() has protected access in java.lang.Object, even after doing public class Term implements Cloneable{

http://stackoverflow.com/a/50506202
has body: I used to have the same purpose as yours, then made a function powered by Java reflection for solving that. Guess I can help you. /** * author: Amo * to use auto-gen SQL create command to create a table having columns named same as the name of model fields */ public void setSQLCreateCmd(Class&lt;?&gt; clazz) { Field[] fields = clazz.getDeclaredFields(); String fieldName; Class&lt;?&gt; fieldType; int fieldCount = fields.length; Log.d("[DEBUG]", "... fieldCount:" + fieldCount); int i = 0; DATABASE_CMD = "create table if not exists " + DATABASE_NAME + "(" + "_id integer primary key autoincrement, "; for (Field field : fields) { if (!field.isAccessible()) field.setAccessible(true); fieldName = field.getName(); fieldType = field.getType(); if (fieldName.compareTo("") == 0) { Logger.d("!!! field name is empty"); continue; } if (i == fieldCount - 1) { Logger.d("... field at " + (i+1) + "named " + fieldName); if (fieldType.equals(String.class)) DATABASE_CMD += fieldName + " text" + ")"; else if (fieldType.equals(int.class) || fieldType.equals(Integer.class)) DATABASE_CMD += fieldName + " integer" + ")"; } else { Logger.d("... field at " + (i+1) + "named " + fieldName); if (fieldType.equals(String.class)) DATABASE_CMD += fieldName + " text" + ","; else if (fieldType.equals(int.class) || fieldType.equals(Integer.class)) DATABASE_CMD += fieldName + " integer" + ","; } i++; } /** * fixes fieldCount is not as same as the defined */ StringBuilder stringBuilder = new StringBuilder(DATABASE_CMD); stringBuilder.setCharAt(stringBuilder.lastIndexOf(","), ')'); DATABASE_CMD = stringBuilder.toString(); Log.d("[DEBUG]", "... now sql cmd is " + DATABASE_CMD); Logger.d("... now sql cmd is " + DATABASE_CMD); } Any comment is welcome and happy coding.
answers question: http://stackoverflow.com/q/2685404
score: 0
type: Answer

http://stackoverflow.com/comment/2729133
has text: @igouy: I don't know what it means exactly, the quote comes from the Go website. (I think their goal is to get within 20% of C's speed for systems-oriented stuff.)
score: 0
type: Comment
comment on: http://stackoverflow.com/q/2704417
type: QuestionComment

http://stackoverflow.com/a/2740132
accepted answer of: http://stackoverflow.com/q/2740059
type: Answer
answers question: http://stackoverflow.com/q/2740059
has body: Determine the aspect ratio of both (height divided by width, say, so tall, skinny rectangles have an aspect ratio > 1). If your rectangle's aspect ratio is greater than that of your image, then scale the image uniformly based on the widths (rectangle width / image width). If your rectangle's aspect ratio is less than that of your image, then scale the image uniformly based on the heights (rectangle height / image height).
score: 16
upvote count: 16
has comment: http://stackoverflow.com/comment/2769029
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/2616473
type: Answer
upvote count: 5
has body: Have you at least tried with nimbus look'n'feel? that is a little bit better than the others.. UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); only downside is that it requires at least Java6 update 10.
downvote count: 0
score: 5
answers question: http://stackoverflow.com/q/2616448

http://stackoverflow.com/comment/126844169
type: AnswerComment
score: 0
type: Comment
has text: @Abhinav or if a balanced BST is used for searching, then at each insertion O(logn), the tree is already incrementally sorted, then a lookup O(logn) should add no cost to it, this for n elements time = O(n*(logn + logn)) = O(n*2logn) = O(nlogn). So yes it is feasible!
comment on: http://stackoverflow.com/a/3312392

http://stackoverflow.com/q/2607019
has answer: http://stackoverflow.com/a/2607101
type: Question
tagged with: jakarta-ee
accepted answer: http://stackoverflow.com/a/2607101
downvote count: 0
possible better answer: http://stackoverflow.com/a/2607047
has answer: http://stackoverflow.com/a/2607117
upvote count: 3
answer count: 3
has title: ThreadLocal (and Singleton) in EJB Container
favorite count: 0
tagged with: ejb-3.0
tagged with: multithreading
has answer: http://stackoverflow.com/a/2607047
tagged with: thread-local
type: AnsweredQuestion
score: 3
has body: I've written an authorization system which relies on objects representing the current user. To simplify programming and increase performance I want to hold those objects in a ThreadLocal after the user has logged in. It looks like this: public class UserCache { private static final ThreadLocal&lt;User&gt; cache = new ThreadLocal&lt;User&gt;(); public User getCurrentUser() { return cache.get(); } public void setCurrentUser(User user) { cache.set(user); } } I've read that static elements make clustering problematic. If I had an UserCache on each cluster node, they all had their own cache object not synchronized with the cache objects on other nodes. Right? UserCache is a classic candidate for a singleton, because the application needs only a single instance of it. But as far as I know @Singleton EJBs have the same behaviour in a cluster. So what to do to make UserCache clusterable in an EJB 3.1 (Java EE 6) environment? Solutions extracted from the answers: Using SessionScope from CDI (JSR 299) or Using JVM clustering with Terracotta
tagged with: java

http://stackoverflow.com/comment/2643396
score: 0
type: AnswerComment
has text: Thanks for your reply. I added a section to my question to answer your questions.
type: Comment
comment on: http://stackoverflow.com/a/2629708

http://stackoverflow.com/a/2723136
type: Answer
score: 2
has body: You have write method for HTML and RTF from StyledEditorKit. See HTMLEditorKit.write and RTFEditorKit
upvote count: 2
accepted answer of: http://stackoverflow.com/q/2723073
answers question: http://stackoverflow.com/q/2723073
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2751841

http://stackoverflow.com/q/2740068
has answer: http://stackoverflow.com/a/2746155
possible better answer: http://stackoverflow.com/a/2740653
accepted answer: http://stackoverflow.com/a/2746155
has title: How can I make Swig correctly wrap a char* buffer that is modified in C as a Java Something-or-other?
favorite count: 0
answer count: 3
has answer: http://stackoverflow.com/a/11507237
has comment: http://stackoverflow.com/comment/2769049
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2740653
type: Question
tagged with: swig
upvote count: 9
tagged with: java-native-interface
tagged with: java
tagged with: http://stackoverflow.com/tag/c
has comment: http://stackoverflow.com/comment/2769402
has body: I am trying to wrap some legacy code for use in Java and I was quite happy to see that Swig was able to handle the header file and it generate a great wrapper that almost works. Now I am looking for the deep magic that will make it really work. In C I have a function that looks like this DLL_IMPORT int DustyVoodoo(char *buff, int len, char *curse); This integer returned by this function is an error code in case it fails. The arguments are buff is a character buffer len is the length of the data in the buffer curse the another character buffer that contains the result of calling DustyVoodoo So, you can see where this is going, the result is actually coming back via the third argument. Also len is confusing since it may be the length of both buffers, they are always allocated as being the same size in calling code but given what DustyVoodoo does I don't think that they need be the same. To be safe both buffers should be the same size in practice, say 512 chars. The C code generated for the binding is as follows: SWIGEXPORT jint JNICALL Java_pemapiJNI_DustyVoodoo(JNIEnv *jenv, jclass jcls, jstring jarg1, jint jarg2, jstring jarg3) { jint jresult = 0 ; char *arg1 = (char *) 0 ; int arg2 ; char *arg3 = (char *) 0 ; int result; (void)jenv; (void)jcls; arg1 = 0; if (jarg1) { arg1 = (char *)(*jenv)-&gt;GetStringUTFChars(jenv, jarg1, 0); if (!arg1) return 0; } arg2 = (int)jarg2; arg3 = 0; if (jarg3) { arg3 = (char *)(*jenv)-&gt;GetStringUTFChars(jenv, jarg3, 0); if (!arg3) return 0; } result = (int)PemnEncrypt(arg1,arg2,arg3); jresult = (jint)result; if (arg1) (*jenv)-&gt;ReleaseStringUTFChars(jenv, jarg1, (const char *)arg1); if (arg3) (*jenv)-&gt;ReleaseStringUTFChars(jenv, jarg3, (const char *)arg3); return jresult; } It is correct for what it does; however, it misses the fact that cursed is not just an input, it is altered by the function and should be returned as an output. It also does not know that the java Strings are really buffers and should be backed by a suitably…
score: 9
downvote count: 0

http://stackoverflow.com/q/2604875
has answer: http://stackoverflow.com/a/2605337
has title: spring - @ContextConfiguration fail to load config file in src/test/resources
downvote count: 0
has body: I've tried to load the spring config file in src/test/resources classpath with the following abstract class: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations={"classpath:/applicationContext.xml"}) public class BaseIntegrationTests { } I have the applicationContext.xml file in src/test/resources but spring cant load it. Thank you.
linked to: http://stackoverflow.com/q/10385452
has answer: http://stackoverflow.com/a/4188042
score: 27
has comment: http://stackoverflow.com/comment/24436469
tagged with: junit
answer count: 7
has answer: http://stackoverflow.com/a/2607409
tagged with: maven-2
favorite count: 0
accepted answer: http://stackoverflow.com/a/2607409
tagged with: spring
type: AnsweredQuestion
tagged with: junit4
has comment: http://stackoverflow.com/comment/2614749
has answer: http://stackoverflow.com/a/2885002
has answer: http://stackoverflow.com/a/44314996
tagged with: java
has answer: http://stackoverflow.com/a/17474839
has comment: http://stackoverflow.com/comment/2617555
has answer: http://stackoverflow.com/a/23649892
type: Question
upvote count: 27
linked to: http://stackoverflow.com/q/3294423
possible better answer: http://stackoverflow.com/a/17474839

http://stackoverflow.com/comment/2659878
type: Comment
score: 0
comment on: http://stackoverflow.com/a/2644801
type: AnswerComment
has text: i am asking about volatile, not static...Static anyways work fine with or without volatile

http://stackoverflow.com/q/2631686
tagged with: android
tagged with: hashtable
has title: Android Hashtable Serialization
has answer: http://stackoverflow.com/a/5015612
type: Question
score: 3
tagged with: java
upvote count: 3
answer count: 2
has body: I am having a weird issue with serialization of a Hashtable. I have made a Server, Client app. Where server(PC/MAC) is serializing a Hashtable and sending it to Client(Android) through UDP. The data is sent/read correctly but I get a bunch of these messages below on LogCat. 04-12 11:19:43.059: DEBUG/dalvikvm(407): GetFieldID: unable to find field Ljava/util/Hashtable;.loadFactor:F Occasionally, I would see these 04-12 11:21:19.150: DEBUG/dalvikvm(407): GC freed 10814 objects / 447184 bytes in 97ms The app would run for 2-3 mins and then crash. Interestingly enough I do not see the Loadfactor errors on SDK 1.5. But I do see the GC Free xxxx objects, quiet often. After debugging I have found that the issue is with de-serialization and the error/warning are coming from following code Code: ByteArrayInputStream bis = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bis); object = ois.readObject(); at Code: object = ois.readObject(); on the client. My server is serializing code is the following. Code: ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(obj); Any idea what is going on? Thanks for the Help!
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2632737
tagged with: serialization
type: UnansweredQuestion

http://stackoverflow.com/a/2713493
downvote count: 0
score: 7
has comment: http://stackoverflow.com/comment/2738442
has comment: http://stackoverflow.com/comment/2738411
has body: The threadsafety is not the issue here. All looks syntactically and functionally fine and it should work for about half a hour. Leaking of resources is however the real issue here. The application will crash after about half a hour because you never close them after use. The database will in turn sooner or later close the connection itself so that it can claim it back. That said, you don't need to worry about caching of preparedstatements. The JDBC driver and the DB will take care about this task. Rather worry about resource leaking and make your JDBC code as solid as possible. public class ThreadedTask implements runnable { public run() { Connection connection = null; Statement statement = null; try { connection = DriverManager.getConnection(url); statement = connection.prepareStatement(sql); // ... } catch (SQLException e) { // Handle? } finally { if (statement != null) try { statement.close(); } catch (SQLException logOrIgnore) {} if (connection != null) try { connection.close(); } catch (SQLException logOrIgnore) {} } } } To improve connecting performance, make use of a connection pool like c3p0 (this by the way does not mean that you can change the way how you write the JDBC code; always acquire and close the resources in the shortest possible scope in a try-finally block).
upvote count: 7
answers question: http://stackoverflow.com/q/2713407
has comment: http://stackoverflow.com/comment/61824057
type: Answer

http://stackoverflow.com/q/2703584
has answer: http://stackoverflow.com/a/2704037
tagged with: type-erasure
upvote count: 3
tagged with: conventions
type: Question
has title: Designing constructors around type erasure in Java
has answer: http://stackoverflow.com/a/2703600
tagged with: java
answer count: 3
has body: Yesterday, I was designing a Java class which I wanted to be initalized with Lists of various generic types: TheClass(List&lt;String&gt; list) { ... } TheClass(List&lt;OtherType&gt; list) { ... } This will not compile, as the constructors have the same erasure. I just went with factory methods differentiated by their names instead: public static TheClass createWithStrings(List&lt;String&gt; list) public static TheClass createWithOtherTypes(List&lt;OtherType&gt; list) This is less than optimal, as there isn't a single obvious location where all the different options for creating instances are available. I tried to search for better design ideas, but found surprisingly few results. What other patterns exist for designing around this problem?
score: 3
downvote count: 0
has answer: http://stackoverflow.com/a/8243725
favorite count: 0
type: UnansweredQuestion

http://stackoverflow.com/q/2747721
has answer: http://stackoverflow.com/a/2747889
has answer: http://stackoverflow.com/a/2748514
has answer: http://stackoverflow.com/a/2747773
type: AnsweredQuestion
tagged with: oop
has answer: http://stackoverflow.com/a/2747744
has answer: http://stackoverflow.com/a/2751158
tagged with: java
has answer: http://stackoverflow.com/a/2751161
has answer: http://stackoverflow.com/a/2747776
has answer: http://stackoverflow.com/a/2747746
downvote count: 3
has answer: http://stackoverflow.com/a/25866654
has comment: http://stackoverflow.com/comment/2777404
possible better answer: http://stackoverflow.com/a/2747773
linked to: http://stackoverflow.com/q/1568091
has body: Getters and Setters are bad Briefly reading over the above article I find that getters and setters are bad OO design and should be avoided as they go against Encapsulation and Data Hiding. As this is the case how can it be avoided when creating objects and how can one model objects to take this into account. In cases where a getter or setter is required what other alternatives can be used? Thanks.
has comment: http://stackoverflow.com/comment/124518410
type: Question
tagged with: c#
has answer: http://stackoverflow.com/a/2748554
duplicate of: http://stackoverflow.com/q/1568091
has answer: http://stackoverflow.com/a/4064830
tagged with: encapsulation
has answer: http://stackoverflow.com/a/2748305
has title: Getters and Setters are bad OO design?
answer count: 13
score: 36
accepted answer: http://stackoverflow.com/a/2747746
has comment: http://stackoverflow.com/comment/2778049
linked to: http://stackoverflow.com/q/565095
has comment: http://stackoverflow.com/comment/2777435
favorite count: 0
has answer: http://stackoverflow.com/a/2748327
upvote count: 39
has comment: http://stackoverflow.com/comment/2777440

highest
tag name: highest
tags question: http://stackoverflow.com/q/2625229
type: Tag

http://stackoverflow.com/q/2638705
has body: I am writing a simple web server in java as an exercise. When I run the program it immediately starts into an infinite loop outputting "Error: null" into the console. I have a few try/catch statements that do System.out.println("Error: " + e.getMessage()); I tried using the eclipse debugger to figure out where it starts, but when I run it in the debugger, it acts normally. Heres the two relevant clips of code: public void run() { // Declare server socket ServerSocket serversocket = null; try { // Initialize serversocket on the port passed to // the constructor serversocket = new ServerSocket(port); System.out.println("Server started on port " + Integer.toString(port)); } catch (Exception e) { System.out.println("Fatal Error: " + e.getMessage()); } while (true) { try { // Wait for connections Socket connectionsocket = serversocket.accept(); // Get client IP InetAddress client = connectionsocket.getInetAddress(); System.out.println(client.getHostName() + " connected."); // Read the request into a buffer BufferedReader input = new BufferedReader( new InputStreamReader(connectionsocket.getInputStream())); // Prepare the output stream for sending headers // and requested file to the client DataOutputStream output = new DataOutputStream(connectionsocket.getOutputStream()); http_handler(input, output); } catch (Exception e) { System.out.println("Error: " + e.getMessage()); } } } and private void http_handler(BufferedReader input, DataOutputStream output) { int method = 0; // 1 get, 2 head, 0 not supported String http = new String(); String path = new String(); String file = new String(); String user_agent = new String(); try { // Two types of requests we can handle: // Get /index.html HTTP/1.0 // HEAD /index.html HTTP/1.0 String tmp = input.readLine(); // Read from the stream String tmp2 = new String(tmp); tmp.toUpperCase(); if (tmp.startsWith("GET")) { method = 1; } if (tmp.startsWith("HEAD")) { method = 2; } if (method == 0) { try { // If the request is unsupported, send…
has comment: http://stackoverflow.com/comment/2653010
has comment: http://stackoverflow.com/comment/2653140
has title: Java: Infinite Error "null"
has comment: http://stackoverflow.com/comment/2653033
has comment: http://stackoverflow.com/comment/2653031
has answer: http://stackoverflow.com/a/2639409
favorite count: 0
has comment: http://stackoverflow.com/comment/2653403
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/2639409
downvote count: 1
tagged with: http
possible better answer: http://stackoverflow.com/a/2638777
has comment: http://stackoverflow.com/comment/2653040
type: Question
has answer: http://stackoverflow.com/a/2638777
answer count: 2
tagged with: network-programming
upvote count: 0
score: -1

http://stackoverflow.com/a/41741857
downvote count: 0
type: Answer
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/2761618
has body: The maximum number of request processing threads to be created by this Connector, which therefore determines the maximum number of simultaneous requests that can be handled. If not specified, this attribute is set to 200. If an executor is associated with this connector, this attribute is ignored as the connector will execute tasks using the executor rather than an internal thread pool. Note that if an executor is configured any value set for this attribute will be recorded correctly but it will be reported (e.g. via JMX) as -1 to make clear that it is not used.

http://stackoverflow.com/comment/3308172
has text: Last time I created a google account, I actually had to call a phone number to verify my humanity. I don't think you could automate something like that very easily.
type: AnswerComment
comment on: http://stackoverflow.com/a/2699134
type: Comment
score: 2

http://stackoverflow.com/comment/44380189
score: 0
type: Comment
has text: Cassandra supports counters (https://cassandra.apache.org/doc/cql3/CQL.html#counters), there are some limitations though.
type: AnswerComment
comment on: http://stackoverflow.com/a/5685869

http://stackoverflow.com/comment/15523790
type: Comment
comment on: http://stackoverflow.com/a/2663213
has text: Pascal, if that saying is true, then I have a lot of experience. Found a bug in my code that was bothering the heck out of me thanks to this answer.
type: AnswerComment
score: 0

http://stackoverflow.com/q/2775113
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/1254940
tagged with: sql
downvote count: 0
favorite count: 0
type: Question
has body: This is a very open question, but I think it can be very beneficial for SQL readability. So you have a Java program, and you are trying to call a monster SQL statement from it, with many subqueries and joins. The starting point for my question is a string constant like this: static string MONSTER_STATEMENT = "SELECT " + " fields" + "WHERE "+ " fieldA = (SELECT a FROM TableC) " + "AND fieldB IN (%s)" + "AND fieldC = %d " + "FROM " " tableA INNER JOIN tableB ON ..."; It later gets filled using String.format and executed. What are you tricks for making this kind of stuff readable? Do you separate your inner joins. Do you indent the SQL itself inside the string? Where do you put the comments? Please share all of the tricks in your arsenal.
score: 5
has comment: http://stackoverflow.com/comment/2810412
has comment: http://stackoverflow.com/comment/2809610
has title: How do you make long SQL invoked from other code readable?
tagged with: java
has comment: http://stackoverflow.com/comment/2809113
answer count: 3
has answer: http://stackoverflow.com/a/2775217
has comment: http://stackoverflow.com/comment/2809102
has comment: http://stackoverflow.com/comment/2809117
has answer: http://stackoverflow.com/a/2775157
tagged with: readability
has answer: http://stackoverflow.com/a/2775309
upvote count: 5
has comment: http://stackoverflow.com/comment/2810494

http://stackoverflow.com/a/2945316
downvote count: 0
answers question: http://stackoverflow.com/q/2602516
score: 5
has body: As mentioned Go and see http://www.forgerock.com/ they provide support and downloads for OpenSSO as OpenAM Video: http://www.youtube.com/watch?v=_o5ifx4euPw Also http://www.axiomatics.com/ is a good replacement.
upvote count: 5
type: Answer

http://stackoverflow.com/q/2706269
type: UnansweredQuestion
tagged with: irc
tagged with: shoutcast
tagged with: bots
tagged with: java
has title: Java Shoutcast Query
type: Question
has body: I have a Java IRC bot which i would like to query a shoutcast server and return basic information (song playing etc). Can someone guide me in the right direction? Thank you.
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/2706815

http://stackoverflow.com/a/3578720
answers question: http://stackoverflow.com/q/2660961
downvote count: 0
has body: This just happened to me. I had User Access Control (UAC) turned off when it happened (windows vista 32 bit). I turned UAC back on, rebooted vista and then the error went away. Counter intuitive that with UAC turned off, delete of the bin/net directory fails, but with UAC back on it works. Go figure.
type: Answer
score: 1
upvote count: 1

http://stackoverflow.com/comment/2739178
type: AnswerComment
has text: @Williham: engineering tasks are a good example for something where integral numbers are *worthless*, because engineers don't work only with sizes and everything at right angles, but also with forces, volumes, masses, voltages, and a host of other things at varying magnitudes. Doing that all in integers would be insane.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2714062

http://stackoverflow.com/a/2621634
type: Answer
answers question: http://stackoverflow.com/q/2621573
upvote count: 2
has body: From Statement javadocs: public ResultSet executeQuery(String sql) throws SQLException Returns: a ResultSet object that contains the data produced by the given query; never null So, you don't need to verify whether rs == null. The standard way to proceed resultset rows is: while (rs.next ()) { doSmth (rs); }
score: 2
downvote count: 0

http://stackoverflow.com/q/2657875
possible better answer: http://stackoverflow.com/a/2657898
type: Question
answer count: 2
has body: I have a class with the following declaration of the fields: public class Game { private static String outputFileName; .... } I set the value of the outputFileName in the main method of the class. I also have a write method in the class which use the outputFileName. I always call write after main sets value for outputFileName. But write still does not see the value of the outputFileName. It say that it's equal to null. Could anybody, pleas, tell me what I am doing wrong? ADDED As it is requested I post more code: In the main: String outputFileName = userName + "_" + year + "_" + month + "_" + day + "_" + hour + "_" + minute + "_" + second + "_" + millis + ".txt"; f=new File(outputFileName); if(!f.exists()){ try { f.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } System.out.println("IN THE MAIN!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); System.out.println("------&gt;" + outputFileName + "&lt;------"); This line outputs me the name of the file. Than in the write I have: public static void write(String output) { // Open a file for appending. System.out.println("==========&gt;" + outputFileName + "&lt;============"); ...... } And it outputs null.
has comment: http://stackoverflow.com/comment/2674827
has title: Why a "private static" is not seen in a method?
tagged with: private
score: 0
tagged with: visibility
has answer: http://stackoverflow.com/a/2657898
has comment: http://stackoverflow.com/comment/2674825
tagged with: static
tagged with: field
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/2657885
accepted answer: http://stackoverflow.com/a/2657885

http://stackoverflow.com/comment/2813348
has text: Most likely you'll want to handle this with a UNION or JOIN in the SQL used to create the ResultSets.
type: Comment
comment on: http://stackoverflow.com/q/2778672
score: 0
type: QuestionComment

http://stackoverflow.com/a/2774215
has body: You have a great tutorial HERE.
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2774195
upvote count: 3
score: 3

http://stackoverflow.com/a/2763462
has body: Another option is that something bad happened to your index - either it was built using a different version of Lucene, or a file is missing. Try opening the index using luke.
has comment: http://stackoverflow.com/comment/2795951
type: Answer
score: 0
answers question: http://stackoverflow.com/q/2763038

http://stackoverflow.com/q/2712880
possible better answer: http://stackoverflow.com/a/2712906
tagged with: java
has answer: http://stackoverflow.com/a/2712906
has body: I'm trying to handle an FileNotFoundException in Java by suspending the thread for x seconds and rereading the file. The idea behind this is to edit properties during runtime. The problem is that the programm simply terminates. Any idea how to realize this solution?
has answer: http://stackoverflow.com/a/2712892
accepted answer: http://stackoverflow.com/a/2712892
type: Question
upvote count: 2
favorite count: 0
has answer: http://stackoverflow.com/a/2712939
tagged with: properties
answer count: 4
has answer: http://stackoverflow.com/a/2712897
score: 2
downvote count: 0
has title: How to retry opening a properties file in Java
type: AnsweredQuestion
tagged with: filenotfoundexception

http://stackoverflow.com/comment/38859678
has text: If you are going front-end based view binding, why not try Angular JS ?
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/8977522
type: Comment

http://stackoverflow.com/a/2764517
type: Answer
has body: I don't know of any, but you should probably consider a more accessible alternative (non-image) like CSS 3 embedded fonts, which allow any fonts (even TTF, OTF and other common font formats) to be used in the page, while behaving like proper text. My website, http://azabani.com/ uses CSS3 embedded fonts, so check that out as an example.
answers question: http://stackoverflow.com/q/2764289
upvote count: 1
has comment: http://stackoverflow.com/comment/2940257
has comment: http://stackoverflow.com/comment/2805847
score: 1
downvote count: 0

http://stackoverflow.com/a/2669110
type: Answer
answers question: http://stackoverflow.com/q/2669015
score: 0
has comment: http://stackoverflow.com/comment/2687759
has body: When you open the file by passing a File object into the Print Writer you're essentially letting the PrintWriter govern how the file is opened (most likely Create) which deletes the existing file and readies a new one for a write. Because you never save (close the stream), any data buffered in the PrintWriter isn't outputted to the file. You need to refactor your file approach, if you use the File.Open(...) function you can specify an append session. FileStream outStream = File.Open(myFileName, FileMode.Append); PrintWriter pw = new PrintWriter(outStream); This way your file wont be cleared just by opening to it, and you may append to the end. Alternatively you can force the file to be cleared when you want it to be by opening it with FileMode.Create P.S. you should learn about the using block, it's very usefull.

http://stackoverflow.com/comment/2815760
type: Comment
score: 0
has text: But I still don't know how to do that. I'm lost and I can find anything above documentation of classes. This is so different from static functions. Any examples? I'm writing implementation of JPEG algorithm and I need to convert to YCbCr and separate channels before fragmentation. Now I'm working with many arrays and function. This is not so flexible as I want.
type: AnswerComment
comment on: http://stackoverflow.com/a/2780378

double
tags question: http://stackoverflow.com/q/2664284
tags question: http://stackoverflow.com/q/2733479
tag name: double
type: Tag
tags question: http://stackoverflow.com/q/2654839
tags question: http://stackoverflow.com/q/2781086
tags question: http://stackoverflow.com/q/2678985

http://stackoverflow.com/comment/2716427
has text: That is a flaw, definitely, but to be honest it doesn't matter. For this project, I know going into it that each Node will have a *distinct* `guid`. Plus, fixing that wouldn't solve my current problem, correct?
comment on: http://stackoverflow.com/a/2694591
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/2600050
upvote count: 2
type: Answer
score: 2
answers question: http://stackoverflow.com/q/2599993
downvote count: 0
has body: DR has the correct answer. Regarding the compiler warnings: hide() is a deprecated call belonging to Window. Don't ever use it, stick with setVisible().

http://stackoverflow.com/a/2709676
type: AcceptedAnswer
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/2762952
accepted answer of: http://stackoverflow.com/q/2706630
upvote count: 3
answers question: http://stackoverflow.com/q/2706630
score: 3
has comment: http://stackoverflow.com/comment/2764681
has body: I prefer to inject the Spring container into an applicationContext variable. Spring supports this with the ApplicationContextAware interface. Then it's easy to ask for a new bean from the code. An example: public class ContextAwareFactory implements ApplicationContextAware { private ApplicationContext applicationContext; public void setApplicationContext(ApplicationContext applicationContext) { this.applicationContext = applicationContext; } public String getConfigValue() { return (String)applicationContext.getBean("config-value"); } }

http://stackoverflow.com/a/2599648
upvote count: 1
answers question: http://stackoverflow.com/q/2599623
downvote count: 0
type: Answer
has body: You can not assign to subtype from super type, but you can implement a Copy Constructor, then you could do the same thing like this: MyCollection myCollection = new MyCollection(somehandler.getCollection()); Edit: the type of the parameter to the constructor could be for example List.
score: 1

http://stackoverflow.com/comment/2718922
has text: So, I understand what you're saying, but Eclipse is confusing me on this one. When I view my Installed JREs I see only "jre6" which, if I click on "Edit..." shows that it includes the rt.jar file. So the classes I want to utilize (specifically those in the javax.xml.soap and other various packages) should already be in the JRE. However, when I import these packages, Eclipse can't find them...then if I add that same rt.jar file to the build path Eclipse can magically find them. Here is a video I recorded illustrating what's happening: http://www.youtube.com/watch?v=gst53v9DLmQ
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2696497
type: AnswerComment

http://stackoverflow.com/comment/2773944
has text: Thank you. I had not thought of that.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2740774
type: AnswerComment

http://stackoverflow.com/comment/2732290
has text: Why wouldn't it help? I mean if the last example would be guarded like the first example, wouldn't it be safe even from ThreadDeath error?
comment on: http://stackoverflow.com/a/2708270
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/2610540
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2599948
has text: I saved the file as UTF-8 and UTF-8, No BOM. Both times I get the same error.
score: 0

http://stackoverflow.com/a/2649416
has comment: http://stackoverflow.com/comment/2665514
score: 0
type: Answer
answers question: http://stackoverflow.com/q/2649375
has comment: http://stackoverflow.com/comment/2665552
has body: Here's a suggestion A.onNewEvent(){ //create job //ask B to do it B.do() } B.do{ // Do some stuff A.onJobDone() } A.onJobDone(){ // print message "Thank you for doing it" (B.do() has just completed, so it //will print for every time you call B.do() if (shouldDoJobAgain()) //it should stop some time, right? B.do() }

http://stackoverflow.com/a/2780702
has comment: http://stackoverflow.com/comment/8742736
type: Answer
has comment: http://stackoverflow.com/comment/8769993
has comment: http://stackoverflow.com/comment/8770475
has body: It's a bad practice, since you cannot be sure that the object is fully initialized. Even if you call the start() method at the end of the constructor it may result in a mess. Be aware that the processor can do things out of order: 1: MyObject(){ 2: aVariable = anyValue; 3: this.start(); 4: } The processor is free to execute line 3 before line 2 since they aren't related (in a single threaded fashion), so you could end up with uninitalized variables (even final ones), and other unexpected stuff.
has comment: http://stackoverflow.com/comment/8770026
upvote count: 2
score: 1
answers question: http://stackoverflow.com/q/2780255
downvote count: 1
has comment: http://stackoverflow.com/comment/8765653
has comment: http://stackoverflow.com/comment/8770970
has comment: http://stackoverflow.com/comment/8805115

http://stackoverflow.com/q/2662750
score: 1
accepted answer: http://stackoverflow.com/a/2662790
has title: Check if system tray focused in Java?
favorite count: 0
has body: I have a Java app that has an icon in the system tray. How can I check if the tray (or tray icon) has current focus? Tray and TrayIcon don't seem to have .isFocused() or similar. Is this possible? Thanks!
upvote count: 1
tagged with: swing
has answer: http://stackoverflow.com/a/2662790
type: AnsweredQuestion
tagged with: java
type: Question
answer count: 1
downvote count: 0

http://stackoverflow.com/comment/2659972
comment on: http://stackoverflow.com/a/2644913
type: AnswerComment
type: Comment
has text: I'd *guess* (even though guessing is not a good idea here) that the resulting "ideal number" will be mostly independent from the number of CPUs/Cores available and depend a lot more on I/O- and Network-performance.
score: 1

http://stackoverflow.com/q/2765704
has answer: http://stackoverflow.com/a/2765721
has answer: http://stackoverflow.com/a/2765727
tagged with: file-io
tagged with: exception
has answer: http://stackoverflow.com/a/2765792
has answer: http://stackoverflow.com/a/2767865
has answer: http://stackoverflow.com/a/2765774
score: 24
has body: Has anyone ever seen an exception thrown when calling close method on any closable object?
has answer: http://stackoverflow.com/a/4620994
has answer: http://stackoverflow.com/a/2765738
upvote count: 24
has answer: http://stackoverflow.com/a/2767916
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2765774
possible better answer: http://stackoverflow.com/a/2765738
tagged with: java
type: Question
answer count: 8
has title: Have you ever seen a Java File close() throw an exception?
downvote count: 0
favorite count: 0

http://stackoverflow.com/a/16768351
has body: directly from this java oracle tutorial: When a thread invokes d.wait, it must own the intrinsic lock for d — otherwise an error is thrown. Invoking wait inside a synchronized method is a simple way to acquire the intrinsic lock.
type: Answer
upvote count: 4
downvote count: 4
has comment: http://stackoverflow.com/comment/24167208
score: 0
answers question: http://stackoverflow.com/q/2779484

http://stackoverflow.com/a/2646843
type: AcceptedAnswer
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2646613
upvote count: 7
accepted answer of: http://stackoverflow.com/q/2646613
score: 7
has body: Here's one option. It's a bit ugly, but allows you to scope the the suppressed warning to only that individual operation. Add a function which does the unchecked cast, and suppress warnings on it: @SuppressWarnings("unchecked") private final static Map&lt;Object,Object&gt; asMap(JSONObject j) { return j; } Then you can call it without compiler warnings: asMap(jsonobj).put("this", "that"); This way, you can be sure that you aren't suppressing any warnings that you actually want to see.
has comment: http://stackoverflow.com/comment/22494671

java-native-interface
tags question: http://stackoverflow.com/q/2702132
tags question: http://stackoverflow.com/q/2648877
tags question: http://stackoverflow.com/q/2617313
tags question: http://stackoverflow.com/q/2735073
type: Tag
tags question: http://stackoverflow.com/q/2623277
tag name: java-native-interface
tags question: http://stackoverflow.com/q/2673839
tags question: http://stackoverflow.com/q/2651964
tags question: http://stackoverflow.com/q/2630529
tags question: http://stackoverflow.com/q/2762916
tags question: http://stackoverflow.com/q/2644167
tags question: http://stackoverflow.com/q/2599536
tags question: http://stackoverflow.com/q/2642371
tags question: http://stackoverflow.com/q/2714311
tags question: http://stackoverflow.com/q/2748480
tags question: http://stackoverflow.com/q/2732269
tags question: http://stackoverflow.com/q/2740068

http://stackoverflow.com/comment/96743916
type: Comment
has text: @igouy I concede that that is an error I probably made - when I saw load, I was interpreting in 'system load' terms, and assuming, user/system/io/idle - my mistake, and it was a substantial one.
comment on: http://stackoverflow.com/a/52325174
score: 1
type: AnswerComment

http://stackoverflow.com/comment/2793281
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/2709249
has text: Loch Ness monser is 20 years old? ha
type: Comment

http://stackoverflow.com/comment/2816760
comment on: http://stackoverflow.com/a/2775157
has text: @Artem: You can still use an ad hoc `PreparedStatement`, can't you? As long as **you** control the text that varies, things aren't bad. The real problem is when users can inject their own text which is rendered as in-line sql.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/2632400
upvote count: 2
downvote count: 1
has body: i think you will get the answer here : http://www.jugpadova.it/articles/2005/11/13/from-which-jar-a-class-was-loaded http://www.techtalkz.com/java/102114-how-find-jar-file-ava-class-all-successorshad-been-loaded.html
answers question: http://stackoverflow.com/q/2632362
type: Answer
score: 1

http://stackoverflow.com/comment/2702985
has text: I guess I'll give my own handling a shot. Although that sounds like a lot of work keeping track of the number of threads and all. Also, it still requires sleep moments to wait for threads to end. Is there a way to "wait" for several threads without ThreadPool?
score: 0
comment on: http://stackoverflow.com/a/2683156
type: Comment
type: AnswerComment

http://stackoverflow.com/q/2619189
possible better answer: http://stackoverflow.com/a/2622563
has comment: http://stackoverflow.com/comment/2631524
has answer: http://stackoverflow.com/a/2622563
has comment: http://stackoverflow.com/comment/2631428
answer count: 4
has comment: http://stackoverflow.com/comment/2648935
has body: We want to rewrite kodingen.com backend with Go which currently is Java, running as daemon using jsvc. I have never touched any C in my life, am only experienced in Java so I don't know if this is something that I should even start. However, task is pretty simple read shell commands from mysql database queue and execute them in parallel save each shell output to the database that's it. So these simple requirements gives me hope that I can start using this wonderful language. What would you advise? Is C still better ?
has comment: http://stackoverflow.com/comment/2631304
accepted answer: http://stackoverflow.com/a/2622454
upvote count: 7
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2631493
has title: Porting Java app to Go - any advice?
has answer: http://stackoverflow.com/a/2623670
score: 7
tagged with: java
tagged with: http://stackoverflow.com/tag/c
has comment: http://stackoverflow.com/comment/2631472
type: Question
downvote count: 0
has answer: http://stackoverflow.com/a/2622759
has answer: http://stackoverflow.com/a/2622454
favorite count: 0
has comment: http://stackoverflow.com/comment/2631533
has comment: http://stackoverflow.com/comment/2631415
tagged with: go

http://stackoverflow.com/comment/2658717
type: Comment
type: QuestionComment
has text: you have provided code that is totally irrelevant. Tell us how are you obtaining the uploaded item.
score: 0
comment on: http://stackoverflow.com/q/2643744

http://stackoverflow.com/a/2770860
answers question: http://stackoverflow.com/q/2768903
upvote count: 5
downvote count: 0
has body: Well, do what you should have a long time before, separate implementation and API ... ok, this is not always that easy on existing systems but that model has a huge bang for your buck. Once your API is in a separate (much more stable) bundle/jar you can compile the clients and implementations against that bundle/jar. One of the key qualities of a successful bundle is that it makes as little assumptions about the outside world as possible. This implies you do not have to compile against the bundles you run against in runtime, I have a preference to try hard to not do that. You should only compile against the bundles minimum set of dependencies. If assumptions are made they are explicit as imported packages and the use of services. Well designed OSGi systems attempt to use services for all inter-bundle communications. Not only does this model get rid of class loading issues it also makes your build setup more decoupled. Unfortunately most code is written as libraries that have a rather wide interface because they hand code lots of the functionality that services provide out of the box like Factories and Listeners. This code has a tight relationship between implementation and API so you have to have the same on the class path during compile and in OSGi. One solution to this problem is to include this kind of code inside the bundle using it (but make sure no objects of this library leak to other bundles). A bit of extra memory consumption but it saves you from some headaches. So with OSGi, try to create systems relying on services and compile against their service API, not an implementation bundle.
score: 5
type: Answer

http://stackoverflow.com/q/2685907
tagged with: plugins
has body: i am using ResourceBundle and I want to give the user an option to select a language for the GUI. i want to get a list of all resource files that are under a specific package. i don't know what resources I will have since this application is based on plug-ins. Is there an option to ask from java to search all available resources under a package? (if no i guess the plug-in should give all available local for it) thank you all
type: AnsweredQuestion
tagged with: java
score: 7
upvote count: 8
type: Question
tagged with: resourcebundle
has title: List all available ResourceBundle Files
answer count: 1
downvote count: 1
has answer: http://stackoverflow.com/a/2686428
accepted answer: http://stackoverflow.com/a/2686428
favorite count: 0

http://stackoverflow.com/a/14597381
type: Answer
downvote count: 0
score: 10
has comment: http://stackoverflow.com/comment/20379293
answers question: http://stackoverflow.com/q/2622062
upvote count: 10
has body: cd "Your File Location without inverted commas" example : cd C:\Users*****\Desktop\directory\target java -jar myjar.jar example bat file looks like this: @echo OFF cd C:\Users\****\Desktop\directory\target java -jar myjar.jar This will work fine.

http://stackoverflow.com/a/2724108
answers question: http://stackoverflow.com/q/2618517
downvote count: 0
has body: The basic approach is this: collect your audio data that you want to display. This may be the raw audio samples or may be the result of processing (e.g. averaging across N samples, or taking every Nth sample) to provide scaling on the x-axis. (Without scaling, you will need 48000 pixels to display 1 second of audio.) Given this array of samples, you have to turn it into a aplitude-time plot. As a start you can create a new JPanel and override the paint method to draw the plot. E.g. public void paint(Graphics g) { short[] samples; // the samples to render - get this from step 1. int height = getHeight(); int middle = height/2; for (int i=0; i&lt;samples.length; i++) { int sample = samples[i]; int amplitude = sample*middle; g.drawLine(i, middle+amplitide, i, middle-amplitude); } } This will draw a amplitude-time graph in your component. it will be as heigh as the component, and as wide as the number of samples. To get animation, you regularly drop in a new short[] array into the component and call repaint() (All on the Swing Event thread, of course!). Good luck!
type: Answer
upvote count: 3
score: 3

http://stackoverflow.com/q/2602527
has answer: http://stackoverflow.com/a/2602712
has answer: http://stackoverflow.com/a/2602544
upvote count: 2
answer count: 5
tagged with: google-app-engine
has body: According to this discussion of Google App Engine on Hacker News, A DB (read) request takes over 100ms on the datastore. That's insane and unusable for about 90% of applications. How do you determine what is an acceptable response time for a DB read request? I have been using App Engine without noticing any issues with DB responsiveness. But, on the other hand, I'm not sure I would even know what to look for in that regard :)
tagged with: python
has comment: http://stackoverflow.com/comment/2613049
type: AnsweredQuestion
tagged with: java
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/2605848
has comment: http://stackoverflow.com/comment/2612030
tagged with: database
possible better answer: http://stackoverflow.com/a/2605080
has answer: http://stackoverflow.com/a/2605080
has answer: http://stackoverflow.com/a/2602798
has title: How do you determine an acceptable response time for App Engine DB requests?
tagged with: response-time
score: 1
has comment: http://stackoverflow.com/comment/2612220
favorite count: 0
accepted answer: http://stackoverflow.com/a/2605848

http://stackoverflow.com/comment/2722755
score: 1
type: AnswerComment
has text: @Walter White Email is not a guaranteed delivery system. If you must deliver this email then you have several options. 1) Post it on your web site and let the person sign in and see any updates th their account. 2) Put an URL in your email to have them click if they received the mail, if not keep sending on a periodic basis. Still not guaranteed, you just know when the got it. 3) Send a letter with the email (Let's say it is account information from a bank) The letter can be registered if needed. 2)
type: Comment
comment on: http://stackoverflow.com/a/2699462

http://stackoverflow.com/a/4275135
answers question: http://stackoverflow.com/q/2636952
has body: Nick, that is not quite right. You can securely stream video with Amazons protected Flash rtmp video streaming service, using Cloudfront. Nobody will be able to download your files. There are tutorials about how to do it on the net. For instance here. You can also go straight to the cloudfront documentation. (Can't post the link here as I'm new to SO and can only post one link).
score: 0
type: Answer

http://stackoverflow.com/a/46058441
upvote count: 4
downvote count: 0
score: 4
answers question: http://stackoverflow.com/q/2607289
has body: I've had the same problem and wrote a generic function that takes an array and returns an ArrayList of the same type with the same contents: public static &lt;T&gt; ArrayList&lt;T&gt; ArrayToArrayList(T[] array) { ArrayList&lt;T&gt; list = new ArrayList&lt;T&gt;(); for(T elmt : array) list.add(elmt); return list; }
type: Answer

http://stackoverflow.com/q/2726006
type: Question
has title: Java CORBA Client Disconnects When Event Fires
has comment: http://stackoverflow.com/comment/2762244
tagged with: java
tagged with: corba
answer count: 2
has body: I have built a Java CORBA application that subscribes to an event server. The application narrows and logs on just fine, but as soon as an event is sent to the client, it breaks with the error below. Please advise. 2010/04/25!13.00.00!E00555!enserver!EventServiceIF_i.cpp!655!PID(7390)!enserver - e._info=system exception, ID 'IDL:omg.org/CORBA/TRANSIENT:1.0' TAO exception, minor code = 54410093 (invocation connect failed; ECONNRESET), completed = NO EDIT: Please note, this only happens when running on some machines. It works on some, but not others. Even on the same platform (I've tried Windows XP/7 and CentOS linux) Some work, some don't... Here is the WireShark output...looks like the working PC is much more interactive with the network compared to the non-working PC. Working PC No. Time Source Destination Protocol Info 62 28.837255 10.10.10.209 10.10.10.250 TCP 50169 &gt; 23120 [SYN] Seq=0 Win=8192 Len=0 MSS=1260 WS=8 63 28.907068 fe80::5de0:8d21:937e:c649 ff02::1:3 LLMNR Standard query A isatap 64 28.907166 10.10.10.209 224.0.0.252 LLMNR Standard query A isatap 65 29.107259 10.10.10.209 10.255.255.255 NBNS Name query NB ISATAP&lt;00&gt; 66 29.227000 10.10.10.250 10.10.10.209 TCP 23120 &gt; 50169 [SYN, ACK] Seq=0 Ack=1 Win=32768 Len=0 MSS=1260 WS=0 67 29.227032 10.10.10.209 10.10.10.250 TCP 50169 &gt; 23120 [ACK] Seq=1 Ack=1 Win=66560 Len=0 68 29.238063 10.10.10.209 10.10.10.250 GIOP GIOP 1.1 Request s=326 id=5 (two-way): op=logon 69 29.291765 10.10.10.250 10.10.10.209 GIOP GIOP 1.1 Reply s=420 id=5: No Exception 70 29.301395 10.10.10.209 10.10.10.250 GIOP GIOP 1.1 Request s=369 id=6 (two-way): op=registerEventStat 71 29.348275 10.10.10.250 10.10.10.209 GIOP GIOP 1.1 Reply s=60 id=6: No Exception 72 29.405250 10.10.10.209 10.10.10.250 TCP 50170 &gt; telnet [SYN] Seq=0 Win=8192 Len=0 MSS=1260 WS=8 73 29.446055 10.10.10.250 10.10.10.209 TCP telnet &gt; 50170 [SYN, ACK] Seq=0 Ack=1 Win=32768 Len=0 MSS=1260 WS=0 74 29.446128 10.10.10.209 10.10.10.250 TCP 50170 &gt; te…
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2786512
linked to: http://stackoverflow.com/q/4418446
score: 3
has answer: http://stackoverflow.com/a/2801614
upvote count: 3
type: UnansweredQuestion

http://stackoverflow.com/q/2718269
accepted answer: http://stackoverflow.com/a/3107787
score: 0
answer count: 1
has body: My application use the SDCard to store data (about 100 Mb of stuff). I would like to delete these file when the application is deleted through the application manager and offer a way to clear the data from there (like the Google Apps does). Any ideas ?
has title: Android - Remove data from SDCard
tagged with: android
type: AnsweredQuestion
type: Question
tagged with: java
has answer: http://stackoverflow.com/a/3107787

http://stackoverflow.com/q/2647745
score: 3
tagged with: asynchronous
accepted answer: http://stackoverflow.com/a/3858471
upvote count: 3
has title: Asynchronous Processing in JBoss 6 ("Comet")
answer count: 1
tagged with: java
tagged with: jboss
has body: edit: Retagged as tomcat/jboss, since this could be a question about the Tomcat embedded inside JBoss 6, rather than JBoss itself I have an extremely simple servlet, which works on Glassfish v3. It uses Servlet 3.0 Asynchronous Processing. Here's a simplified version (which doesn't do much): @WebServlet(asyncSupported=true) public class SimpleServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final AsyncContext ac = request.startAsync(); ac.setTimeout(3000); } } On JBoss 6.0.0 Milestone 2, I get the following Exception: java.lang.IllegalStateException: The servlet or filters that are being used by this request do not support async operation at org.apache.catalina.connector.Request.startAsync(Request.java:3096) at org.apache.catalina.connector.Request.startAsync(Request.java:3090) at org.apache.catalina.connector.RequestFacade.startAsync(RequestFacade.java:990) at playcomet.SimpleServlet.doGet(SimpleServlet.java:18) at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) ... Do I have to do anything special to enable Asynchronous Processing in JBoss 6? Or do I need an additional deployment descriptor? ...
tagged with: servlets
has comment: http://stackoverflow.com/comment/2790693
has answer: http://stackoverflow.com/a/3858471
type: AnsweredQuestion
downvote count: 0
tagged with: tomcat
favorite count: 0
type: Question

http://stackoverflow.com/q/2629812
tagged with: java
upvote count: 1
tagged with: testing
has answer: http://stackoverflow.com/a/2633350
downvote count: 0
possible better answer: http://stackoverflow.com/a/2631317
type: AnsweredQuestion
tagged with: grouping
has answer: http://stackoverflow.com/a/2631317
score: 1
favorite count: 0
tagged with: testng
accepted answer: http://stackoverflow.com/a/2633350
type: Question
answer count: 2
has title: TestNG's groups
has body: If we have &lt;include name="web" &gt; and &lt;include name="weekend" &gt;, TestNG runs all the methods that belong to either web or weekend. Is it possible to change this behaviour so TestNG would run all the methods that belong to web and weekend? Does anyone knows a way to accomplish this?

http://stackoverflow.com/a/2682218
has body: You can also use NSIS. You can find an example of slightly better application launcher.
answers question: http://stackoverflow.com/q/2680513
score: 0
type: Answer

http://stackoverflow.com/comment/2806192
score: 2
comment on: http://stackoverflow.com/a/2772553
type: AnswerComment
has text: -1 Sorry, but I don't see what this answer has to do with the question asked.
type: Comment

http://stackoverflow.com/a/2722434
has comment: http://stackoverflow.com/comment/2751534
type: Answer
has comment: http://stackoverflow.com/comment/2748743
has comment: http://stackoverflow.com/comment/2751602
has comment: http://stackoverflow.com/comment/2748772
has comment: http://stackoverflow.com/comment/2748737
has comment: http://stackoverflow.com/comment/2751416
has comment: http://stackoverflow.com/comment/2775671
has body: I don't see anything wrong with doing it as per your example. However, if you want to get fancy you could use Google's Guava library, specifically the Collections2 class, to do a functional-style filtering on your collection. You get to provide your own predicate, which can of course do the instanceof thing. Collection&lt;Object&gt; newCollection = Collections2.filter(initCollection, new Predicate&lt;Object&gt;() { public boolean apply(Object o) { return !(o instanceof String); } });
answers question: http://stackoverflow.com/q/2722343
score: 4
upvote count: 4
has comment: http://stackoverflow.com/comment/2750186
has comment: http://stackoverflow.com/comment/2749788
downvote count: 0
has comment: http://stackoverflow.com/comment/2750141

google-finance-api
tags question: http://stackoverflow.com/q/2732138
type: Tag
tag name: google-finance-api

http://stackoverflow.com/a/2738259
has comment: http://stackoverflow.com/comment/2767018
score: 29
has comment: http://stackoverflow.com/comment/2766854
has comment: http://stackoverflow.com/comment/2766675
has comment: http://stackoverflow.com/comment/2766683
has comment: http://stackoverflow.com/comment/2766687
has body: I guess that java.util.IdentityHashMap is what you're looking for (note, there's no IdentityHashSet). Lookup the API documentation: This class implements the Map interface with a hash table, using reference-equality in place of object-equality when comparing keys (and values). In other words, in an IdentityHashMap, two keys k1 and k2 are considered equal if and only if (k1==k2). (In normal Map implementations (like HashMap) two keys k1 and k2 are considered equal if and only if (k1==null ? k2==null : k1.equals(k2)).) This class is not a general-purpose Map implementation! While this class implements the Map interface, it intentionally violates Map's general contract, which mandates the use of the equals method when comparing objects. This class is designed for use only in the rare cases wherein reference-equality semantics are required. edit: See Joachim Sauer's comment below, it's really easy to make a Set based on a certain Map. You'd need to do something like this: Set&lt;E&gt; mySet = Collections.newSetFromMap(new IdentityHashMap&lt;E, Boolean&gt;());
has comment: http://stackoverflow.com/comment/2766786
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2766946
accepted answer of: http://stackoverflow.com/q/2738230
type: Answer
answers question: http://stackoverflow.com/q/2738230
has comment: http://stackoverflow.com/comment/2766707
upvote count: 29

http://stackoverflow.com/comment/102186678
type: AnswerComment
type: Comment
score: 2
has text: Split uses Regex internally?
comment on: http://stackoverflow.com/a/2670853

http://stackoverflow.com/a/2602031
upvote count: 1
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/2601875
type: Answer
has body: Best answer to this simple question is: "it depends". There are many API's you can use for database access. Nearly all of them will use the JDBC API as their means to communicate with the database. So in theory, nothing can beat raw low level JDBC (just as machine code is in theory always faster than higherlevel programming languages). But as you also like to write reusable code, I suggest you look into JPA. It's the Java standard for object persistence to relational databases. It’s performance is quite good and it’s very portable. As JPA is just a specification, you can choose you’re own implementation: Hibernate, OpenJPA or any compliant Java EE server.

http://stackoverflow.com/comment/72838570
has text: @ThreaT No, it doesn't, because when you modify p1 you make it reference null, but you don't destroy the object; the object and its reference are distinct things: p2 still points to the created object until you make p2 reference null; then, the object will be destroyed by GC because nothing references it. C pointers are similar in this: consider the code void main() { int n, *p1, *p2; n = 42; p1 = &n; p2 = p1; *p1 = 100; p1 = NULL; printf("%d\n", *p2); } it will print "100" because when you do p1 = null, you modify the pointer value, not the value of what it points to.
type: AnswerComment
comment on: http://stackoverflow.com/a/17092543
type: Comment
score: 2

http://stackoverflow.com/q/2648422
score: 1
tagged with: java
tagged with: hibernate
tagged with: websphere
has comment: http://stackoverflow.com/comment/2664536
upvote count: 1
answer count: 1
has comment: http://stackoverflow.com/comment/2665066
favorite count: 0
tagged with: jdbc
has comment: http://stackoverflow.com/comment/2664215
has title: Configure Hibernate to obtain a fresh connection from a connection pool
type: AnsweredQuestion
downvote count: 0
tagged with: orm
has body: How do I configure Hibernate so that each time I call sessionFactory.openSession() it connects with a new connection from the connection pool? The connection pool is managed by Websphere Application Server and is a JDBC Data Source. Thanks
has comment: http://stackoverflow.com/comment/2669293
type: Question
linked to: http://stackoverflow.com/q/2647912
has answer: http://stackoverflow.com/a/2649690
accepted answer: http://stackoverflow.com/a/2649690

http://stackoverflow.com/a/2724171
type: AcceptedAnswer
has body: Are you aware of the purpose of ThreadLocal? From the docs: This class provides thread-local variables. These variables differ from their normal counterparts in that each thread that accesses one (via its get or set method) has its own, independently initialized copy of the variable. ThreadLocal instances are typically private static fields in classes that wish to associate state with a thread (e.g., a user ID or Transaction ID). You're getting a different Hibernate session for each thread precisely because that's what your code says to do. Now, we can't really comment on whether this a good thing or not - although in many cases it's reasonably sensible. After all, you wouldn't want two threads to share the same session and interact with each other's transactions, would you?
downvote count: 0
has comment: http://stackoverflow.com/comment/2750896
has comment: http://stackoverflow.com/comment/2751281
has comment: http://stackoverflow.com/comment/2751216
type: Answer
has comment: http://stackoverflow.com/comment/2751008
has comment: http://stackoverflow.com/comment/2750957
score: 7
accepted answer of: http://stackoverflow.com/q/2724147
has comment: http://stackoverflow.com/comment/2751386
answers question: http://stackoverflow.com/q/2724147
upvote count: 7

http://stackoverflow.com/q/2680993
accepted answer: http://stackoverflow.com/a/2681051
has answer: http://stackoverflow.com/a/9168955
tagged with: sockets
possible better answer: http://stackoverflow.com/a/9168955
type: AnsweredQuestion
score: 2
tagged with: transfer
upvote count: 2
tagged with: java
tagged with: file
has body: I am working on a chat implementation with Java sockets. I have focused on few functionalities, like authentication, one person chat and a group chat. I was thinking about adding file transfer functionality, and I wonder what's the good practice about this. Should I have separate socket on the server with different port listening just for file transfers? Right now input and output streams that I get from server socket are binded to Scanner and PrintWriter objects respectively, so I find it hard to use that for file transfer. Any patterns you guys could recommend or give me good recommendations are very appreciated. Thanks, ZeKoU
type: Question
has answer: http://stackoverflow.com/a/2681051
tagged with: chat
answer count: 2
has title: How to implement file transfer with Java sockets?
downvote count: 0
favorite count: 0

http://stackoverflow.com/comment/2678714
score: 0
has text: "I'm getting a compiler error" -- WHAT is the error? How can you say something like that and leave it out? Please help us help you.
comment on: http://stackoverflow.com/q/2660295
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/110231624
has text: The property spring.servlet.multipart.resolve-lazily really helped. Thanks!
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/54405341
score: 3

http://stackoverflow.com/comment/2729636
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2706003
has text: Heh... I came up with the exact same solution as you, although it is worth pointing out that this won't work like that. You need to use `@` before the string or else you need to escape the backslashes.
score: 0

http://stackoverflow.com/a/24150480
type: Answer
score: 11
downvote count: 0
upvote count: 11
answers question: http://stackoverflow.com/q/2703984
has body: The Queue interface specifies that add() will throw an IllegalStateException if no space is currently available (and otherwise return true) while offer() will return false if the element couldn't be inserted due to capacity restrictions. The reason they are the same in a PriorityQueue is that this queue is specified to be unbounded, i.e. there are no capacity restrictions. In the case of no capacity restrictions, the contracts of add() and offer() display the same behaviour.

http://stackoverflow.com/a/2725130
downvote count: 0
has body: If the same program is doing the creation of the file as the polling, you could instead have the logic that creates the file notify the part of the program using Object.notify(). A general description of the wait() and notify/notifyAll() mechanism can be found here: http://java.sun.com/docs/books/tutorial/essential/concurrency/guardmeth.html
answers question: http://stackoverflow.com/q/2725080
type: Answer
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/2751811

http://stackoverflow.com/comment/2652447
type: Comment
comment on: http://stackoverflow.com/a/2635490
has text: Besides, I found that blog post, which seems to sumarize quite well the state of OSGi application building : http://codepitbull.wordpress.com/2010/01/19/me-osgi-and-maven/
score: 1
type: AnswerComment

http://stackoverflow.com/comment/2650391
comment on: http://stackoverflow.com/a/2629758
has text: Not-so-micro nitpick: The "reference to pointer" table that you mention is one possible implementation, but in no way required by the Java specification.
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/a/2682696
score: 1
answers question: http://stackoverflow.com/q/2631209
downvote count: 0
has body: Don't know Seam but you must know that in EJB3.1 specs you can put your ejb's inside a war... See http://community.jboss.org/wiki/EJB31inAS600M2 Glassfish v3 also support it i think. I guess Tomcat supports/will support it too but anyway you can use EJB3 in Tomcat with an embedded EJB3 impl like OpenEJB ( http://openejb.apache.org/ )
type: Answer
upvote count: 1

http://stackoverflow.com/q/2625520
tagged with: java
has comment: http://stackoverflow.com/comment/51979427
tagged with: comparison
type: Question
has body: I've been using C/C++ and Python, but I now I see that a lot of new programming books use Java or C# as examples. I don't think I'll use Java or C# for the time being, but I guess I have to study one of the languages (or both of them) in order to read/understand the books. How similar Java and C#? If I learn Java, is learning C# almost free? Or vice versa? If I have to choose only one of the two languages, which would be better? Which has wider coverage in terms of programming language?
score: 45
has title: Java and C#, how close are they?
has comment: http://stackoverflow.com/comment/2638335
favorite count: 0
has comment: http://stackoverflow.com/comment/86413189
has answer: http://stackoverflow.com/a/2626037
has answer: http://stackoverflow.com/a/2685191
answer count: 4
possible better answer: http://stackoverflow.com/a/2626076
has answer: http://stackoverflow.com/a/2626076
has answer: http://stackoverflow.com/a/2625548
has comment: http://stackoverflow.com/comment/19948055
accepted answer: http://stackoverflow.com/a/2626037
downvote count: 1
has comment: http://stackoverflow.com/comment/25750740
type: AnsweredQuestion
tagged with: c#
upvote count: 46

http://stackoverflow.com/comment/2806174
comment on: http://stackoverflow.com/q/2772511
has text: Tim: String#toCharArray creates an array with a copy of the String's characters. Even if it works, it imposes unnecessary overhead just to iterate over the characters.
score: 6
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2774720
tagged with: exception
type: AnsweredQuestion
type: Question
has answer: http://stackoverflow.com/a/4285530
has body: ... Null primary key encountered in unit of work clone ... exception in eclipselink(2.0.2 with 2.0 jpa) literally meaning that id in my entity is &lt;=0 (for primitive types). Though debug here states that everything's fine and I have nothing to worry about. My AS is glassfish v3. Can any one point out what may cause such behavior?
tagged with: java
has comment: http://stackoverflow.com/comment/2808845
has title: How to handle "null primary key encountered" exception in eclipselink?
score: 0
tagged with: eclipselink
tagged with: java-ee-6
tagged with: jpa
answer count: 1
accepted answer: http://stackoverflow.com/a/4285530

jndi
tags question: http://stackoverflow.com/q/2759727
tags question: http://stackoverflow.com/q/2672125
tags question: http://stackoverflow.com/q/2735167
tags question: http://stackoverflow.com/q/2620739
tag name: jndi
tags question: http://stackoverflow.com/q/2758248
tags question: http://stackoverflow.com/q/2653718
tags question: http://stackoverflow.com/q/2744011
tags question: http://stackoverflow.com/q/2720948
tags question: http://stackoverflow.com/q/2759300
type: Tag
tags question: http://stackoverflow.com/q/2701861
tags question: http://stackoverflow.com/q/2678356

http://stackoverflow.com/comment/2771397
comment on: http://stackoverflow.com/a/2742208
has text: added suggestion (Edit) in my response.. (lastResult..batch)
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/q/2692319
linked to: http://stackoverflow.com/q/585599
has body: There seems to be some confusion as well contradicting statements on various SO answers: What&#39;s causing my java.net.SocketException: Connection reset? . You can see here that the accepted answer states that the connection was closed by other side. But this is not true, closing a connection doesn't cause a connection reset. It is cauesed by "an underlying TCP/IP error." What I want to know is if a SocketException: Connection reset means really besides "unerlying TCP/IP Error." What really causes this? As I doubt it has anything to do with the connection being closed (since closing a connection isn't an exception worthy flag, and reading from a closed connection is, but that isn't an "underlying TCP/IP error." My hypothesis is this Connection reset is caused from a server's failure to acknowledge an ACK packet (either wholly or just improperly as per TCP/IP). And that a SocketTimeoutException is generated only when no data is generated to be read (since this is thrown during a read after a certain duration, and read is waiting for data, but is not concerned with ACK packets). In other words, read() throws SocketTimeoutException if it didn't read any bytes of actual data (DATA LAYER) in its allotted time.
duplicate of: http://stackoverflow.com/q/585599
has answer: http://stackoverflow.com/a/2694990
has comment: http://stackoverflow.com/comment/118006358
favorite count: 0
accepted answer: http://stackoverflow.com/a/2694990
upvote count: 2
tagged with: tcp
has title: Java: Clearing up the confusion on what causes a connection reset
has answer: http://stackoverflow.com/a/2692349
type: AnsweredQuestion
score: 2
tagged with: ioexception
tagged with: java
possible better answer: http://stackoverflow.com/a/2692349
type: Question
answer count: 2
downvote count: 0

http://stackoverflow.com/comment/80476382
type: Comment
score: 3
type: QuestionComment
comment on: http://stackoverflow.com/q/2642777
has text: This question is cited in The Most Dangerous Code in the World paper as an example of fallacious reasoning. (research paper: http://www.cs.utexas.edu/~shmat/shmat_ccs12.pdf)

http://stackoverflow.com/comment/71519975
has text: I don't see this mentioned but if you use ubuntu most of the most common packages are available like `apt install maven` or `apt install gradle`
type: Comment
type: QuestionComment
score: 2
comment on: http://stackoverflow.com/q/2710266

http://stackoverflow.com/a/2607006
has body: Maybe you can just use ArrayList, shouldn't be much difference in performance compared to a plain array.
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/2606766
downvote count: 0
type: Answer

http://stackoverflow.com/a/2723814
has body: The source code of the API is available, get a JDK and open up the src.zip file from the installation folder.
upvote count: 3
type: Answer
downvote count: 0
score: 3
answers question: http://stackoverflow.com/q/2723781

http://stackoverflow.com/comment/13365345
type: Comment
has text: @NateS: Thanks, it looks very promising! I'm on a different project now, but told my colleagues the good news. Sounds like they'll be switching.
score: 0
comment on: http://stackoverflow.com/a/2746895
type: AnswerComment

http://stackoverflow.com/comment/21221693
score: 3
has text: @ Goober Just as a matter of interest, which uni teaches c# over java? I went to City University London and almost all programming was done in Java ( which annoyed me a bit actually).
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2685191

http://stackoverflow.com/comment/2636585
has text: well it is like simple http servers. In theory they are very simple. ask for html - get html.. but look at ruby on rails for example.. there we see 10 different database solutions, deployment servers, testing frameworks, benchmark frameworks, polymorthic relationships, timezone support, templating etc!.. i hope this supports my point ;)
comment on: http://stackoverflow.com/q/2623677
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/2654776
comment on: http://stackoverflow.com/q/2640135
type: Comment
type: QuestionComment
has text: Is the array given at start time, or is it a stream of incoming strings?
score: 0

http://stackoverflow.com/a/2701117
downvote count: 0
has comment: http://stackoverflow.com/comment/2724270
has comment: http://stackoverflow.com/comment/2724046
score: 4
has body: JSF provide an abstraction layer with several responsibilities, but most important it handles all the messy details of HTML forms and transferring data back and forth between web pages and Java POJO beans (getX, setX methods), which is notoriously difficult to do right. It also provides navigation and in the latest incarnation in Java EE 6 rudimentary AJAX support is available allowing for simple updates of the web page as the user inputs data. You might find it easier to think of it as a way to avoid writing JavaScript yourself.
answers question: http://stackoverflow.com/q/2701094
type: Answer
upvote count: 4

http://stackoverflow.com/a/2674735
downvote count: 0
answers question: http://stackoverflow.com/q/2674707
type: Answer
has body: StringBuffer sb = new StringBuffer(); sb.append(a).append(b).append(c)... Keeping the values as an int is preferred thou, as the other answers show you.
has comment: http://stackoverflow.com/comment/2693480
has comment: http://stackoverflow.com/comment/2693576
score: 5
upvote count: 5

http://stackoverflow.com/comment/50210857
type: Comment
type: QuestionComment
has text: @JamesKPolk But it make sense in c#.i read Illustrated CSharp 2012 and in chapter 8 writer say : "an operator is symbol that represents an opration that returns single result".
comment on: http://stackoverflow.com/q/2709553
score: 0

http://stackoverflow.com/comment/2799811
type: AnswerComment
has text: I actually gave IP address only.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2748878

http://stackoverflow.com/q/2606603
has comment: http://stackoverflow.com/comment/103978748
tagged with: drools
has comment: http://stackoverflow.com/comment/77701368
has answer: http://stackoverflow.com/a/2608235
answer count: 3
downvote count: 0
has answer: http://stackoverflow.com/a/2648906
upvote count: 48
favorite count: 0
has body: We're embarking on a module which will generate some recommendations based on some criteria. The criteria will be in the form of set of Business Rules and hence I was considering using a Business Rule Engine like Drools(open source and java :-) ) we need to learn Drools fast (2-3 weeks) and be able to implement rules using JBoss Drools. Which articles, tutorials, books, best practices should we be following ?
score: 48
type: UnansweredQuestion
has title: how to learn Drools or another rule engine fast
has comment: http://stackoverflow.com/comment/2616641
tagged with: java
tagged with: business-rules
has answer: http://stackoverflow.com/a/14499242
type: Question

http://stackoverflow.com/a/15842879
score: 37
upvote count: 37
downvote count: 0
answers question: http://stackoverflow.com/q/2618136
has body: in Xpath, "." (Dot) represents the current document. So, write your XPATH string after a "." (Dot) . ex : "./title" or ".//title" Whatever you want.... removing the slash works only if its a child of the node. What if you want to use the // (wherever in the current Document) functionality ? So, use the dot (.) Thanks a lot for the above answers too :) .
type: Answer

http://stackoverflow.com/a/2717266
upvote count: 0
answers question: http://stackoverflow.com/q/2717111
score: -1
type: Answer
has body: package playground.tests; import junit.framework.TestCase; public class PrintTriangleTest extends TestCase { public void testPrintTriangle() throws Exception { assertEquals("*\n**\n***\n****\n*****\n", printTriangleRecursive(5, 0, 0)); } private String printTriangleRecursive(int count, int line, int character) { if (line == count) return ""; if (character &gt; line) return "\n" + printTriangleRecursive(count, line + 1, 0); return "*" + printTriangleRecursive(count, line, character + 1); } }
downvote count: 1

http://stackoverflow.com/a/2678913
score: 0
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2673994
answers question: http://stackoverflow.com/q/2673994
type: Answer
has comment: http://stackoverflow.com/comment/2700462
has body: Render your SVGs to textures, then render textured quads with desired transforms.

http://stackoverflow.com/comment/2727276
type: QuestionComment
has text: @Andrei: I tried to address that part in my answer. I'll happily take any other suggestions you may have.
score: 0
comment on: http://stackoverflow.com/q/2703259
type: Comment

http://stackoverflow.com/comment/2776472
type: QuestionComment
has text: Doh!! :) :) Running an small proof of concept ( as I guess you did in this case ) always help to spot where the problem is. You can mark my answer as accepted though -> http://stackoverflow.com/questions/2746744/java-why-sublist0-5-clear-doesnt-work-on-my-objects/2746863#2746863
comment on: http://stackoverflow.com/q/2746744
score: 0
type: Comment

guice
tags question: http://stackoverflow.com/q/2632033
tags question: http://stackoverflow.com/q/2621319
tag name: guice
tags question: http://stackoverflow.com/q/2728097
type: Tag
tags question: http://stackoverflow.com/q/2669926
tags question: http://stackoverflow.com/q/2684189
tags question: http://stackoverflow.com/q/2605198
tags question: http://stackoverflow.com/q/2647139

http://stackoverflow.com/comment/2808209
has text: just a matter of personal preference, but I prefer not to parse and like the google splitter solution better.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2774178

http://stackoverflow.com/a/2774475
answers question: http://stackoverflow.com/q/2773206
type: Answer
score: 0
has body: Comparison between the Poly-SO mix code and Apache Commons FileUtils: iterateFiles and listFiles Apache commons-io has similar methods iterateFiles and listFiles in FileUtils, suggested by Bozho. Parameter checks are done in a variety of ways, but never "System.exit(9)"! They comp par to null, check its existence with File-type (available method for it), They use static, linkedList in the listFiles-implementation -- suggested in the book by poly. They reuse the field to match all dirs: TrueFileFilter.INSTANCE Singleton instance of true filter (From Apache API, singleton?) The two methods are the only methods that use IOFileFilter as a parameter. I am uncertain of its implications. They can surely reuse their code. There are some very succinct -- I think nice -- evaluation points, no blurring dummy vars. Please, see the evalution of (a?b:c), saves stupid dums and if-clauses. return listFiles(directory, filter, (recursive ? TrueFileFilter.INSTANCE : FalseFileFilter.INSTANCE)); The FileUtils-class in which the methods resides have only 4 field value -- about 2.5 methods per field! Now I am shamed with my class. A striking difference is the use of Exceptions. They use them but -- apparently due to the different goal of FileUtils class -- they let for user to handle them, no centralised collection in list. No extra declarations. Summary Similarity: linkedList and list Differences: less inits, less decs, smaller density of fields to methods -- succincy Different Goals: SO's class end-user case, FileUtils more backend Difference(natural): exceptions handling in SO but not in FileUtils (perhaps that is the reason it is so clean) I liked comments and particularly the source -- much better for educational purposes than reading trivial APIs, I feel. Hope you too :) Apache Commons: FileUtils.java, listFiles, iterateFiles - code pieces /** * Finds files within a given directory (and optionally its * subdirectories). All files found are filtered by an IOFileFilter. * * If your se…

http://stackoverflow.com/comment/2776339
type: Comment
has text: I would expect stencil buffer to be slower than glViewport. I'm not sure about clip planes - it might depend on how many you need.
comment on: http://stackoverflow.com/a/2739744
type: AnswerComment
score: 0

http://stackoverflow.com/q/2670956
linked to: http://stackoverflow.com/q/1234912
has answer: http://stackoverflow.com/a/2670986
has answer: http://stackoverflow.com/a/2670959
has answer: http://stackoverflow.com/a/31660211
has answer: http://stackoverflow.com/a/2672739
downvote count: 0
has body: What's the best way to quit a Java application with code?
has title: How to quit a java app from within the program
favorite count: 0
upvote count: 157
has answer: http://stackoverflow.com/a/2670980
answer count: 12
has answer: http://stackoverflow.com/a/46720691
accepted answer: http://stackoverflow.com/a/2670959
has answer: http://stackoverflow.com/a/2670988
score: 157
possible better answer: http://stackoverflow.com/a/2670980
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/33120593
has answer: http://stackoverflow.com/a/6381074
has answer: http://stackoverflow.com/a/12751594
tagged with: java
has answer: http://stackoverflow.com/a/23219773
type: Question
has answer: http://stackoverflow.com/a/2672060
has comment: http://stackoverflow.com/comment/2689517
has comment: http://stackoverflow.com/comment/2689635

http://stackoverflow.com/q/2739302
accepted answer: http://stackoverflow.com/a/2739581
score: 0
has title: How to use @BeforeClass and @AfterClass in JunitPerf?
answer count: 1
tagged with: junit
has body: I want to do some actions before the whole test suite (also after the suite). So I wrote like: public class PerformanceTest extends TestCase { @BeforeClass public static void suiteSetup() throws Exception { //do something } @AfterClass public static void suiteSetup() throws Exception { //do something } @Before public void setUp() throws Exception { //do something } @After public void tearDown() throws Exception { //do something } public PerformanceTest(String testName){ super(testName); } public static Test suite() { TestSuite suite = new TestSuite(); Test testcase1 = new PerformanceTest("DoTest1"); Test loadTest1 = new LoadTest(testcase1, n); Test testcase2 = new PerformanceTest("DoTest2"); Test loadTest2 = new LoadTest(testcase2, n); return suite; } public void DoTest1 throws Throwable{ //do something } public void DoTest2 throws Throwable{ //do something } } But I found that it never reach the code in @BeforeClass and @AfterClass. So how could I do to solve this problem? Or is there other way to realize this? Thank you for your help.
tagged with: junitperf
type: AnsweredQuestion
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/2739581

http://stackoverflow.com/a/2776432
answers question: http://stackoverflow.com/q/2776400
has comment: http://stackoverflow.com/comment/2810773
has comment: http://stackoverflow.com/comment/64318367
score: 12
accepted answer of: http://stackoverflow.com/q/2776400
upvote count: 12
type: AcceptedAnswer
has body: No, there is not a better solution. If you are working with values that cannot fit into a long or a double then you will need to use a reference type like BigInteger, and Java does not support operator overloading. Technically, I suppose you could have some mapping between signed and unsigned values, but if your goal is clean and simple code then this is not at all the way to go.
downvote count: 0
has comment: http://stackoverflow.com/comment/39430881
type: Answer

http://stackoverflow.com/comment/18042776
has text: signatures are not allowed on posts here [faq#signatures]
score: 0
type: Comment
comment on: http://stackoverflow.com/a/5454189
type: AnswerComment

http://stackoverflow.com/comment/2664602
type: Comment
score: 2
has text: @Rui - i would say, the question is not clear. You want to port from Java to C++; but you have given the C++ code. What is that in Java you are trying to port.? Consider editing your question so that you get quick answers.
type: QuestionComment
comment on: http://stackoverflow.com/q/2648756

http://stackoverflow.com/comment/3274027
has text: Charlie wants to test email fetching, Dumbster and SubEthaSmtp are for sending mail.
type: AnswerComment
comment on: http://stackoverflow.com/a/2783199
score: 0
type: Comment

http://stackoverflow.com/comment/2756233
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2728492
has text: I'm still confused about the references. I thought the reference would remain the same. Anyway, accepted your answer. Thanks.
type: AnswerComment

http://stackoverflow.com/comment/2809657
comment on: http://stackoverflow.com/a/2775479
type: AnswerComment
has text: @BalusC added. Yep, I had two 10k accounts already so, I though a merge was in order.
score: 0
type: Comment

http://stackoverflow.com/comment/125888064
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2707732
has text: Loved your example!

http://stackoverflow.com/q/2708921
has body: I've been working on a project in Netbeans. Now I'd like to submit it and allow the markers to compile it with a script. However, I get the NoClassDefFoundError when I try to run via the command line. Even when setting the classpath to the current directory manually. javac Main.java works fine then calling java -classpath . Main gives: java -classpath . Main Exception in thread "main" java.lang.NoClassDefFoundError: Main (wrong name: pro ject2/Main) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:620) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12 4) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) at java.net.URLClassLoader.access$000(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
accepted answer: http://stackoverflow.com/a/2708936
type: Question
tagged with: java
tagged with: noclassdeffounderror
has title: Yet another Java classpath problem
answer count: 2
possible better answer: http://stackoverflow.com/a/2708942
has answer: http://stackoverflow.com/a/2708936
has answer: http://stackoverflow.com/a/2708942
score: 0
tagged with: javac
type: AnsweredQuestion

http://stackoverflow.com/q/2703161
has comment: http://stackoverflow.com/comment/74863570
has answer: http://stackoverflow.com/a/47805407
has answer: http://stackoverflow.com/a/50236635
has answer: http://stackoverflow.com/a/10400575
has answer: http://stackoverflow.com/a/11988335
has answer: http://stackoverflow.com/a/50180854
has answer: http://stackoverflow.com/a/27556715
linked to: http://stackoverflow.com/q/1828775
upvote count: 169
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/73107999
has answer: http://stackoverflow.com/a/12573535
has answer: http://stackoverflow.com/a/24624966
has answer: http://stackoverflow.com/a/3894076
tagged with: java
has answer: http://stackoverflow.com/a/17472034
has answer: http://stackoverflow.com/a/2703233
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/35203927
has answer: http://stackoverflow.com/a/11614499
has answer: http://stackoverflow.com/a/39560151
has comment: http://stackoverflow.com/comment/72971944
has comment: http://stackoverflow.com/comment/73107967
possible better answer: http://stackoverflow.com/a/24370091
has comment: http://stackoverflow.com/comment/13794333
has answer: http://stackoverflow.com/a/50274496
tagged with: ssl
has answer: http://stackoverflow.com/a/38509015
has answer: http://stackoverflow.com/a/24370091
has answer: http://stackoverflow.com/a/75876538
has comment: http://stackoverflow.com/comment/72968686
answer count: 25
has body: How do I bypass invalid SSL certificate errors with Apache HttpClient 4.0?
has answer: http://stackoverflow.com/a/5979031
has answer: http://stackoverflow.com/a/49668661
has answer: http://stackoverflow.com/a/28847175
accepted answer: http://stackoverflow.com/a/2703233
has title: How to ignore SSL certificate errors in Apache HttpClient 4.0
has answer: http://stackoverflow.com/a/76222849
has answer: http://stackoverflow.com/a/29651988
has answer: http://stackoverflow.com/a/29435138
score: 168
has comment: http://stackoverflow.com/comment/60468862
has comment: http://stackoverflow.com/comment/13693685
has answer: http://stackoverflow.com/a/10828086
favorite count: 0
tagged with: apache-httpclient-4.x
has comment: http://stackoverflow.com/comment/31869558

http://stackoverflow.com/comment/62446767
type: AnswerComment
score: 1
type: Comment
comment on: http://stackoverflow.com/a/2620545
has text: This answer is devoid of meaningful information for answering the question.

http://stackoverflow.com/q/2620591
has comment: http://stackoverflow.com/comment/2633172
upvote count: 20
downvote count: 0
has title: Get the Integer from the end of a string (variable length)
has answer: http://stackoverflow.com/a/40435587
favorite count: 0
has answer: http://stackoverflow.com/a/2620751
has answer: http://stackoverflow.com/a/2620630
has body: I have a string of a variable length and at the end of the string are some digits. What would be the best / efficient way, to parse the string and get the number from the end as an Integer? The String and the digits at the end can can be of any length. For example: abcd123 --> 123 abc12345 --> 12345 ab4cd1 --> 1
accepted answer: http://stackoverflow.com/a/2620609
answer count: 10
has answer: http://stackoverflow.com/a/2620933
possible better answer: http://stackoverflow.com/a/2620933
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2620609
has answer: http://stackoverflow.com/a/2620941
has answer: http://stackoverflow.com/a/2620693
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/2621900
has answer: http://stackoverflow.com/a/2620622
score: 20
has answer: http://stackoverflow.com/a/2620736

http://stackoverflow.com/comment/2613357
type: Comment
comment on: http://stackoverflow.com/a/2602257
type: AnswerComment
has text: Forgot to tell this, I won't need to change the state after object creation.
score: 0

http://stackoverflow.com/q/2723815
has answer: http://stackoverflow.com/a/10809484
has answer: http://stackoverflow.com/a/2724558
has answer: http://stackoverflow.com/a/5301816
has title: Java Caching on distributed environment
has answer: http://stackoverflow.com/a/12348637
favorite count: 0
has comment: http://stackoverflow.com/comment/32966133
upvote count: 2
has answer: http://stackoverflow.com/a/12609130
answer count: 5
type: UnansweredQuestion
has body: I am supposed to create a simple replicated cache using java for internal purpose which will be used in a distributed environment. I have seen oracle has implemented Replicated Cache Service. The problem I am facing is while doing an update or remove, I acquire lock on other cache's to the point the cache get's updated and notifies others of the change. This is eventually going into a dead lock situation, while removing. Is there any strategy I should follow while updating or removing from cache's. Can I implement a replicated cache without having a primary cache?
score: 2
tagged with: java
tagged with: caching
type: Question
downvote count: 0
has comment: http://stackoverflow.com/comment/2786475

http://stackoverflow.com/a/2675446
has body: The Eclipse SDK contains a class SocketUtil, that does what you want. You may have a look into the git source code.
downvote count: 1
upvote count: 12
type: Answer
score: 11
has comment: http://stackoverflow.com/comment/46094304
answers question: http://stackoverflow.com/q/2675362

compilation
tags question: http://stackoverflow.com/q/2768903
tags question: http://stackoverflow.com/q/2692421
tags question: http://stackoverflow.com/q/2769387
tag name: compilation
tags question: http://stackoverflow.com/q/2650168
tags question: http://stackoverflow.com/q/2639811
tags question: http://stackoverflow.com/q/2679066
type: Tag
tags question: http://stackoverflow.com/q/2614502

http://stackoverflow.com/a/2630496
has body: I recreated your code and added some extra debugging output by creating a class to print the output from process: private static class Writer implements Runnable { private InputStream is; public Writer(InputStream is) { this.is = is; } @Override public void run() { try { BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line; while ((line = br.readLine()) != null) { System.out.println(line); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } In the main method I then started an instance of this before calling waitFor(): public static void main(String[] args) throws Exception { String command = "tasklist /svc | findstr \"svchost.exe\""; Process p = Runtime.getRuntime().exec(command); new Thread(new Writer(p.getInputStream())).start(); new Thread(new Writer(p.getErrorStream())).start(); System.out.println("Return code: " + p.waitFor()); } The output from this is: ERROR: Invalid argument/option - '|'. Type "TASKLIST /?" for usage. Because the command isn't executed in a shell, you first need to call the Windows shell, and pass in the command as an argument: String command = "cmd /c tasklist /svc | findstr \"svchost.exe\""; After changing this the output is now Return code: 0. I've found a strange issue however, in that if you don't handle the output from the process's stdout channel, for some reason the process does not terminate. To get around this, I've had to put in a loop to read and discard the output from the process: public static void main(String[] args) throws Exception { String command = "cmd /c tasklist /svc | findstr \"svchost.exe\""; Process p = Runtime.getRuntime().exec(command); while(p.getInputStream().read() != -1) {} //hangs without this line System.out.println("Return code: " + p.waitFor()); }
downvote count: 0
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2629922
upvote count: 2
type: Answer
accepted answer of: http://stackoverflow.com/q/2629922
score: 2

http://stackoverflow.com/q/2618697
has body: I began studying Java Regular Expression recently and I found some really intersting task.For example,I now need to dig out "Product Name","Product Description" and "Sellers for this product" out of the following HTML code.(I am sorry for the big chunck of code,but it is very straightforward) &lt;td class="sr-check"&gt; &lt;input type="checkbox" name="cptitle" value="678560038" /&gt;&lt;/td&gt; &lt;td class="sr-image" style="width: 80px;"&gt;&lt;a href="/Nikon-D300S-12-3-678560038/prices-html" class="strictRule" rel="nofollow"&gt;&lt;img src="http://img01.static-nextag.com/image/Nikon-D300S-12-3-MP-Digital-SLR-Camera-Body-Black/0/000/006/789/461/678946110.jpg" alt="Nikon D300S 12.3 MP Digital SLR Camera Body - Black" class="imageLink strictRule" height="75" width="75" id="opILink_0" title="Nikon Digital Cameras - Nikon D300S 12.3 MP Digital SLR Camera Body - Black" /&gt;&lt;/a&gt;&lt;div class="breaker"&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt; &lt;td class="sr-info"&gt; &lt;div class="sr-info"&gt; &lt;a id="opPNLink_0" class="underline" style="font-size:16px" href="/Nikon-D300S-12-3-678560038 /prices-html" &gt;Nikon D300S 12.3 MP &lt;b&gt;Digital&lt;/b&gt; SLR &lt;b&gt;Camera&lt;/b&gt; Body - Black&lt;/a&gt; &lt;div class="sr-subinfo"&gt; &lt;div class="sr-info-description"&gt;SLR - 13.1MP, 12.3MP - 1x Optical Zoom - CompactFlash, SD/MMC Memory Card - 3in.&lt;/div&gt; &lt;div class="rating"&gt; &lt;img src="http://img01.static-nextag.com/imagefiles/stars/stars4_10px.gif" alt="4/5 stars" title="4/5 stars" /&gt; (92 user ratings)&lt;/div&gt; &lt;div style="clear: both;"&gt; &lt;!-- nxtginc=nextag.api.ServerInclude$JSPIncludeWriter(/buyer/ATLSSI.jsp?ptid=678560038&amp;dts=y) --&gt; &lt;a id="_atl_0" style="" href="http://www.nextag.com/serv/main/buyer/MyPDir.jsp?list=_transCookieList&amp;amp;cmd=add&amp;amp;ptitle=678560038" rel="nofollow"&gt;+ Add to Shopping List&lt;/a&gt; &amp;nbsp;|&amp;nbsp; &lt;!-- endnxtginc --&gt; &lt;a rel="nofollow" id="mltLink_0" class="mlt-link…
tagged with: http://stackoverflow.com/tag/html
tagged with: regex
has comment: http://stackoverflow.com/comment/2630732
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2630727
has comment: http://stackoverflow.com/comment/2630767
accepted answer: http://stackoverflow.com/a/2621763
tagged with: java
type: Question
linked to: http://stackoverflow.com/q/1732348
score: 0
answer count: 1
has title: Beginner questions on Java Regular Expression
has answer: http://stackoverflow.com/a/2621763

http://stackoverflow.com/a/2709855
upvote count: 18
type: AcceptedAnswer
downvote count: 0
score: 18
has body: Use a negative lookbehind: "(?&lt;!\\\\):" The reason for the four backslashes is: the backslash is a special character in regular expressions so you need the regular expression \\ to match a single backslash. backslashes must be escaped in Java strings, so each of the above backslashes must be written as \\, giving a total of four. Example code: Pattern pattern = Pattern.compile("(?&lt;!\\\\):"); Matcher matcher = pattern.matcher("foo\\:x bar:y"); if (matcher.find()) { System.out.println(matcher.start()); } Output: 10
type: Answer
accepted answer of: http://stackoverflow.com/q/2709839
answers question: http://stackoverflow.com/q/2709839

http://stackoverflow.com/a/2605960
accepted answer of: http://stackoverflow.com/q/2605931
has body: It's an interesting question, but to be honest I'm not convinced that considering Hotspot's behaviour here will yield useful information. Any answers you do get are not going to be transferable in a general case (because we're looking at the optimisations that Hotspot performs in one specific situation), so they'll help you understand why one no-op is faster than another, but they won't help you write faster "real" programs. It's also incredibly easy to write very misleading micro benchmarks around this sort of thing - see this IBM DW article for some of the common pitfalls, how to avoid them and some general commentary on what you're doing. So really this is a "no comment" answer, but I think that's the only valid response. A compile-time-trivial no-op loop doesn't need to be fast, so the compiler isn't optimised to be fast in some of these conditions.
downvote count: 0
score: 5
type: AcceptedAnswer
upvote count: 5
answers question: http://stackoverflow.com/q/2605931
has comment: http://stackoverflow.com/comment/2616006
type: Answer

http://stackoverflow.com/a/4555487
downvote count: 1
has body: Instead of using your own flag, you can use the flag set automatically by ADT, like this: final static int appFlags = context.getApplicationInfo().flags; final static boolean isDebug = (appFlags &amp; ApplicationInfo.FLAG_DEBUGGABLE) != 0 The FLAG_DEBUGGABLE bit is automatically set to true or false, depending on the "debuggable" attribute of the application (set in AndroidManifest.xml). The latest version of ADT (version 8) automatically sets this attribute for you when not exporting a signed package. Thus, you don't have to remember setting / resetting your own custom flag. You can read more in this thread.
upvote count: 57
answers question: http://stackoverflow.com/q/2718565
type: Answer
score: 56

http://stackoverflow.com/q/2607613
has body: I'm writing an application wherein users will sometimes make orders through it. I want to give users the option to save their billing info (name, address, etc.) so that it can be quickly restored later if they want to make another order. The user will enter a password to secure the data. Obviously I can't just put this as a file on the device, as anyone can root/find the data. Is there a built-in Android method for storing secure data that is locked with a password? If not, what is a good place to start for storing this data securely using Java? Edit: To clarify, when I say that the user will enter a password, I don't mean that I've come up with a way to secure the data yet. I'm just trying to convey the method with which the user will secure the data on their end; now I'm trying to figure out how to keep my end of the bargain. :)
tagged with: android
accepted answer: http://stackoverflow.com/a/2607731
has answer: http://stackoverflow.com/a/15430249
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2618810
type: Question
possible better answer: http://stackoverflow.com/a/2607708
has title: Is there a way to securely store user data on an Android device?
has answer: http://stackoverflow.com/a/2607708
tagged with: java
score: 10
upvote count: 10
has comment: http://stackoverflow.com/comment/2618851
has answer: http://stackoverflow.com/a/2607731
downvote count: 0
has comment: http://stackoverflow.com/comment/2618711
favorite count: 0
tagged with: security
answer count: 3

http://stackoverflow.com/comment/2760173
comment on: http://stackoverflow.com/a/2721808
has text: Sorry my answer wasn't clear enough, but it looks like you figured it out. I did indeed mean `final LocalDate myDate = new LocalDate("2010-04-28");`
score: 1
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2785310
comment on: http://stackoverflow.com/q/2753741
score: 0
has text: Ok i found some more information. I tried saving the image as a png file and the colours are correct. So it's the jpg encoder that seems to be incorrect. It's really important for me to save the image as a jpg file as png files are large. Anybody have any further information? Is there maybe another mechanism to save the image as a jpg file, perhaps through the Toolkit?
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/62219822
comment on: http://stackoverflow.com/a/2667975
type: Comment
score: 1
has text: > What do you mean by "using the debugger -> by hand, too slow"? - For example, from my experience, when you have to debug remotely. But sometimes remote debugger attachment is not even possible.
type: AnswerComment

instantiation
type: Tag
tags question: http://stackoverflow.com/q/2728097
tag name: instantiation

http://stackoverflow.com/q/2647677
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2647716
downvote count: 0
has answer: http://stackoverflow.com/a/2647716
favorite count: 0
has answer: http://stackoverflow.com/a/2647715
linked to: http://stackoverflow.com/q/1215207
type: Question
has title: Help with enums in Java
upvote count: 6
has answer: http://stackoverflow.com/a/2647778
has body: Is it possible to have an enum change its value (from inside itself)? Maybe it's easier to understand what I mean with code: enum Rate { VeryBad(1), Bad(2), Average(3), Good(4), Excellent(5); private int rate; private Rate(int rate) { this.rate = rate; } public void increateRating() { //is it possible to make the enum variable increase? //this is, if right now this enum has as value Average, after calling this //method to have it change to Good? } } This is want I wanna achieve: Rate rate = Rate.Average; System.out.println(rate); //prints Average; rate.increaseRating(); System.out.println(rate); //prints Good Thanks
tagged with: java
accepted answer: http://stackoverflow.com/a/2647709
tagged with: enums
has answer: http://stackoverflow.com/a/2647709
score: 6
answer count: 4

http://stackoverflow.com/q/2783007
score: 6
has answer: http://stackoverflow.com/a/2786837
tagged with: swallowed-exceptions
tagged with: junit
has answer: http://stackoverflow.com/a/2783109
downvote count: 0
has answer: http://stackoverflow.com/a/2783209
favorite count: 0
has title: Is there a way to force JUnit to fail on ANY unchecked exception, even if swallowed
type: Question
has comment: http://stackoverflow.com/comment/2818158
has answer: http://stackoverflow.com/a/2783032
upvote count: 6
answer count: 6
has answer: http://stackoverflow.com/a/2786219
tagged with: java
has body: I am using JUnit to write some higher level tests for legacy code that does not have unit tests. Much of this code "swallows" a variety of unchecked exceptions like NullPointerExceptions (e.g., by just printing stack trace and returning null). Therefore the unit test can pass even through there is a cascade of disasters at various points in the lower level code. Is there any way to have a test fail on the first unchecked exception even if they are swallowed? The only alternative I can think of is to write a custom JUnit wrapper that redirects System.err and then analyzes the output for exceptions.
has comment: http://stackoverflow.com/comment/2818255
tagged with: unit-testing
has answer: http://stackoverflow.com/a/2783124
type: UnansweredQuestion

http://stackoverflow.com/q/2668364
has title: What's the easiest way to implement background downloading in Wicket?
upvote count: 3
tagged with: java
answer count: 1
has answer: http://stackoverflow.com/a/2669699
accepted answer: http://stackoverflow.com/a/2669699
has body: I've got a simple Wicket form that lets users select some data and then download a ZIP file (generated on the fly) containing what they asked for. Currently the form button's onSubmit() method looks something like this: public void onSubmit() { IResourceStream stream = /* assemble the data they asked for ... */ ; ResourceStreamRequestTarget target = new ResourceStreamRequestTarget(stream); target.setFileName("download.zip"); RequestCycle.get().setRequestTarget(target); } This works, but of course the request stops there and it's impossible to display any other feedback to the user. What I'd like to have is something like the typical "Your requested download [NAME] should begin automatically. If not, click this link." Ideally, still displaying the same page, so the user can immediately select some different data and download that as well. I imagine it's possible to do this using Wicket's Ajax classes, but I've managed to avoid having to use them so far, and it's not immediately obvious to me how. What's my quickest way out, here? Updated per answer from Zeratul, below: what I ended up with was something like this: class MyDownloader extends AbstractAjaxBehavior { private final MyForm form; MyDownloader(MyForm form) { this.form = form; } void startDownload(AjaxRequestTarget target) { target.addComponent(myForm); target.appendJavascript("window.location.href='" + getCallbackUrl() + "'"); } @Override public void onRequest() { try { ResourceStreamRequestTarget streamTarget = form.getStreamTarget(); form.info(/* some status message */); getComponent().getRequestCycle().setRequestTarget(streamTarget); catch (SomeException e) { form.error(e.getMessage()); } } } class MyForm extends Form { private final MyDownloader myDownloader; private final Object myModel; MyForm(Object aModel) { super("myForm"); myModel = aModel; myDownloader = new MyDownloader(this); add(myDownloader); add(/* form components */); add(new AjaxButton("download", new Model&lt;String&gt;("Download"), this) …
type: AnsweredQuestion
score: 3
downvote count: 0
favorite count: 0
type: Question
tagged with: wicket

http://stackoverflow.com/q/2632757
linked to: http://stackoverflow.com/q/815787
type: AnsweredQuestion
downvote count: 0
has title: check for naming convention in java
score: 1
has answer: http://stackoverflow.com/a/2634405
favorite count: 0
type: Question
answer count: 2
accepted answer: http://stackoverflow.com/a/2634405
tagged with: reflection
tagged with: java
upvote count: 1
linked to: http://stackoverflow.com/q/773303
has comment: http://stackoverflow.com/comment/2647998
has body: through java reflection how to check that method name is in camelCase? e.g. import java.lang.reflect.*; public class TestClass { private int simpleMethod( Object p, int x) throws NullPointerException { if (p == null) throw new NullPointerException(); return x; } public static void main(String args[]) { try { Class cls = Class.forName("method1"); Method methlist[] = cls.getDeclaredMethods(); for (int i = 0; i &lt; methlist.length; i++) { Method m = methlist[i]; System.out.println("name= " + m.getName()); } } catch (Throwable e) { System.err.println(e); } } } here i am getting method names simpleMethod and main i have to check that these names are in camelCase.
possible better answer: http://stackoverflow.com/a/2632777
has answer: http://stackoverflow.com/a/2632777
linked to: http://stackoverflow.com/q/2559759

http://stackoverflow.com/q/2646773
tagged with: regex
has answer: http://stackoverflow.com/a/2646815
type: AnsweredQuestion
score: 3
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/2647092
has answer: http://stackoverflow.com/a/2646854
accepted answer: http://stackoverflow.com/a/2646854
type: Question
has comment: http://stackoverflow.com/comment/2662099
has body: I want to remove ) character from the end of a string through a regex. E.g If a string is UK(Great Britain) then I want to replace the last ) symbol. Note: 1). The regex should remove only the last ) symbol, doesn't matter how many ) symbols are present in the string.
has title: Java - Regex problem
upvote count: 3
has answer: http://stackoverflow.com/a/2646841
possible better answer: http://stackoverflow.com/a/2647092
has answer: http://stackoverflow.com/a/2646830
favorite count: 0
answer count: 5

http://stackoverflow.com/comment/2699376
type: QuestionComment
type: Comment
score: 0
has text: thanks for the correction again WizardOfOdds.
comment on: http://stackoverflow.com/q/2679503

http://stackoverflow.com/comment/2745446
comment on: http://stackoverflow.com/a/2718917
type: AnswerComment
has text: Thanks for your answer mdma! I'm just wondering, how can I be sure that array() will work? The Javadoc says "Invoke the hasArray method before invoking this method in order to ensure that this buffer has an accessible backing array." And allocateDirect() tells me "Whether or not it has a backing array is unspecified." I wonder if that wil work?
score: 0
type: Comment

http://stackoverflow.com/a/2767351
score: 0
type: Answer
answers question: http://stackoverflow.com/q/2767274
has body: If you're really against the arbitrary ordering that comes from a 2d array or a collection, perhaps consider making an inner class that reflects the logic of what you're doing. You could simply define a class that holds two arrays and you could have your method return that, with names and function that reflect the logic of exactly what you're doing.

http://stackoverflow.com/a/9291146
has body: You can solve this with the help of Java's robot class. Use the robot class to take a screenshot, then wait for lets say 60 seconds and take another screenshot. Compare the screenshots with each other to see if any changes has happened, but don't just compare the screenshots pixel by pixel. Check for the percentage of the pixels that has changed. The reason is that you don't want small differences like Windows clock to interfere with the result. If the percentage is less that 0.005% (or whatever), then the computer is probably idling. import java.awt.AWTException; import java.awt.DisplayMode; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.Rectangle; import java.awt.Robot; import java.awt.Toolkit; import java.awt.image.BufferedImage; public class CheckIdle extends Thread { private Robot robot; private double threshHold = 0.05; private int activeTime; private int idleTime; private boolean idle; private Rectangle screenDimenstions; public CheckIdle(int activeTime, int idleTime) { this.activeTime = activeTime; this.idleTime = idleTime; // Get the screen dimensions // MultiMonitor support. int screenWidth = 0; int screenHeight = 0; GraphicsEnvironment graphicsEnv = GraphicsEnvironment .getLocalGraphicsEnvironment(); GraphicsDevice[] graphicsDevices = graphicsEnv.getScreenDevices(); for (GraphicsDevice screens : graphicsDevices) { DisplayMode mode = screens.getDisplayMode(); screenWidth += mode.getWidth(); if (mode.getHeight() &gt; screenHeight) { screenHeight = mode.getHeight(); } } screenDimenstions = new Rectangle(0, 0, screenWidth, screenHeight); // setup the robot. robot = null; try { robot = new Robot(); } catch (AWTException e1) { e1.printStackTrace(); } idle = false; } public void run() { while (true) { BufferedImage screenShot = robot .createScreenCapture(screenDimenstions); try { Thread.sleep(idle ? idleTime : activeTime); } catch (InterruptedException e) { e.printStackTrace(); } BufferedImage screenShot2 = robot .createScre…
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/18392142
upvote count: 2
has comment: http://stackoverflow.com/comment/18333977
answers question: http://stackoverflow.com/q/2777594
downvote count: 0

http://stackoverflow.com/a/2749351
type: AcceptedAnswer
score: 0
has body: I may be wrong, but the line number shouldn't be relevant to your XML parser/reader as long as the XML structure itself is valid. You might try to extrapolate the line-number programatically on the assumption that each node/content must be on a distinct line but it's going to be tricky.
type: Answer
upvote count: 1
downvote count: 1
answers question: http://stackoverflow.com/q/2747416
accepted answer of: http://stackoverflow.com/q/2747416

http://stackoverflow.com/a/2772712
type: Answer
score: 4
has body: This is the best free tutorial on the net for linux/unix socket programming in C. https://beej.us/guide/bgnet/html/multi/index.html It has example code. If you want to get serious, buy the Unix Network Programming books by W. Richard Stevens. I've also done sockets in Java, and they're really easy. Not to mention that concurrency in Java is also really easy, and often necessary when writing network programs. Just googling java socket should get your the documentation from sun's website for that. Your C++ solution will just use the unix sockets api, so it would be no different than the C solution. For this reason, I see it as unnecessary to use C++. Edit: So, I recently tried boost.asio. It's a decent solution if you like the async paradigm, try it with C++!
answers question: http://stackoverflow.com/q/2772310
upvote count: 4
accepted answer of: http://stackoverflow.com/q/2772310
downvote count: 0
type: AcceptedAnswer

http://stackoverflow.com/a/2709916
has comment: http://stackoverflow.com/comment/2734319
has comment: http://stackoverflow.com/comment/2734309
upvote count: 1
has comment: http://stackoverflow.com/comment/2734304
has comment: http://stackoverflow.com/comment/2734383
answers question: http://stackoverflow.com/q/2709888
type: Answer
has body: I'm not sure what are you trying to do with this, public SomeClass(){ new SomeClass(r.nextInt(5)); } but I suspect the correct syntax (if you want to call the other constructor) is public SomeClass(){ this(r.nextInt(5)); } You should post the code of the outside class to understand your problem.
downvote count: 0
score: 1

http://stackoverflow.com/comment/115021377
comment on: http://stackoverflow.com/a/2772214
has text: @MichaelDorst Generics was introduced in JDK 1.5, the System.arrayCopy() method was introduced either in 1.0 or 1.1.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/5998148
score: 2
has comment: http://stackoverflow.com/comment/55477172
upvote count: 3
has body: Yeah, using a static object is by far the easiest way of doing this with custom non-serialisable objects.
downvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/2736389

http://stackoverflow.com/a/2776605
score: 1
has comment: http://stackoverflow.com/comment/2811489
downvote count: 1
has body: The best solution is to follow a design pattern. A State based design pattern defines a class per each state. The state class then encapsulates what is the course of action for that particular state. This not only prevents a large junk of if -else statement mesh.
upvote count: 2
type: Answer
answers question: http://stackoverflow.com/q/2772303

http://stackoverflow.com/a/2622084
has body: To run a .jar file from the command line, just use: java -jar YourJar.jar To do this as a batch file, simply copy the command to a text file and save it as a .bat: @echo off java -jar YourJar.jar The @echo off just ensures that the second command is not printed.
answers question: http://stackoverflow.com/q/2622062
type: Answer
has comment: http://stackoverflow.com/comment/2635108
downvote count: 0
has comment: http://stackoverflow.com/comment/2641885
score: 7
upvote count: 7

http://stackoverflow.com/a/2784145
type: Answer
has body: You forgot to update the mask: for(int i=1; i&lt;=32; i++) { if( (mask &amp; number) != 0 ) System.out.print(1); else System.out.print(0); if( (i % 4) == 0 ) System.out.print(" "); mask = mask &gt;&gt; 1; }
answers question: http://stackoverflow.com/q/2784133
has comment: http://stackoverflow.com/comment/2821549
score: 5
upvote count: 5
accepted answer of: http://stackoverflow.com/q/2784133
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/2674174
has answer: http://stackoverflow.com/a/32914192
tagged with: java
tagged with: concurrency
has answer: http://stackoverflow.com/a/2674265
type: Question
has title: What is the difference between Thread.start() and Thread.run()?
accepted answer: http://stackoverflow.com/a/2674175
downvote count: 0
favorite count: 0
answer count: 9
has answer: http://stackoverflow.com/a/24013057
has answer: http://stackoverflow.com/a/23957000
score: 48
upvote count: 48
linked to: http://stackoverflow.com/q/262816
possible better answer: http://stackoverflow.com/a/2674240
has answer: http://stackoverflow.com/a/2674240
has answer: http://stackoverflow.com/a/13134168
has answer: http://stackoverflow.com/a/2674175
has answer: http://stackoverflow.com/a/33303180
tagged with: multithreading
has body: Why do we call the start() method, which in turn calls the run() method? Can't we directly make a call to run()? Please give an example where there is a difference.
has answer: http://stackoverflow.com/a/2674509
type: AnsweredQuestion

http://stackoverflow.com/q/2775359
type: Question
has comment: http://stackoverflow.com/comment/2810039
answer count: 1
downvote count: 0
has comment: http://stackoverflow.com/comment/2809737
score: 4
has title: Specific Shopping Cart Recommendations
has answer: http://stackoverflow.com/a/2793872
tagged with: e-commerce
upvote count: 4
favorite count: 0
type: UnansweredQuestion
tagged with: php
has body: I'm trying to suggest a solution for a friend who owns an existing web shop. The current solution isn't cutting it. The new solution needs to have a few things that look like they're enterprise-only if I go with Magento, and $12k a year for a store with maybe $20k in stock just doesn't work. The site should have items, which have one or more categories. Each category may have a parent category. Items have MSRP, and a discount rate by supplier, brand, and sometimes additional discount by product. When a user buys something, it should automatically setup a shipping label with UPS or USPS, depending on user's choice, and build two invoices; one to go in the box, one to go into records. This is crucial; it's low profit per item, so it needs to minimize labor here. Need to be able to have sales (limited by time), discount codes/coupon codes. Ideally would have private sales and/or members-only rates as well. It needs a payment gateway; Paypal/GCheckout-only isn't going to fly. Must be able to accept Visa/MC. Suggestions? I'm debating just building this myself in Java or PHP, but wanted to point my friend to a reasonable-cost solution that already exists if I can. This all seems pretty straightforward to code, save working with the UPS/USPS/Visa/MC APIs, and doing CSS for it.
tagged with: java
tagged with: shopping-cart

http://stackoverflow.com/a/2715161
score: 1
type: Answer
has body: I just want to add, that with unit testing, you can gain even more if you think first of the possible cases and after that implement in the test driven development fashion, because this will help you stay focuesed on the current case and this will enable you to create easiest implementation possible in DRY fashion. You might also be usng some test coverage tool, e.g. in Eclipse EclEmma, which is really easy to use and will show you if tests have executed all of your code, which might help you to determine when it is enough (although this is not a proof, just a metric). Generally when it comes to unit testing I was much inspired by Kent Becks's Test Driven Development by Example book, I strongly recommend it.
answers question: http://stackoverflow.com/q/2710545
upvote count: 1
downvote count: 0

http://stackoverflow.com/comment/2796505
type: Comment
type: QuestionComment
has text: you forgot how the line looks like that does the printing.
comment on: http://stackoverflow.com/q/2764031
score: 0

http://stackoverflow.com/comment/113101926
has text: Thank you for this answer, it saved my day. I don't have the admin rights to write in C drive where I have my JDK installed. I appended "-Djavax.net.ssl.trustStore=<MyLocation>" into Tomcat Catalina and it worked.
type: Comment
score: 1
comment on: http://stackoverflow.com/a/2645939
type: AnswerComment

http://stackoverflow.com/a/2675543
downvote count: 0
has body: I assume this is related to UTF-8 formatting in SPARQL? Having looked at it here's what's happened: Importer took input 'Chodovská tvrz' encoded in utf-8. In utf-8 that's: '43 68 6f 64 6f 76 73 6b c3 a1 20 74 76 72 7a' (c3 a1 is 'á' in utf-8) Importer read those bytes instead as unicode characters. So instead of 'á' you get the two characters c3 a1, which are 'Ã' and '¡'. You can reverse that by turning the characters of the string to a byte array, then making a new string from it. I'm sure there must be a simpler way, but here's an example: public class Convert { public static void main(String... args) throws Exception { String in = "Chodovsk\u00C3\u00A1 tvrz"; char[] chars = in.toCharArray(); // make a new string by treating chars as bytes String out = new String(fix(chars), "utf-8"); System.err.println("Got: " + out); // Chodovská tvrz } public static byte[] fix(char[] a) { byte[] b = new byte[a.length]; for (int i = 0; i &lt; a.length; i++) b[i] = (byte) a[i]; return b; } } Using this on list.get(i).get("churchname").toString() (which is what you are printing) will fix those names. Edit: Or just use: String churchname = list.get(i).get("churchname").toString(); String out2 = new String(churchname.getBytes("iso-8859-1"), "utf-8"); Which is much simpler.
type: Answer
has comment: http://stackoverflow.com/comment/2694919
has comment: http://stackoverflow.com/comment/2695123
score: 5
upvote count: 5
answers question: http://stackoverflow.com/q/2674633

http://stackoverflow.com/comment/2700970
score: 0
type: AnswerComment
has text: Based on the feedback here I have decided to use constructor injection and to remove the default constructor as the parent of a component can never change by design (immutable heritage). There is a single interface type that is permitted to have an empty parent and all methods that call getParent() are aware that the top node will return null. If any other type of class provides null in the constructor then I throw an IllegalArgumentException so that it will fail fast. I also documented in the code that parent should always be non-null (along with the exceptional case).
type: Comment
comment on: http://stackoverflow.com/a/2680720

http://stackoverflow.com/a/47310438
type: Answer
has body: You can try: <logout invalidate-session="true" logout-url="/LoginPage.jsf?error_logout=logoutComSucesso"/>
answers question: http://stackoverflow.com/q/2693268
has comment: http://stackoverflow.com/comment/81572764
score: 0

http://stackoverflow.com/q/2724222
has body: Below is an example that is producing an exception in Java (and not matching the input). Perhaps I misunderstood the JavaDoc, but it looks like it should work. Using the same pattern and input in C# will produce a match. import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void main(String[] args) { String pattern = "aspx\\?uid=([^']*)"; Pattern p = Pattern.compile(pattern); Matcher m = p.matcher("id='page.aspx?uid=123'"); System.out.println(m.groupCount() &gt; 0 ? m.group(1) : "No Matches"); } } EDIT: I should note the JavaDoc says the following about Matcher.groupCount Any non-negative integer smaller than or equal to the value returned by this method is guaranteed to be a valid group index for this matcher.
tagged with: regex
has comment: http://stackoverflow.com/comment/2750960
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/2750821
type: Question
score: 0
answer count: 2
has title: Java RegEx Pattern not matching (works in .NET)
possible better answer: http://stackoverflow.com/a/2724270
has answer: http://stackoverflow.com/a/2724274
has answer: http://stackoverflow.com/a/2724270
accepted answer: http://stackoverflow.com/a/2724274

http://stackoverflow.com/comment/2748718
type: QuestionComment
has text: But did you add it to the classpath?
comment on: http://stackoverflow.com/q/2719983
score: 0
type: Comment

http://stackoverflow.com/comment/77462620
comment on: http://stackoverflow.com/a/2658941
has text: Great answer @BalusC Thanks a bunch! Quick question though if you don't mind. So i shouldn't escape html on user input, only when displaying it? Is that what you mean by double escaping? And if not, how does one go about escaping user input using a textarea, not an input field? Is ( htmlEscape="true" ) correct?
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/2764039
upvote count: 1
score: 1
has body: Ok, so using aioobe's original suggestion (which i also tried earlier), I have: String regexDate = "Expiry Date:(.+?) "; Pattern p = Pattern.compile(regexDate); Matcher m = p.matcher(returnedHTML); if (m.matches()) // check if it matches (and "generate the groups") { System.out.println("*******REGEX RESULT*******"); System.out.println(m.group(1)); // prints whatever the .+? expression matched. System.out.println("*******REGEX RESULT*******"); } The IF statement must keep coming up FALSE as the *******REGEX RESULT******* is never outputted. If anyone missed what I am trying to achieve, I am just wanting to get the date out. Amongst a html page is a date like Expiry Date: 03 May 2010 and I want the 03 May 2010.
downvote count: 0
has comment: http://stackoverflow.com/comment/2796588
has comment: http://stackoverflow.com/comment/2797227
type: Answer
answers question: http://stackoverflow.com/q/2758708

http://stackoverflow.com/comment/123683682
type: Comment
comment on: http://stackoverflow.com/a/69930984
score: 1
has text: Thanks for this solution. Initially I wanted to go with `@ScriptAssert`, but some beans have many rules needing validation, so this is much more intuitive: one validation method per rule.
type: AnswerComment

http://stackoverflow.com/q/2696034
has answer: http://stackoverflow.com/a/3041018
type: Question
accepted answer: http://stackoverflow.com/a/2696069
tagged with: berkeley-db
answer count: 2
score: 2
downvote count: 0
has title: Inserting records into Berkeley DB with Java
has body: I can't seem to find sample code for constructing a Berkeley DB in Java and inserting records into it. Any samples? And I do not mean the Berkeley DB Java Edition either.
favorite count: 0
has answer: http://stackoverflow.com/a/2696069
type: AnsweredQuestion
upvote count: 2
tagged with: java
possible better answer: http://stackoverflow.com/a/3041018

http://stackoverflow.com/q/2782780
has answer: http://stackoverflow.com/a/2782836
answer count: 2
downvote count: 1
has body: This code isn't working. Can you help me fix it? // need to get next parameter static double getParametr() { Scanner scanner = new Scanner(System.in); param = scanner.nextDouble(); return param; } // ... // ... if (i==1) { System.out.println("vvedite storoni pryamougolnika: "); Shape parA = new Rectangle(); parA.a = Shape.getParametr(); --- this is ok double aa = parA.a; Shape parB = new Rectangle(); parB.b = Shape.getParametr(); ------ this is no work!!! double bb = parB.b; Rectangle rec = new Rectangle(aa, bb); arrayFigur[i] = rec.area(); }
has comment: http://stackoverflow.com/comment/2817930
tagged with: java
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/15090929
has comment: http://stackoverflow.com/comment/2817886
has comment: http://stackoverflow.com/comment/2818013
upvote count: 0
has comment: http://stackoverflow.com/comment/2817949
favorite count: 0
has title: correct method "get next value"
type: Question
has answer: http://stackoverflow.com/a/2782919
score: -1

http://stackoverflow.com/comment/2687874
comment on: http://stackoverflow.com/a/2669420
type: AnswerComment
score: 0
type: Comment
has text: Hum yes but I don't think that's the origin of my problem ... no ?

http://stackoverflow.com/comment/2800846
type: QuestionComment
has text: I agree it does seem like a waste.
score: 0
comment on: http://stackoverflow.com/q/2767442
type: Comment

http://stackoverflow.com/comment/2755993
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2728143
has text: Good, matter settled than. Thank you for help :)

http://stackoverflow.com/q/2632175
downvote count: 0
tagged with: query-string
possible better answer: http://stackoverflow.com/a/6926987
has body: I need to decode a URI that contains a query string; expected input/output behavior is something like the following: abstract class URIParser { /** example input: * something?alias=pos&amp;FirstName=Foo+A%26B%3DC&amp;LastName=Bar */ URIParser(String input) { ... } /** should return "something" for the example input */ public String getPath(); /** should return a map * {alias: "pos", FirstName: "Foo+A&amp;B=C", LastName: "Bar"} */ public Map&lt;String,String&gt; getQuery(); } I've tried using java.net.URI, but it seems to decode the query string so in the above example I'm left with "alias=pos&amp;FirstName=Foo+A&amp;B=C&amp;LastName=Bar" so there is ambiguity whether a "&amp;" is a query separator or is a character in a query component. Edit: I just tried URI.getRawQuery() and it doesn't do the encoding, so I can split the query string with a &amp;, but then what do I do? Javascript has decodeURIComponent, I can't seem to find the corresponding method in Java. Any suggestions? I would prefer not to use any new libraries.
favorite count: 0
has answer: http://stackoverflow.com/a/6926987
score: 35
answer count: 5
has answer: http://stackoverflow.com/a/36356195
has comment: http://stackoverflow.com/comment/2646057
has title: Decoding URI query string in Java
has answer: http://stackoverflow.com/a/61721591
tagged with: decoding
has answer: http://stackoverflow.com/a/2632368
type: Question
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/41148424
accepted answer: http://stackoverflow.com/a/2632368
upvote count: 35

http://stackoverflow.com/q/2755752
score: 0
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2755788
tagged with: java
tagged with: render
has body: Could someone provide an example of how to dynamically create an image in Java, draw lines et cetera on it, and then draw the image so that areas not painted will remain transparent in the drawing process?
tagged with: image
has title: Creating and rendering an image dynamically with transparent background for use with drawImage
tagged with: draw
type: Question
answer count: 1
tagged with: transparency
has answer: http://stackoverflow.com/a/2755788

http://stackoverflow.com/comment/70652763
has text: Please note that [the issue](https://bugs.openjdk.java.net/browse/JDK-6721089) @user1084563 refers to is fixed with Java 8 (confirmed with openjdk-8-jdk-headless_8u111-b14-2~bpo8+1_amd64.deb and zulu8.19.0.1-jdk8.0.112-win_x64.zip).
type: Comment
comment on: http://stackoverflow.com/a/2781738
score: 1
type: AnswerComment

http://stackoverflow.com/q/2608452
score: 3
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2608567
tagged with: android
type: AnsweredQuestion
upvote count: 3
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/2608567
tagged with: session
possible better answer: http://stackoverflow.com/a/23336816
has title: How to keep the session of user login?
has answer: http://stackoverflow.com/a/23336816
has body: I have an app that requires user to register. I've got the app conected to PHP in my server to do the logic of register/login and so, this is not problem at all. But, I want to keep a session of the user in local, so the user doesn't have to login again every time he runs the app. So, I want something like this: First time user, he opens the app, register and login. Do some stuff with the app and closes it. Open the app again, the user is recognized so he doesn't need to login again. I only need to store an ID and a Username (both fetched from the DB in the login php method). What's the best way to do this?? I've thought about doing a custom preference, store the data in files or even a local DB (sqlite). Any suggestions?
answer count: 2

http://stackoverflow.com/a/19347078
type: Answer
score: 0
answers question: http://stackoverflow.com/q/2617369
has body: I have found that his original statement it true. removeAll works automatically only if you override the remove in the iterator. Just overriding the remove in the Collection is not enough because the removeAll (and clear and retainAll) all use the iterator to work. Since you should not change the underlying collection while using the iterator except for the remove in the iterator, if you do not override the remove in the iterator, the removeAll, clear and retainAll will not work. If you throw an UnsupportedOperationException in the remove method inside the iterator, that is what you will see if you call one of the three methods discussed.

http://stackoverflow.com/q/2685524
upvote count: 8
type: Question
tagged with: math
has answer: http://stackoverflow.com/a/46233624
has answer: http://stackoverflow.com/a/57452269
downvote count: 0
answer count: 7
has answer: http://stackoverflow.com/a/58893470
has title: Check if BigInteger is not a perfect square
has answer: http://stackoverflow.com/a/2685732
possible better answer: http://stackoverflow.com/a/2685721
favorite count: 0
has answer: http://stackoverflow.com/a/2685668
has comment: http://stackoverflow.com/comment/8123496
accepted answer: http://stackoverflow.com/a/2685668
has comment: http://stackoverflow.com/comment/2705748
has comment: http://stackoverflow.com/comment/2705711
has comment: http://stackoverflow.com/comment/2705698
has comment: http://stackoverflow.com/comment/2705961
score: 8
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2705691
has comment: http://stackoverflow.com/comment/2706151
tagged with: biginteger
tagged with: java
has answer: http://stackoverflow.com/a/68081115
has body: I have a BigInteger value, let's say it is 282 and is inside the variable x. I now want to write a while loop that states: while b2 isn't a perfect square: a ← a + 1 b2 ← a*a - N endwhile How would I do such a thing using BigInteger? EDIT: The purpose for this is so I can write this method. As the article states one must check if b2 is not square.
has comment: http://stackoverflow.com/comment/2705724
has answer: http://stackoverflow.com/a/2685721

http://stackoverflow.com/q/2752277
score: 1
tagged with: java
has title: Java Swing automatically gather data from forms
has body: I have a form in Swing with a lot of textfields receiving data. The idea is when a button is clicked, the app gathers all the data from the textfields at once. Do you know a good practice for this? Or is it necessary to gather the data textfield by textfield?
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/2752324
upvote count: 1
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2752316
tagged with: swing
has comment: http://stackoverflow.com/comment/2782893
downvote count: 0

http://stackoverflow.com/q/2682364
answer count: 1
score: 0
has body: I have a scenario in which i`m getting a number of tiles (e.g.12) from my mapping server. Now for buffering and offline functions I need to join them all back again so that we have to deal with 1 single image object instead of 12. I ve tried to do it without JAI my code is below. package imagemerge; import java.awt.*; import java.awt.image.*; import java.awt.event.*; public class ImageSticher extends WindowAdapter { Image tile1; Image tile2; Image result; ColorModel colorModel; int width,height,widthr,heightr; //int t1,t2; int t12[]; public ImageSticher() { } public ImageSticher (Image img1,Image img2,int w,int h) { tile1=img1; tile2=img2; width=w; height=h; colorModel=ColorModel.getRGBdefault(); } public Image horizontalStich() throws Exception { widthr=width*2; heightr=height; t12=new int[widthr * heightr]; int t1[]=new int[width*height]; PixelGrabber p1 =new PixelGrabber(tile1, 0, 0, width, height, t1, 0, width); p1.grabPixels(); int t2[]=new int[width*height]; PixelGrabber p2 =new PixelGrabber(tile2, 0, 0, width, height, t1, 0, width); p2.grabPixels(); int y, x, rp, rpi; int red1, red2, redr; int green1, green2, greenr; int blue1, blue2, bluer; int alpha1, alpha2, alphar; for(y=0;y&lt;heightr;y++) { for(x=0;x&lt;widthr;x++) { //System.out.println(x); rpi=y*widthr+x; // index of resulting pixel; rp=0; //initializing resulting pixel System.out.println(rpi); if(x&lt;(widthr/2)) // x is less than width , copy first tile { //System.out.println("tile1="+x); blue1 = t1[rpi] &amp; 0x00ff; // ERROR occurs here green1=(t1[rpi] &gt;&gt; 8) &amp; 0x00ff; red1=(t1[rpi] &gt;&gt; 16) &amp; 0x00ff; alpha1 = (t1[rpi] &gt;&gt; 24) &amp; 0x00ff; redr = (int)(red1 * 1.0); // copying red band pixel into redresult,,,,1.0 is the alpha valye redr = (redr &lt; 0)?(0):((redr&gt;255)?(255):(redr)); greenr = (int)(green1 * 1.0); // redr = (int)(red1 * 1.0); // greenr = (greenr &lt; 0)?(0):((greenr&gt;255)?(255):(greenr)); bluer = (int)(blue1 * 1.0); bluer = (bluer &lt; 0)?(0):((bluer&gt;25…
tagged with: mosaic
tagged with: swing
has answer: http://stackoverflow.com/a/2682417
accepted answer: http://stackoverflow.com/a/2682417
type: AnsweredQuestion
tagged with: join
tagged with: java
tagged with: image
type: Question
has title: How to Stich to Image objects in Java

http://stackoverflow.com/comment/2717988
comment on: http://stackoverflow.com/a/2693483
has text: Excellent. See also @Kevin Brock's informative answer: http://stackoverflow.com/questions/2693223/read-large-amount-of-data-from-file-in-java/2694507#2694507
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/2609997
comment on: http://stackoverflow.com/a/2600648
type: AnswerComment
has text: how to use that? i cant get u people. plz elobrate... :(
score: 0
type: Comment

http://stackoverflow.com/comment/10491316
type: Comment
has text: That line should read "Uri uri = intent.getParcelableExtra...". Note the lowecase "i" in "intent". Just a typo on the above code.
score: 1
comment on: http://stackoverflow.com/a/2726008
type: AnswerComment

http://stackoverflow.com/q/2596941
answer count: 1
has body: Does anyone know the value of the Java system property "os.name" on Windows Server 2008? I found a rally going here (Crowdsourcing a Complete list of Common Java System Properties and Known Values), but nothing on Windows Server 2008. Any help is appreciated.
score: 0
has answer: http://stackoverflow.com/a/3702575
tagged with: windows-server-2008
type: UnansweredQuestion
tagged with: system-properties
has title: os.name system property value in Java for Windows Server 2008
type: Question
linked to: http://stackoverflow.com/q/1803075
tagged with: java

http://stackoverflow.com/comment/2719962
comment on: http://stackoverflow.com/a/2697598
type: AnswerComment
score: 0
type: Comment
has text: My class is used as Date in numerous places, I cannot change that.

http://stackoverflow.com/a/2754947
type: Answer
has body: I think this might be closer to what you are looking for. Node newNode = new Node(someInt); Node current = head; //check head first if (current.data &gt; newNode.data) { newNode.next = head; head = newNode; } //check body else { while(true){ if(current == tail){ current.next = newNode; tail = newNode; break; } if(current.data &lt; someInt &amp;&amp; current.next.data &gt;= someInt){ newNode.next = current.next; current.next = newNode; break; } current = current.next; } }
upvote count: 4
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2786126
score: 4
accepted answer of: http://stackoverflow.com/q/2754891
answers question: http://stackoverflow.com/q/2754891
has comment: http://stackoverflow.com/comment/2786712
downvote count: 0

http://stackoverflow.com/a/16015448
type: Answer
score: 13
downvote count: 0
has body: Here's a short demonstration of what the unary plus will do to a Character variable: private static void method(int i){ System.out.println("int: " + i); } private static void method(char c){ System.out.println("char: " + c); } public static void main(String[] args) { Character ch = 'X'; method(ch); method(+ch); } The output of running this programme is: char: X int: 88 How it works: Unary + or - unbox their operand, if it's a wrapper object, then promote their operand to int, if not already an int or wider. So, as we can see, while the first call to method will choose the char overload (unboxing only), the second call will choose the int version of method. Variable ch of type Character will be passed into method as int argument because of the applied unary plus.
upvote count: 13
has comment: http://stackoverflow.com/comment/116371647
answers question: http://stackoverflow.com/q/2624410

http://stackoverflow.com/q/2662704
has comment: http://stackoverflow.com/comment/2680349
answer count: 2
has answer: http://stackoverflow.com/a/2662758
accepted answer: http://stackoverflow.com/a/2662741
score: 0
has answer: http://stackoverflow.com/a/2662741
has title: Java : Storing Data in Array Of Object from JOptionPane Dialog
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/2680255
has body: I need to know how I can insert data inside objects inside an array of objects using my already made Set methods. i need to know how should i do it through user , i mean JOptionPane input dialog student[] s = new student[5]; for (int i=1 ; i &lt;= s.length ;i++) { s[i] = new student(i,"AAA","Ecommerce",0.0); } for (int i=1; i&lt;=s.length;i++) { name = JOptionPane.showInputDialog("Please Write Name for student n " + i); major = JOptionPane.showInputDialog("Please Write Major for student n " + i); gpa = Double.parseDouble(JOptionPane.showInputDialog("Please Write GPA for student n " +i)); s[i] = new student(i,name,major,gpa); } I tried to do vars here that get data from user by JOptionPane, but it seems that i only use my already made constructor , not the Set methods. I need to use the methods because it has some validation code inside it. Any ideas?
possible better answer: http://stackoverflow.com/a/2662758
type: Question

http://stackoverflow.com/a/2622044
has comment: http://stackoverflow.com/comment/127971232
has comment: http://stackoverflow.com/comment/2634458
upvote count: 66
type: Answer
has comment: http://stackoverflow.com/comment/4691409
has comment: http://stackoverflow.com/comment/7115514
downvote count: 2
has comment: http://stackoverflow.com/comment/2634421
has comment: http://stackoverflow.com/comment/34606378
has comment: http://stackoverflow.com/comment/89572215
has comment: http://stackoverflow.com/comment/127970183
has comment: http://stackoverflow.com/comment/120510922
has body: There is no way to do this with slf4j 1.x. I imagine that the reason that this functionality is missing is that it is next to impossible to construct a Level type for slf4j that can be efficiently mapped to the Level (or equivalent) type used in all of the possible logging implementations behind the facade. Alternatively, the designers decided that your use-case is too unusual to justify the overheads of supporting it. Concerning @ripper234's use-case (unit testing), I think the pragmatic solution is modify the unit test(s) to hard-wire knowledge of what logging system is behind the slf4j facade ... when running the unit tests. UPDATE They intend to implement piecemeal construction of logging events (with dynamic logging levels) in slf4j 2.0; see https://jira.qos.ch/browse/SLF4J-124. According to @Ceki (see comments), it is implemented in the 2.0.0-alpha2 release.
accepted answer of: http://stackoverflow.com/q/2621701
has comment: http://stackoverflow.com/comment/4685508
score: 64
has comment: http://stackoverflow.com/comment/47772703
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2621701

http://stackoverflow.com/a/24624966
upvote count: 2
score: 2
has body: Tested with 4.3.3 import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import javax.net.ssl.SSLContext; import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.conn.ssl.SSLContexts; import org.apache.http.conn.ssl.TrustStrategy; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; public class AccessProtectedResource { public static void main(String[] args) throws Exception { // Trust all certs SSLContext sslcontext = buildSSLContext(); // Allow TLSv1 protocol only SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory( sslcontext, new String[] { "TLSv1" }, null, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); CloseableHttpClient httpclient = HttpClients.custom() .setSSLSocketFactory(sslsf) .build(); try { HttpGet httpget = new HttpGet("https://yoururl"); System.out.println("executing request" + httpget.getRequestLine()); CloseableHttpResponse response = httpclient.execute(httpget); try { HttpEntity entity = response.getEntity(); System.out.println("----------------------------------------"); System.out.println(response.getStatusLine()); if (entity != null) { System.out.println("Response content length: " + entity.getContentLength()); } for (Header header : response.getAllHeaders()) { System.out.println(header); } EntityUtils.consume(entity); } finally { response.close(); } } finally { httpclient.close(); } } private static SSLContext buildSSLContext() throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException { SSLContext sslcontext = SSLCon…
answers question: http://stackoverflow.com/q/2703161
downvote count: 0
has comment: http://stackoverflow.com/comment/57051141
type: Answer

http://stackoverflow.com/a/2766698
has comment: http://stackoverflow.com/comment/2799289
accepted answer of: http://stackoverflow.com/q/2766248
upvote count: 2
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2799802
type: Answer
score: 2
has body: What you have here is an interaction between a standard java issue and a standard IDEA behavior. Constant expressions like this are inlined in the class compilation (as per the Java Language Specification), so in fact the class referencing this constant did not change just because you removed the line (obviously) and there is no recorded dependency between the constant and the class anymore since it was inlined. This causes the compilation to not fail (the class wouldn't fail at runtime either if that was the only change - it will only fail when you do a clean build). One way around that in IDEA is to do a Build->Rebuild Project when you have such a change. The other is in Settings->Compiler there is an Honor Dependencies on "Compile" command. This can adversely affect performance in large projects (hence it is disabled by default), but is supposed to solve this kind of problem. The other part of this problem is that IDEA does not automatically recalculate all inspections on a change like that. It recalculates when you open a file. I'm not aware of a setting that makes IDEA do that. When you rebuild any problems found will get highlighted (up to where the compiler gave up), but the highlight won't go away until you open the class or recompile as well.
downvote count: 0
answers question: http://stackoverflow.com/q/2766248

http://stackoverflow.com/q/2609925
tagged with: java
has answer: http://stackoverflow.com/a/2610025
tagged with: servlets
type: Question
upvote count: 1
has answer: http://stackoverflow.com/a/2609976
has answer: http://stackoverflow.com/a/2610045
favorite count: 0
answer count: 3
has comment: http://stackoverflow.com/comment/2620383
downvote count: 0
has body: I am using a wrapper class A which initializes the java.util.logger static class A { public static Logger logger; public static void init(){ logger = Logger.getLogger("test"); } Now, everywhere in my program I call A.init() and then logger.log("Message+uniqid"). But recently I moved to HTTP servlets and I am having problems. Basically, If a app is already running and the logger is logging... and someone else runs the app again, the logger from the previous instance stops and starts logging for the second one. Can anyone have a solution to how I should go about fixing this static variable issue? I can pass the logger into all constructor classes but thats really tedious. Any better solution would be appreciated..
type: UnansweredQuestion
tagged with: logging
has title: Java Logger with Servlets
score: 1

http://stackoverflow.com/a/2788167
type: Answer
answers question: http://stackoverflow.com/q/2781604
score: 0
accepted answer of: http://stackoverflow.com/q/2781604
has body: Thank you very much for your advice Brad. In fact I have solved the problem myself, by generating more debug verbose in the application. Actually the activity uses the Compte class that loads the user credentials from files in the phone memory, and the service didn't. So the service didn't have the user credentials to log onto the HTML page. So the service sent login request with empty credentials, until the activity loaded them. Now that the service also loads the credentials using the Compte class, it works well. I am very sorry I didn't investigate more thoroughly my app. Thanks anyway Brad! Much appreciated.
type: AcceptedAnswer

http://stackoverflow.com/comment/2763498
comment on: http://stackoverflow.com/q/2710434
score: 0
type: Comment
type: QuestionComment
has text: Greg Wilkins tells me that TablePane.Row is no longer final as of version 1.5.

http://stackoverflow.com/a/4492898
downvote count: 2
has comment: http://stackoverflow.com/comment/28922727
score: 11
answers question: http://stackoverflow.com/q/2652126
upvote count: 13
has body: Edit 2023-07-13: Now a decade later the world has moved towards small, self contained deployments which mean that your program brings its own web server so you are not dependent on being deployed inside an application server and using what it provides (CDI in this answer). If so, you should not think of CDI (unless it is a hard requirement) but instead strongly consider spring boot which provides the bits and pieces you need, and very good documentation. ——- The most important feature CDI has opposed to Guice, is that it is a standard part of Java EE 6. The importance of this cannot be underestimated, as it means that CDI is the DI-standard you should use when coding web applications. A while back I had a look at the technologies to be able to determine how we could have a standard core distribution - suitably prepared - where we could add extra modules at will which could override existing functionality without having to change the core modules. I.e. add an extra jar, and the functionality activates automatically. It turned out that the best way for us to do this for a code base used in both desktop and web applications, was to use JSR-330 annotations for our code, and then use either CDI or Guice (SVN, coming real soon now in 3.0) as the engine. After a few projects I've found that I like the Guice configuration best instead of the opaque magic happening in Weld. Additionally I found that the way to do what we want as described above with Weld, I have to mark the class in the extra jar as @Alternative, and then mention in beans.xml that I want the alternative class enforced (and that is not robust against refactoring). But, all in all, JSR-330 allows us to do something which was very tedious and fragile before (because new binds so extremely tightly), and that is a great win. I can strongly recommend looking into DI if you have any need like this.
has comment: http://stackoverflow.com/comment/127939524
type: Answer
has comment: http://stackoverflow.com/comment/129966019
has comment: http://stackoverflow.com/comment/33945169

http://stackoverflow.com/comment/2745426
type: Comment
comment on: http://stackoverflow.com/a/2718636
score: 0
type: AnswerComment
has text: @Safyan, did not mean to say that 'synchronized' was wrong, just unnecessarily ambiguous. Please see edit to question.

http://stackoverflow.com/q/2747275
has answer: http://stackoverflow.com/a/8849700
tagged with: clojure
linked to: http://stackoverflow.com/q/826246
type: AnsweredQuestion
tagged with: immutability
downvote count: 0
has answer: http://stackoverflow.com/a/2747580
tagged with: java
has answer: http://stackoverflow.com/a/2827855
has body: In particular an immutable List with a cons operation would be welcome.
has answer: http://stackoverflow.com/a/8748224
type: Question
has title: Typed persistent data structure a la Clojure, done in Java?
score: 3
has answer: http://stackoverflow.com/a/2827510
accepted answer: http://stackoverflow.com/a/2827510
possible better answer: http://stackoverflow.com/a/2827855
tagged with: data-structures
upvote count: 3
favorite count: 0
answer count: 5

http://stackoverflow.com/comment/18401580
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2718861
has text: As far as I know, the functionality of the framework got absorbed, but not the language itself. So, you can't use beanshell from the platform per se.
score: 0

http://stackoverflow.com/comment/2673705
type: AnswerComment
has text: It might just be a matter of how you *interpret* the specification. If it just says "The data should be encrypted using a 1024 bit RSA key", then Thomas' answer is *the* standard way to do this, so I would argue that it is completely in agreement with the spec.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2654368

http://stackoverflow.com/q/2707322
has body: What is null? Is null an instance of anything? What set does null belong to? How is it represented in the memory?
accepted answer: http://stackoverflow.com/a/2707333
has answer: http://stackoverflow.com/a/7258515
score: 285
has answer: http://stackoverflow.com/a/45692650
has answer: http://stackoverflow.com/a/34201526
has answer: http://stackoverflow.com/a/5907979
answer count: 14
downvote count: 2
has answer: http://stackoverflow.com/a/2707339
has answer: http://stackoverflow.com/a/2707325
tagged with: null
possible better answer: http://stackoverflow.com/a/2707351
has answer: http://stackoverflow.com/a/2707333
favorite count: 0
tagged with: terminology
has comment: http://stackoverflow.com/comment/139710168
upvote count: 287
has answer: http://stackoverflow.com/a/2707354
has answer: http://stackoverflow.com/a/2707353
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/41925070
has title: What is null in Java?
has answer: http://stackoverflow.com/a/45077453
has answer: http://stackoverflow.com/a/2707351
has answer: http://stackoverflow.com/a/2707330
type: Question
has comment: http://stackoverflow.com/comment/77127688
has answer: http://stackoverflow.com/a/20273914
tagged with: java

http://stackoverflow.com/q/2671858
tagged with: sequences
downvote count: 0
has answer: http://stackoverflow.com/a/2671977
has answer: http://stackoverflow.com/a/21072120
has comment: http://stackoverflow.com/comment/93643035
has title: Distributed sequence number generation?
has answer: http://stackoverflow.com/a/2671912
type: Question
has answer: http://stackoverflow.com/a/70702318
has answer: http://stackoverflow.com/a/2671957
score: 127
tagged with: java
has answer: http://stackoverflow.com/a/24731208
has answer: http://stackoverflow.com/a/49483961
has answer: http://stackoverflow.com/a/3858354
answer count: 14
tagged with: apache-zookeeper
has answer: http://stackoverflow.com/a/43227684
has answer: http://stackoverflow.com/a/2671961
has body: I've generally implemented sequence number generation using database sequences in the past. e.g. Using Postgres SERIAL type http://www.neilconway.org/docs/sequences/ I'm curious though as how to generate sequence numbers for large distributed systems where there is no database. Does anybody have any experience or suggestions of a best practice for achieving sequence number generation in a thread safe manner for multiple clients?
favorite count: 0
has answer: http://stackoverflow.com/a/45830388
has comment: http://stackoverflow.com/comment/6493358
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/40801378
upvote count: 127
has answer: http://stackoverflow.com/a/49526850
has answer: http://stackoverflow.com/a/5685869

http://stackoverflow.com/comment/2659882
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2644743
has text: The filling thread is not the culprit, the filling thread wait on the consumer thread when the throughput goes down (seen with the visualvm profiler). when the filling thread had not to wait on the consumer the throughput is realy good, at least 58Mb/s. the consumer thread waits on the take method, the operations in the consumer task ar minimal... i tried also the ArrayBlockingQueue...the same game, the consumer wait for the slow take method, and the filler wait because the queue is full p.s.: the program is a copy task p.p.s: thank u for ur answer ;)

izpack
tag name: izpack
tags question: http://stackoverflow.com/q/2643327
tags question: http://stackoverflow.com/q/2652654
type: Tag

http://stackoverflow.com/q/2768931
accepted answer: http://stackoverflow.com/a/2769018
possible better answer: http://stackoverflow.com/a/2768996
has comment: http://stackoverflow.com/comment/2801973
has answer: http://stackoverflow.com/a/2768985
has answer: http://stackoverflow.com/a/24152746
downvote count: 1
type: AnsweredQuestion
upvote count: 5
has answer: http://stackoverflow.com/a/2768973
tagged with: java
has body: In Java we have indexOf and lastIndexOf. Is there anything like lastSubstring? It should work like : "aaple".lastSubstring(0, 1) = "e";
score: 4
has answer: http://stackoverflow.com/a/2768963
has answer: http://stackoverflow.com/a/2768960
has answer: http://stackoverflow.com/a/2769018
type: Question
has title: Last substring of string
answer count: 7
tagged with: string
has comment: http://stackoverflow.com/comment/2802019
favorite count: 0
has answer: http://stackoverflow.com/a/2768996

http://stackoverflow.com/q/2738338
type: Question
possible better answer: http://stackoverflow.com/a/2738396
accepted answer: http://stackoverflow.com/a/2738459
has answer: http://stackoverflow.com/a/2738396
answer count: 3
has answer: http://stackoverflow.com/a/2738397
upvote count: 1
has answer: http://stackoverflow.com/a/2738459
has comment: http://stackoverflow.com/comment/2766832
favorite count: 0
has body: when i search internet i have found a way to underline font like this, Font f=jLabel1.getFont(); Map&lt;TextAttribute,Object&gt; map = new Hashtable&lt;TextAttribute,Object&gt;(); map.put(TextAttribute.UNDERLINE,TextAttribute.UNDERLINE_ON); f=f.deriveFont(map); jLabel1.setFont(f); it works well on jdk6, however it doesnt work on jdk5, and it doesnt warn about anything. first, how can i get same effect on jdk5? second, why is there a TextAttribute.UNDERLINE constant, if it doesnt work?
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
has title: How can i underline a text in JDK5, NOT JDK6
tagged with: swing

http://stackoverflow.com/q/2648110
type: Question
has answer: http://stackoverflow.com/a/2648225
tagged with: java
has body: I need to write a process controller module on Linux that handles tasks, which are each made up of multiple executables. The input to the controller is an XML file that contains the path to each executable and list of command line parameters to be passed to each. I need to implement the following functionality: Start each executable as an independent process Be able to kill any of the child processes created, independent of the others In order to do (2), I think I need to capture the pid when I create a process, to issue a system kill command. I tried to get access to pid in Java using ProcessBuilder but saw no easy way to do it. All my other logic (putting info about the tasks in DB, etc) is done in Java so I'd like to stick with that, but if there are solutions you can suggest in C, C++, or Python I'd appreciate those, too.
answer count: 3
downvote count: 0
favorite count: 0
tagged with: linux
type: UnansweredQuestion
has title: How to know start and kill processes within Java code (or C or Python) on *nix
has comment: http://stackoverflow.com/comment/2663961
has comment: http://stackoverflow.com/comment/2664025
score: 2
has comment: http://stackoverflow.com/comment/2664157
has answer: http://stackoverflow.com/a/2650692
upvote count: 2
has answer: http://stackoverflow.com/a/2648266
tagged with: process

http://stackoverflow.com/comment/2772348
type: Comment
comment on: http://stackoverflow.com/a/2741293
score: 0
has text: So I would get the DB guy to change his stored procedure so it is actually usable, or educate you as to how he thinks it can actually be used in that form.
type: AnswerComment

http://stackoverflow.com/a/2630563
upvote count: 7
type: Answer
accepted answer of: http://stackoverflow.com/q/2630514
has comment: http://stackoverflow.com/comment/2643926
has body: The case you've described can't work, you probably do listToDump.getClass().getName() There is no way to get information about generic type in runtime due to type erasure: When a generic type is instantiated, the compiler translates those types by a technique called type erasure — a process where the compiler removes all information related to type parameters and type arguments within a class or method. If you describe in detail what problem you're trying to solve then maybe we'll suggest you some workarounds or even solutions. Type erasure shouldn't be a big issue, it just can change the way of doing some things.
answers question: http://stackoverflow.com/q/2630514
score: 6
type: AcceptedAnswer
downvote count: 1

http://stackoverflow.com/a/2623164
accepted answer of: http://stackoverflow.com/q/2623125
type: AcceptedAnswer
has body: You can't cast a String to an int. Java is strongly typed, and there is no implicit type conversion like you might find in a scripting language. To convert a String to an int, use an explicit conversion, like Integer.parseInt(String). All member variables and elements of arrays are initialized with a default value. For int types, the value is 0. For reference types (any subtype of Object), the default value is null. Local variables don't get a default value, but the compiler analyzes the code to ensure that a value is assigned before the variable is read. If not, the code will not compile. I think what you want is something like this: int[] n = new int[Integer.parseInt(s[0]); for (int idx = 0; idx &lt; n; ++idx) n[idx] = Integer.parseInt(s[idx + 1]);
score: 12
upvote count: 12
has comment: http://stackoverflow.com/comment/2636843
type: Answer
has comment: http://stackoverflow.com/comment/2635745
has comment: http://stackoverflow.com/comment/2635672
downvote count: 0
has comment: http://stackoverflow.com/comment/2635634
answers question: http://stackoverflow.com/q/2623125
has comment: http://stackoverflow.com/comment/2635656
has comment: http://stackoverflow.com/comment/2635685

tablemodel
type: Tag
tag name: tablemodel
tags question: http://stackoverflow.com/q/2775306

http://stackoverflow.com/a/2752608
downvote count: 0
has comment: http://stackoverflow.com/comment/2783394
answers question: http://stackoverflow.com/q/2752576
type: Answer
accepted answer of: http://stackoverflow.com/q/2752576
has body: Its a set limit on where to stop parsing the POST. Just in case some hacker decides to start sending a request with POST data and just continuously sending POST data. Tomcat won't just take forever parsing POST. Having the limit prevents a denial of service attacks. (They keep doing this until your server maxes stops responding for whatever reason)
has comment: http://stackoverflow.com/comment/2786127
upvote count: 5
has comment: http://stackoverflow.com/comment/5357991
score: 5
type: AcceptedAnswer

http://stackoverflow.com/a/2608229
downvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/2608210
has body: You'd need to save data somewhere, in your case it might be easiest to just write out an empty file after the first run of the app. So you would check for the existence of this file and if it was there then you wouldn't show the second activity, and would just show the main activity.
score: 1
upvote count: 2

http://stackoverflow.com/q/2691041
has body: What does phrase "synchronization with main memory" mean?
type: Question
has answer: http://stackoverflow.com/a/2691074
has answer: http://stackoverflow.com/a/2691070
has title: What does "synchronization with main memory" mean?
answer count: 3
downvote count: 0
has answer: http://stackoverflow.com/a/15494993
favorite count: 0
tagged with: multithreading
possible better answer: http://stackoverflow.com/a/2691070
type: AnsweredQuestion
score: 3
accepted answer: http://stackoverflow.com/a/2691074
upvote count: 3
tagged with: java
has comment: http://stackoverflow.com/comment/2712135
tagged with: concurrency

http://stackoverflow.com/a/2756011
answers question: http://stackoverflow.com/q/2755994
type: Answer
has body: No, Why would there be any conflict? It will just install smooth and fine. You may install it without worrying about anything.
upvote count: 1
score: 1
downvote count: 0

http://stackoverflow.com/comment/64881387
score: 1
comment on: http://stackoverflow.com/a/38753795
type: AnswerComment
type: Comment
has text: You know that this isn't a good way and this question already has some proper ways, so what is the point in sharing this "unclean" one? (Just asking)

http://stackoverflow.com/a/2744774
type: Answer
score: 1
upvote count: 1
has body: You need to pass the Class in your function, something like; public static &lt;T&gt; void parsePropsToList( String propName, String delim, List&lt;T&gt; listToFill, Class&lt;T&gt; clazz) then using the reflection of clazz, get the Constructor having one String for its argument, split your propName with delim and, for each substring, invoke a new instance of T using the previous constructor. put this new instance into listToFill and return this list at then.
accepted answer of: http://stackoverflow.com/q/2744730
answers question: http://stackoverflow.com/q/2744730
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/55896958
answers question: http://stackoverflow.com/q/2667724
has body: I was using Spring and I just had to change Jaxb2Marshaller mlr = new Jaxb2Marshaller(); mlr.setContextPaths("",""); to Jaxb2Marshaller mlr = new Jaxb2Marshaller(); mlr.setPackagesToScan("","");
downvote count: 0
type: Answer
score: 3
upvote count: 3

http://stackoverflow.com/tag/xml
tags question: http://stackoverflow.com/q/2652654
tags question: http://stackoverflow.com/q/2759899
tags question: http://stackoverflow.com/q/2775790
tags question: http://stackoverflow.com/q/2716063
tags question: http://stackoverflow.com/q/2659525
tags question: http://stackoverflow.com/q/2783758
tags question: http://stackoverflow.com/q/2767660
tags question: http://stackoverflow.com/q/2649597
tags question: http://stackoverflow.com/q/2767695
tags question: http://stackoverflow.com/q/2696439
tags question: http://stackoverflow.com/q/2758639
tags question: http://stackoverflow.com/q/2773733
type: Tag
tags question: http://stackoverflow.com/q/2689125
tags question: http://stackoverflow.com/q/2773722
tags question: http://stackoverflow.com/q/2637335
tags question: http://stackoverflow.com/q/2676514
tags question: http://stackoverflow.com/q/2599919
tags question: http://stackoverflow.com/q/2678299
tags question: http://stackoverflow.com/q/2717619
tags question: http://stackoverflow.com/q/2720915
tags question: http://stackoverflow.com/q/2710434
tags question: http://stackoverflow.com/q/2736687
tags question: http://stackoverflow.com/q/2694657
tags question: http://stackoverflow.com/q/2598621
tags question: http://stackoverflow.com/q/2608776
tags question: http://stackoverflow.com/q/2653918
tags question: http://stackoverflow.com/q/2624763
tags question: http://stackoverflow.com/q/2739840
tags question: http://stackoverflow.com/q/2734318
tags question: http://stackoverflow.com/q/2692078
tags question: http://stackoverflow.com/q/2781653
tags question: http://stackoverflow.com/q/2669632
tags question: http://stackoverflow.com/q/2611964
tags question: http://stackoverflow.com/q/2681732
tags question: http://stackoverflow.com/q/2643949
tags question: http://stackoverflow.com/q/2623392
tags question: http://stackoverflow.com/q/2766347
tags question: http://stackoverflow.com/q/2779682
tags question: http://stackoverflow.com/q/2767442
tag name: xml
tags question: http://stackoverflow.com/q/2651647
tags question: http://stackoverflow.com/q/2608296
tags question: http://stackoverflow.com/q/2720719
tags question: http://stackoverflow.com/q/2775349
tags question: http://stackoverflow.com/q/2765876
tags question: http://stackoverflow.com/q/2601360
tags question: http://stackoverflow.com/q/2771365
tags question: http://stackoverflow.com/q/2625466
tags question: http://stackoverflow.com/q/2665970
tags question: http://stackoverflow.com/q/2618252
tags question: http://stackoverflow.com/q/2730231
tags question: http://stackoverflow.com/q/2738429
tags question: http://stackoverflow.com/q/2694045
tags question: http://stackoverflow.com/q/2609998
tags question: http://stackoverflow.com/q/2647097
tags question: http://stackoverflow.com/q/2775401
tags question: http://stackoverflow.com/q/2650259
tags question: http://stackoverflow.com/q/2651221
tags question: http://stackoverflow.com/q/2611481
tags question: http://stackoverflow.com/q/2706201
tags question: http://stackoverflow.com/q/2641775
tags question: http://stackoverflow.com/q/2640825
tags question: http://stackoverflow.com/q/2775409
tags question: http://stackoverflow.com/q/2716916
tags question: http://stackoverflow.com/q/2727860
tags question: http://stackoverflow.com/q/2757034
tags question: http://stackoverflow.com/q/2626159
tags question: http://stackoverflow.com/q/2629987
tags question: http://stackoverflow.com/q/2736496
tags question: http://stackoverflow.com/q/2612915
tags question: http://stackoverflow.com/q/2602473
tags question: http://stackoverflow.com/q/2665748
tags question: http://stackoverflow.com/q/2610674
tags question: http://stackoverflow.com/q/2721138

http://stackoverflow.com/q/2765750
has body: I have a private LinkedList in a Java class &amp; will frequently need to retrieve the last element in the list. The lists need to scale, so I'm trying to decide whether I need to keep a reference to the last element when I make changes (to achieve O(1)) or if the LinkedList class does that already with the getLast() call. What is the big-O cost of LinkedList.getLast() and is it documented? (i.e. can I rely on this answer or should I make no assumptions &amp; cache it even if it's O(1)?)
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2765764
accepted answer: http://stackoverflow.com/a/2765764
has answer: http://stackoverflow.com/a/2765773
answer count: 5
upvote count: 18
tagged with: big-o
has answer: http://stackoverflow.com/a/2765855
has answer: http://stackoverflow.com/a/2765781
tagged with: java
has answer: http://stackoverflow.com/a/2765791
tagged with: collections
type: Question
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2765773
tagged with: performance
score: 18
has title: What is the time complexity of LinkedList.getLast() in Java?

http://stackoverflow.com/q/2758873
has comment: http://stackoverflow.com/comment/2790536
has title: Need Json results in a Table Format
tagged with: http://stackoverflow.com/tag/html
linked to: http://stackoverflow.com/q/2203269
score: 2
upvote count: 2
type: UnansweredQuestion
type: Question
has body: I am getting results in json format, i need to display my results in a table format, Getting a input from html, executing it servlet program, the sparql query shows result in Json format, can anybody help me in showing the result in table format? response.setContentType("json-comment-filtered"); response.setHeader("Cache-Control","nocache"); OutputStream out = response.getOutputStream(); // ResultSetFormatter.outputAsXML(out, results); System.out.println("called"); out.flush(); JSONOutput jOut = new JSONOutput(); jOut.format(out, results); soon the query is executed, the set of code is executed and results are displayed in json format, so can anybody help me out in way that I can get results in table format.
tagged with: java
tagged with: http://stackoverflow.com/tag/json
tagged with: servlets
answer count: 1
downvote count: 0
linked to: http://stackoverflow.com/q/1900711
favorite count: 0
has answer: http://stackoverflow.com/a/2759190

http://stackoverflow.com/q/2769797
answer count: 4
tagged with: object
score: 3
has answer: http://stackoverflow.com/a/2769804
tagged with: java
has title: ArrayList of my objects, indexOf problem
downvote count: 1
type: Question
tagged with: indexof
has answer: http://stackoverflow.com/a/2772184
upvote count: 4
tagged with: arraylist
has body: I have problem with Java's ArrayList. I've created an Object, that contains two attributes, x and y. Now I've loaded some object in my ArrayList. Problem is that I don't know how to find index of some object with x atribute I'm searching. Is there any way to do this?
has answer: http://stackoverflow.com/a/2769845
favorite count: 0
has answer: http://stackoverflow.com/a/2770617
type: UnansweredQuestion

http://stackoverflow.com/comment/5079507
score: 5
type: AnswerComment
has text: this is pretty much possible when myString is null. You should know that when the left part of the && fails, the right expression will not be evaluated at all..
type: Comment
comment on: http://stackoverflow.com/a/2601998

http://stackoverflow.com/comment/2627760
score: 0
type: Comment
has text: Doesn't handle the `NumberFormatException` -- and also, this being (I suspect) a homework problem, let's maybe prefer good hints over explicitly writing out the solution.
comment on: http://stackoverflow.com/a/2616094
type: AnswerComment

http://stackoverflow.com/comment/11247006
score: 0
type: Comment
has text: Interesting that it doesn't list any Spring compatibility. Have you successfully integrated it with Spring MVC?
comment on: http://stackoverflow.com/a/8976843
type: AnswerComment

http://stackoverflow.com/a/2649851
answers question: http://stackoverflow.com/q/2649830
score: 3
downvote count: 0
has body: How about a database? You can use either Derby or Hypersonic. You can create an embedded instance of them just for your own application use. I've used them in lots of applications where I have to manipulate large quantity of data. Hypersonic is very nice and fast. Derby is bundle with the JDK so its convenient database to use. See this for Derby and this for Hypersonic.
upvote count: 3
type: Answer

http://stackoverflow.com/comment/2818534
comment on: http://stackoverflow.com/a/2783206
type: AnswerComment
score: 0
type: Comment
has text: Thanks, Nathan, for the quick response. I do read the output from the subprocess using getInputStream() a few lines after the code I showed, but the code hangs before it gets there. What does "failure to promptly write" mean? I'm trying to write as soon as I open the OutputStream. What else can I do? Thanks again.

http://stackoverflow.com/comment/2619864
type: QuestionComment
comment on: http://stackoverflow.com/q/2609421
has text: It seems that this question is related to the OP's other question: http://stackoverflow.com/questions/2608888/how-to-convert-a-binary-representation-of-a-string-back-into-a-string
score: 0
type: Comment

http://stackoverflow.com/a/2686957
has comment: http://stackoverflow.com/comment/112532431
answers question: http://stackoverflow.com/q/2683202
score: 1
has comment: http://stackoverflow.com/comment/92472523
has body: What about this one? Definitely not nice, but it deals with all necessary cases mentioned. public class SimpleNumberComparator implements Comparator&lt;Number&gt; { @Override public int compare(Number o1, Number o2) { if(o1 instanceof Short &amp;&amp; o2 instanceof Short) { return ((Short) o1).compareTo((Short) o2); } else if(o1 instanceof Long &amp;&amp; o2 instanceof Long) { return ((Long) o1).compareTo((Long) o2); } else if(o1 instanceof Integer &amp;&amp; o2 instanceof Integer) { return ((Integer) o1).compareTo((Integer) o2); } else if(o1 instanceof Float &amp;&amp; o2 instanceof Float) { return ((Float) o1).compareTo((Float) o2); } else if(o1 instanceof Double &amp;&amp; o2 instanceof Double) { return ((Double) o1).compareTo((Double) o2); } else if(o1 instanceof Byte &amp;&amp; o2 instanceof Byte) { return ((Byte) o1).compareTo((Byte) o2); } else if(o1 instanceof BigInteger &amp;&amp; o2 instanceof BigInteger) { return ((BigInteger) o1).compareTo((BigInteger) o2); } else if(o1 instanceof BigDecimal &amp;&amp; o2 instanceof BigDecimal) { return ((BigDecimal) o1).compareTo((BigDecimal) o2); } else { throw new RuntimeException("Ooopps!"); } } }
upvote count: 3
downvote count: 2
has comment: http://stackoverflow.com/comment/112523051
type: Answer

http://stackoverflow.com/comment/2702601
comment on: http://stackoverflow.com/q/2682913
type: Comment
type: QuestionComment
score: 0
has text: What headers are you refering to? Are you confusing this with c? You don't need any seperate header-files in Java. If you already have the classes, you also should have the header, i.e. `public class ClassName() {`

http://stackoverflow.com/comment/2640995
comment on: http://stackoverflow.com/a/2627906
type: AnswerComment
type: Comment
has text: Implementing only `equals()` is **not** enough, you need to implement `hashCode()` as well. See Chapter 3 of Effective Java (available online: http://java.sun.com/developer/Books/effectivejava/Chapter3.pdf)
score: 5

http://stackoverflow.com/comment/2748631
type: AnswerComment
has text: Naughty? CSS is there for styling :) HTML is just markup. Oh, you forgot to accept his answer.
comment on: http://stackoverflow.com/a/2721642
type: Comment
score: 1

http://stackoverflow.com/q/2660198
answer count: 2
tagged with: flash
upvote count: 1
tagged with: upload
downvote count: 0
tagged with: applet
possible better answer: http://stackoverflow.com/a/6648082
favorite count: 0
has comment: http://stackoverflow.com/comment/2677956
has answer: http://stackoverflow.com/a/6648082
tagged with: video
type: AnsweredQuestion
has title: Video Upload Applet
has body: i am working on a small project that i need the ability to let users upload a video to my website or use a webcam to record a video and then upload it. i have seen this done on several sites (youtube,facebook etc) so i know that there is a java or flash applet that supports this. however i have not been able to find one. can anyone recommend a good flash or java based video uploader with these features?
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/2660667
accepted answer: http://stackoverflow.com/a/2660667
type: Question

http://stackoverflow.com/q/2698740
downvote count: 1
has answer: http://stackoverflow.com/a/2698824
favorite count: 0
has title: How can we run .sql file from java without using JDBC?
tagged with: jdbc
has body: I want to run a .sql file from java without using jdbc on windows 7. I am trying with java runtime class which executes the system commands. But my java is running with only user privileges and the command needs Administrator privileges. The command that am using to run is "sqlplus /nolog @sqlscript.sql".
upvote count: 0
has comment: http://stackoverflow.com/comment/2721743
type: UnansweredQuestion
type: Question
tagged with: java
score: -1
answer count: 2
has answer: http://stackoverflow.com/a/2728164
tagged with: sql

http://stackoverflow.com/a/2778896
has comment: http://stackoverflow.com/comment/2817796
score: 1
upvote count: 2
downvote count: 1
type: Answer
has body: The correct answer is not actually correct I think. Microsoft.com simply ignore ICMP requests, probably to avoid basic ping flood attacks. As for the second host I've no idea what the problem with the ping might be, but I'm using GNU/Linux and isReachable works just fine.
answers question: http://stackoverflow.com/q/2777226
has comment: http://stackoverflow.com/comment/2817207

http://stackoverflow.com/comment/2806447
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2769686
has text: @Jon very ingteresting idea thank you
type: AnswerComment

http://stackoverflow.com/a/2694028
answers question: http://stackoverflow.com/q/2689277
score: 0
has body: Indeed it is. http://java.sun.com/developer/onlineTraining/JavaMail/contents.html
type: Answer

http://stackoverflow.com/comment/2765946
type: Comment
comment on: http://stackoverflow.com/a/2730903
has text: is there a generic method to say if it is an audio or image, independent of the extension?
score: 0
type: AnswerComment

http://stackoverflow.com/comment/2770662
type: Comment
comment on: http://stackoverflow.com/a/2741632
has text: your first answer is also ideal, just tried it out works really well! Thanks!
score: 0
type: AnswerComment

http://stackoverflow.com/q/2628279
type: Question
has answer: http://stackoverflow.com/a/2675411
has title: When does JVM produce dumps, other than out of memory
downvote count: 0
has comment: http://stackoverflow.com/comment/2712325
answer count: 3
favorite count: 0
upvote count: 2
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2628523
has body: I need to now when does jvm produce hprof dumps other than out of memory situations. Eg, does it produce an hprof when there is a high cpu usage? I see hprof files produces and there is no out of memory situation.
has answer: http://stackoverflow.com/a/2643611
score: 2
tagged with: java
tagged with: crash-dumps

http://stackoverflow.com/q/2606530
type: Question
has body: I'm trying order pairs of integers ascendantly where a pair is considered less than another pair if both its entries are strictly less than those of the other pair, and larger than the other pair if both its entries are strictly larger than those of the other pair. All other cases are considered incomparable. They way I want to solve this is by defining a Comparator that implements the above, but will throw an exception for incomparable cases, and provide that to a PriorityQueue. Of course, while inserting a pair the priority queue does several comparisons while bubbling the new entry up to its correct position in the heap, and many of these will be comparable. But it may happen during the bubbling process that a pair is encountered with which this new pair is incomparable, and an exception will be thrown. If this happens, what will be the state of the PriorityQueue? Will the pair I was trying to insert sit in the heap at the last position it was in before the exception was thrown? If I use the PriorityQueue's remove(Object o) method, will the PriorityQueue be restored to a consistent state? Thanks
tagged with: comparator
answer count: 1
downvote count: 0
has title: What happens to my PriorityQueue if my Comparator throws an exception while it's busy bubbling up or down?
tagged with: priority-queue
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2606871
upvote count: 1
score: 1
tagged with: java

http://stackoverflow.com/a/2756020
type: Answer
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/2755994
type: AcceptedAnswer
downvote count: 0
has body: Netbeans is an IDE for many programming languages. There is no issue of installing Netbeans after installing java sdk. For details follow http://netbeans.org/downloads/index.html JDK 6 or JDK 5 is required for installing and running the Java SE, JavaFX, Java and All NetBeans Bundles. You can download standalone JDK or download the latest JDK with NetBeans IDE Java SE bundle.
accepted answer of: http://stackoverflow.com/q/2755994

http://stackoverflow.com/comment/3224679
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2773717
has text: Maybe you should put the Strings and Numbers in different collections.

http://stackoverflow.com/a/34987472
type: Answer
answers question: http://stackoverflow.com/q/2667873
has body: You must do as the following code, if you want to pass 4 parameters to backing bean. &lt;a4j:form&gt; &lt;a4j:jsFunction name="addClip" action="#{backingBean.goGo}"&gt; &lt;a4j:actionparam name="param1" assignTo="#{backingBean.param1}"/&gt; &lt;a4j:actionparam name="param2" assignTo="#{backingBean.param2}"/&gt; &lt;a4j:actionparam name="param3" assignTo="#{backingBean.param3}"/&gt; &lt;a4j:actionparam name="param4" assignTo="#{backingBean.param4}"/&gt; &lt;/a4j:jsFunction&gt;
score: 0

http://stackoverflow.com/a/2761018
has comment: http://stackoverflow.com/comment/2793362
has comment: http://stackoverflow.com/comment/81546501
has comment: http://stackoverflow.com/comment/81558871
has comment: http://stackoverflow.com/comment/56331319
has comment: http://stackoverflow.com/comment/78321143
has comment: http://stackoverflow.com/comment/31758993
score: 64
has comment: http://stackoverflow.com/comment/2793865
has comment: http://stackoverflow.com/comment/52959901
upvote count: 76
has comment: http://stackoverflow.com/comment/122342450
type: Answer
has comment: http://stackoverflow.com/comment/44319905
has comment: http://stackoverflow.com/comment/2793267
downvote count: 12
has body: Yes. new ArrayList&lt;String&gt;(){{ add("A"); add("B"); }} What this is actually doing is creating a class derived from ArrayList&lt;String&gt; (the outer set of braces do this) and then declare a static initialiser (the inner set of braces). This is actually an inner class of the containing class, and so it'll have an implicit this pointer. Not a problem unless you want to serialise it, or you're expecting the outer class to be garbage collected. I understand that Java 7 will provide additional language constructs to do precisely what you want. EDIT: recent Java versions provide more usable functions for creating such collections, and are worth investigating over the above (provided at a time prior to these versions)
has comment: http://stackoverflow.com/comment/94658467
has comment: http://stackoverflow.com/comment/2829836
answers question: http://stackoverflow.com/q/2760995

http://stackoverflow.com/comment/2658920
has text: Thanks for the help BalusC. I haven't explicitly added the servlet-api or jsp-api to the dependencies list in my pom.xml, actually they're not listed there. Perhaps it's a dependency of one of the dependencies I have. I'll give your suggestion a go.
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2641393

http://stackoverflow.com/a/2680526
type: Answer
has comment: http://stackoverflow.com/comment/2700341
has body: You can use a tool like IzPack2exe. Even if you package the the program just as a jar file - double clicking it in windows win run it, if the user has Java installed.
has comment: http://stackoverflow.com/comment/2700179
score: 0
answers question: http://stackoverflow.com/q/2680513

http://stackoverflow.com/a/2661886
upvote count: 1
has comment: http://stackoverflow.com/comment/2679235
has body: If you didn't do that before - download some source code of some Java application (jEdit for example) and look and the files structure in the sources. It will clarify everything a bit probably. in jEdit there are several different packages, so you'll see how everything works. And by the way - if you never read anyone's code - go and do it ASAP!! Even if you don't understand everything or just a small parts - do it as it's a great school of good programming practices!!!
type: Answer
score: -1
answers question: http://stackoverflow.com/q/2661698
downvote count: 2

http://stackoverflow.com/comment/34465038
type: AnswerComment
comment on: http://stackoverflow.com/a/2741103
score: 0
type: Comment
has text: i am not able to get the part through which i can retrieve File size from remote Unix. `SftpATTRS` is not avaibale in my Jsch jar file

http://stackoverflow.com/comment/18129779
type: Comment
comment on: http://stackoverflow.com/a/13292073
score: 5
type: AnswerComment
has text: I think I would prefer to have a `public abstract Cage getSuitableCage() { ... }` in `Animal`

http://stackoverflow.com/comment/2785776
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2754687
has text: I don't want it to execute if the the property is false.
type: AnswerComment

http://stackoverflow.com/comment/2668214
comment on: http://stackoverflow.com/a/2651695
score: 0
type: AnswerComment
type: Comment
has text: Thanks for that but my need is it can start from any part of the cell.Meaning Progress bar starts from 0 to 100 but mine is like a new bar should start in between like 40%.IN that case will progress bar be useful?

http://stackoverflow.com/q/2720738
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/477750
possible better answer: http://stackoverflow.com/a/2720765
tagged with: java
has answer: http://stackoverflow.com/a/2720765
linked to: http://stackoverflow.com/q/2696812
type: Question
accepted answer: http://stackoverflow.com/a/2720821
tagged with: casting
downvote count: 0
has answer: http://stackoverflow.com/a/2720796
has body: I have the following code snippet. public static void main(String[] args) { short a = 4; short b = 5; short c = 5 + 4; short d = a; short e = a + b; // does not compile (expression treated as int) short z = 32767; short z_ = 32768; // does not compile (out of range) test(a); test(7); // does not compile (not applicable for arg int) } public static void test(short x) { } Is the following summary correct (with regard to only the example above using short)? direct initializations without casting is only possible using literals or single variables (as long as the value is in the range of the declared type) if the rhs of an assignment deals with expressions using variables, casting is necessary But why exactly do I need to cast the argument of the second method call taking into account the previous summary?
has comment: http://stackoverflow.com/comment/2746851
answer count: 3
upvote count: 11
favorite count: 0
tagged with: primitive-types
has answer: http://stackoverflow.com/a/2720821
has title: Java - short and casting
score: 11

http://stackoverflow.com/a/2638293
has body: How about converting the document to string using asXml() and using String.length()?
score: 0
answers question: http://stackoverflow.com/q/2638107
has comment: http://stackoverflow.com/comment/2652887
type: Answer

http://stackoverflow.com/comment/43824688
score: 0
type: AnswerComment
type: Comment
has text: @weston in which class do i write this code. FontsOverride.setDefaultFont(this, "DEFAULT", "MyFontAsset.ttf");
comment on: http://stackoverflow.com/a/16883281

http://stackoverflow.com/comment/2678569
score: 0
type: AnswerComment
has text: @Michael, did you forget a `!` ?
comment on: http://stackoverflow.com/a/2661121
type: Comment

http://stackoverflow.com/q/2758224
has answer: http://stackoverflow.com/a/2758267
has answer: http://stackoverflow.com/a/64387889
has answer: http://stackoverflow.com/a/30274891
has answer: http://stackoverflow.com/a/16196119
has answer: http://stackoverflow.com/a/10976329
has comment: http://stackoverflow.com/comment/135746024
linked to: http://stackoverflow.com/q/4963300
accepted answer: http://stackoverflow.com/a/2758645
has comment: http://stackoverflow.com/comment/37107577
has answer: http://stackoverflow.com/a/45422538
has comment: http://stackoverflow.com/comment/37147942
favorite count: 0
has comment: http://stackoverflow.com/comment/32119183
has comment: http://stackoverflow.com/comment/56903372
answer count: 20
downvote count: 5
has answer: http://stackoverflow.com/a/21571971
has answer: http://stackoverflow.com/a/33304681
has comment: http://stackoverflow.com/comment/2790398
linked to: http://stackoverflow.com/q/5223268
has comment: http://stackoverflow.com/comment/32140908
has answer: http://stackoverflow.com/a/37605954
has answer: http://stackoverflow.com/a/2758645
has answer: http://stackoverflow.com/a/52918492
has answer: http://stackoverflow.com/a/44527555
linked to: http://stackoverflow.com/q/22589302
has body: What are some real life examples to understand the key role of the Java assert keyword?
has answer: http://stackoverflow.com/a/21180198
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21196051
has answer: http://stackoverflow.com/a/21670520
tagged with: java
has comment: http://stackoverflow.com/comment/103421398
has comment: http://stackoverflow.com/comment/103421282
has answer: http://stackoverflow.com/a/29439538
has comment: http://stackoverflow.com/comment/32140865
type: Question
has comment: http://stackoverflow.com/comment/32162288
tagged with: assertion
possible better answer: http://stackoverflow.com/a/19425549
has answer: http://stackoverflow.com/a/78836896
has comment: http://stackoverflow.com/comment/110439147
has comment: http://stackoverflow.com/comment/32235544
has comment: http://stackoverflow.com/comment/32117360
has title: What are assertions in Java and when should they be used?
has answer: http://stackoverflow.com/a/2758262
has answer: http://stackoverflow.com/a/19425549
has answer: http://stackoverflow.com/a/44056242
upvote count: 751
score: 746

http://stackoverflow.com/q/2703410
has answer: http://stackoverflow.com/a/2705693
accepted answer: http://stackoverflow.com/a/2705693
type: Question
downvote count: 0
has title: Session expiry times?
answer count: 3
upvote count: 1
possible better answer: http://stackoverflow.com/a/2712330
favorite count: 0
tagged with: google-app-engine
has body: I've enabled sessions on my app: // appengine-web.xml true they seem to work when I load different pages under my domain. If I close the browser however, looks like the session is terminated. Restarting the browser shows the last session is no longer available. That could be fine, just wondering if this is documented anywhere, so I can rely on this fact? I tried the following just to test if we can tweak it: // in web.xml 10 also // in my servlet getThreadLocalRequest().getSession().setMaxInactiveInterval(60 * 5); but same behavior, session data is no longer available after browser restart. I looked at the stats for my project and I see data being used for something like "_ah_SESSION" objects. Are those the sessions from above? If so, shouldn't they be cleaned since they're no longer valid? (Hopefully gae takes care of that automatically?) Thanks
has answer: http://stackoverflow.com/a/41532927
type: AnsweredQuestion
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/2712330

jboss5.x
tag name: jboss5.x
tags question: http://stackoverflow.com/q/2767460
type: Tag

http://stackoverflow.com/q/2701094
possible better answer: http://stackoverflow.com/a/2701123
answer count: 5
has answer: http://stackoverflow.com/a/2701123
has answer: http://stackoverflow.com/a/2701153
upvote count: 34
type: AnsweredQuestion
has body: I am trying to get familiar with Java EE 6 by reading http://java.sun.com/javaee/6/docs/tutorial/doc/gexaf.html. I am a bit confused about the use of JSF. Usually, the way I develop my Web App would be, Servlet would act like a controller and JSP would act like a View in an MVC model. So Does JSF try to replace this structure? Below are the quote from the above tutorial: Servlet are best suited for service-oriented App and control function of presentation-oriented App like dispatching request JSF and Facelet are more appropriated for generating mark-up like XHTML, and generally used for presentation-oriented App Not sure if I understand the above quote too well, they did not explain too well what is service-oriented vs presentation-oriented. A JavaServer Faces application can map HTTP requests to component-specific event handling and manage components as stateful objects on the server. Any knowledgeable Java developer out there can give me a quick overview about JSF, JSP and Servlet? Do I integrate them all, or do I use them separated base on the App? if so then what kind of app use JSF in contrast with Servlet and JSP A JavaServer Faces application can map HTTP requests to component-specific event handling and manage components as stateful objects on the server. Sound like what servlet can do, but not sure about manage components as stateful objects on the server. Not even sure what that mean? Thanks in advance.
tagged with: jsf
tagged with: java
has title: Java EE 6: JSF vs Servlet + JSP. Should I bother learning JSF?
downvote count: 1
has answer: http://stackoverflow.com/a/2701117
tagged with: servlets
score: 33
type: Question
tagged with: jakarta-ee
has answer: http://stackoverflow.com/a/2701288
linked to: http://stackoverflow.com/q/2095397
tagged with: jsp
accepted answer: http://stackoverflow.com/a/2701153
has answer: http://stackoverflow.com/a/6895504
favorite count: 0

http://stackoverflow.com/comment/139339670
has text: @suketup I am trying this, and it's not working for me. Though the server is working fine while using FileZilla Client. Here is my code:
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/44317591

http://stackoverflow.com/comment/2773442
comment on: http://stackoverflow.com/a/2743868
has text: The main advantage of the CopyOnWriteArrayList approach is that you only take the hit of copying the list when adding / removing a listener, which is likely to be a far less common event than notifications.
type: Comment
score: 1
type: AnswerComment

http://stackoverflow.com/a/2734346
type: AcceptedAnswer
type: Answer
downvote count: 0
has body: I actually think the algorithm is something like this (simplifying way down and using Java syntax): while(dataSource.next()) { for (JRField field : reportFields) currentValues.put(field, dataSource.getFieldValue(field)); } Fields are declared in the jrxml file independently of where they are displayed. However, to the best of my knowledge, by default only the detail section is generated (drawn or updated) on a per-record basis. In other words, you'll have to do something fancy if you need to update information in the header or footer of the page. I believe there is an evaluationTime attribute that can be used in several elements that might be helpful in this regard or you may want to look into the subreport features, depending on how much data you need to work with. Personally, I've found the JasperReports sample projects to be helpful, though it does require some effort to get much out of them. I'd also point to The Definitive Guide to JasperReports whose name is a lie, but does serve as a decent (and otherwise totally lacking) reference manual.
score: 1
accepted answer of: http://stackoverflow.com/q/2733317
answers question: http://stackoverflow.com/q/2733317
upvote count: 1

http://stackoverflow.com/q/2623966
type: Question
possible better answer: http://stackoverflow.com/a/2624023
has answer: http://stackoverflow.com/a/2624033
has answer: http://stackoverflow.com/a/2624023
upvote count: 16
has answer: http://stackoverflow.com/a/2624040
has answer: http://stackoverflow.com/a/2624125
tagged with: syntax
has answer: http://stackoverflow.com/a/2624044
tagged with: java
has title: Java syntax of +
accepted answer: http://stackoverflow.com/a/2624125
answer count: 7
has comment: http://stackoverflow.com/comment/2636674
has comment: http://stackoverflow.com/comment/2636614
has answer: http://stackoverflow.com/a/2624057
downvote count: 0
has body: Why is the following syntax correct: x = y+++y; Where it means y++ + y or y + ++y which means y * 2 + 1 (not sure about this, though: very ambiguous) But this syntax is incorrect: x = y+++++y; Which should mean y++ + ++y, which means y * 2 + 2 Is there a reason for the incorrectness of this syntax? (Edit: thank you for explaining why it is invalid syntax, but that is not my intention with this question.) (Edit: ofcourse I'm not using this in real code, purely in interest of parsers/lexers; but I wonder why the parser doesn't like this; the last example even looks less ambiguous than the first one.) (Edit: int i = 0; int j = (i = 3)+++i; Is invalid too, though it seems very unambiguous to me, (i = 3) is a value, thus (value + value) and then the ++i value token.)
score: 16
has answer: http://stackoverflow.com/a/2627725
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2636661
favorite count: 0
tagged with: operators

http://stackoverflow.com/a/2620619
answers question: http://stackoverflow.com/q/2619643
upvote count: 2
type: Answer
score: 2
accepted answer of: http://stackoverflow.com/q/2619643
has body: Yeah, the problem is that one of your constructors doesn't initialize the final field. In Java final non-static fields have to be initialized at the declaration time, in an initialization block, OR in EVERY constructor! The default constructor in your example doesn't do that. Remember as well that implementing an empty default constructor makes sense only if you want to use inheritance features. If you don't provide a default constructor, but you will some other one Java won't make a hidden default constructor for you, because the default one is not required. So don't implement things like MyClass() {} with no special purpose - keep your code clean and save!
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/2606376
type: Answer
has comment: http://stackoverflow.com/comment/2616724
answers question: http://stackoverflow.com/q/2606249
has comment: http://stackoverflow.com/comment/2616421
has body: Tomcat doesn't ship with JSF libraries, so you have to include those in WEB-INF/lib. From the listing above it is obvious that your are missing those. For JSF2 go here. Moreover you do not need servlet-api in WEB-INF/lib, it is a provided library.
score: 0
has comment: http://stackoverflow.com/comment/2616411
has comment: http://stackoverflow.com/comment/2616516

http://stackoverflow.com/q/2703689
has answer: http://stackoverflow.com/a/2704572
tagged with: unit-testing
score: 2
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2703749
tagged with: java
has comment: http://stackoverflow.com/comment/2728623
possible better answer: http://stackoverflow.com/a/2703749
type: Question
answer count: 2
accepted answer: http://stackoverflow.com/a/2704572
downvote count: 0
has title: codingBat separateThousands using regex (and unit testing how-to)
favorite count: 0
has body: This question is a combination of regex practice and unit testing practice. Regex part I authored this problem separateThousands for personal practice: Given a number as a string, introduce commas to separate thousands. The number may contain an optional minus sign, and an optional decimal part. There will not be any superfluous leading zeroes. Here's my solution: String separateThousands(String s) { return s.replaceAll( String.format("(?:%s)|(?:%s)", "(?&lt;=\\G\\d{3})(?=\\d)", "(?&lt;=^-?\\d{1,3})(?=(?:\\d{3})+(?!\\d))" ), "," ); } The way it works is that it classifies two types of commas, the first, and the rest. In the above regex, the rest subpattern actually appears before the first. A match will always be zero-length, which will be replaceAll with ",". The rest basically looks behind to see if there was a match followed by 3 digits, and looks ahead to see if there's a digit. It's some sort of a chain reaction mechanism triggered by the previous match. The first basically looks behind for ^ anchor, followed by an optional minus sign, and between 1 to 3 digits. The rest of the string from that point must match triplets of digits, followed by a nondigit (which could either be $ or \.). My question for this part is: Can this regex be simplified? Can it be optimized further? Ordering rest before first is deliberate, since first is only needed once No capturing group Unit testing part As I've mentioned, I'm the author of this problem, so I'm also the one responsible for coming up with testcases for them. Here they are: INPUT, OUTPUT "1000", "1,000" "-12345", "-12,345" "-1234567890.1234567890", "-1,234,567,890.1234567890" "123.456", "123.456" ".666666", ".666666" "0", "0" "123456789", "123,456,789" "1234.5678", "1,234.5678" "-55555.55555", "-55,555.55555" "0.123456789", "0.123456789" "123456.789", "123,456.789" I haven't had much experience with industrial-strength unit testing, so I'm wondering if others can comment whether this is a good coverage, whether I've mi…
tagged with: regex
upvote count: 2

http://stackoverflow.com/q/2621733
tagged with: mapping
tagged with: one-to-many
has comment: http://stackoverflow.com/comment/2635464
score: 6
has title: Hibernate: What's wrong with this mapping to a subclass joined on foreign key?
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/17118434
tagged with: java
tagged with: hibernate
accepted answer: http://stackoverflow.com/a/2663490
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/17118434
upvote count: 6
downvote count: 0
has answer: http://stackoverflow.com/a/2663490
tagged with: inheritance
has body: I am experimenting with Hibernate to gain experience. I created a class Person with two subclasses: Student and Worker: public abstract class Person { private Long id; ... } public class Student extends Person { ... } Another class, Employer, has a bidirectional one-to-many relationship with Worker. public class Worker extends Person { private Employer employer; ... } public class Employer { private String taxId; private Set<Worker> employees = new HashSet<Worker>(); ... } for which the mapping is <generator class="assigned"/> ... <key column="EMPLOYER_TAX_ID"/> <one-to-many class="Worker"/> The inheritance hierarchy is modelled with a mixed strategy, where Student is mapped to the PERSON table, but Worker is stored in its own table, joined with a foreign key: <generator class="native"/> <discriminator column="PERSON_TYPE" type="string"/> ... ... <key column="WORKER_ID"/> <many-to-one name="employer" column="EMPLOYER_TAX_ID" cascade="save-update"/> ... I use Apache Derby 10.5.3.0 and autogenerate the schema by setting hibernate.hbm2ddl.auto to create-drop. To test all this, I created a DBUnit test with the following dataset: <EMPLOYER TAX_ID = "1234567890" ... /> <PERSON PERSON_ID = "12345" PERSON_TYPE = "WRK" ... /> <WORKER WORKER_ID = "12345" EMPLOYER_TAX_ID = "1234567890" ... /> I have a test which loads the worker entity and verifies that it has the correct employee. This passes. Then a test for the opposite direction: String taxId = "1234567890"; Employer employer = (Employer) session.get(Employer.class, taxId); assertNotNull(employer); assertThat(employer.getEmployees().size(), is(1)); Upon execution, the last assert fails because the set of employees is empty. Digging deeper, I found that for some reason Hibernate looks for (and creates) the EMPLOYER_TAX_ID column in table PERSON instead of WORKER! It is also present in WORKER, but that one is not used in the query. The select statements for populating the set of employees is: select employees0_.EMPLOYER_TAX_…
has comment: http://stackoverflow.com/comment/2634407
has comment: http://stackoverflow.com/comment/2635354
has comment: http://stackoverflow.com/comment/2634494
favorite count: 0

http://stackoverflow.com/a/2683473
downvote count: 0
type: Answer
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/2683328
has comment: http://stackoverflow.com/comment/2704078
has body: On reentrancy of your method: if it's static, it doesn't hold any state, so it's perfectly safe. On performance: look at your use cases. Since you're validating Strings, I can only assume you are validating user input. In any case, the number of simultaneous users of your system is not probable to incur a performance bottleneck.
has comment: http://stackoverflow.com/comment/2703262

http://stackoverflow.com/a/2729122
score: 2
accepted answer of: http://stackoverflow.com/q/2726295
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2726295
type: Answer
upvote count: 2
has comment: http://stackoverflow.com/comment/5119179
has body: You cannot modify the background that way, due to limitations in the RemoteViews API. What you can do is choose a different layout -- one with the background you want -- when you create your RemoteViews instance for this particular update.
has comment: http://stackoverflow.com/comment/2758870

http://stackoverflow.com/comment/31464741
comment on: http://stackoverflow.com/a/2681099
type: AnswerComment
type: Comment
has text: Simply placing the current directory file name didn't resolve correctly. Is that platform based Java bug?
score: 0

http://stackoverflow.com/q/2744286
type: Question
has title: How to configure Hibernate database reverse engineering tool to map database table relation as a entites inheritance?
answer count: 1
tagged with: jpa
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/2747072
tagged with: reverse-engineering
has answer: http://stackoverflow.com/a/2747072
type: AnsweredQuestion
has body: Is it possible to configure Hibernate reverse engineering and code generation tool in such a way that one-to-many relation between tables is mapped to entities inheritance instead of enrites relation? I have Person table and Employee table, which are related with the foreign key (Person contains basic information, Employee the rest). In my Java code I would like this relation mapped to inheritance Employee extends Person. This can be done by hand, but maybe I missed some custom configuration parameter that I can use. I couldn't find any official documentation - docs link on RedHat Hibernate page (http://www.hibernate.org/5.html#A10) is broken...
score: 1
tagged with: java
tagged with: hibernate
tagged with: orm
upvote count: 1

http://stackoverflow.com/q/2704597
has answer: http://stackoverflow.com/a/4110311
accepted answer: http://stackoverflow.com/a/2704640
has answer: http://stackoverflow.com/a/2704613
favorite count: 0
has answer: http://stackoverflow.com/a/2704615
has answer: http://stackoverflow.com/a/4110057
answer count: 9
has title: Iteration order of HashSet
has comment: http://stackoverflow.com/comment/127785000
has answer: http://stackoverflow.com/a/2704610
has answer: http://stackoverflow.com/a/2704612
linked to: http://stackoverflow.com/q/4418896
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/2704650
score: 24
has comment: http://stackoverflow.com/comment/2729755
tagged with: collections
upvote count: 24
type: Question
has answer: http://stackoverflow.com/a/2704646
tagged with: algorithm
tagged with: hashset
has comment: http://stackoverflow.com/comment/2728989
has answer: http://stackoverflow.com/a/2704640
has body: If every object added to a java.util.HashSet implements Object.equals() and Object.hashCode() in a deterministic fashion, is the iteration order over the HashSet guaranteed to be identical for every identical set of elements added, irrespective of the order in which they were added? Bonus question: what if the insertion order is identical as well? (Assuming Sun JDK6 with same HashSet initialization.) Edit: My original question was not clear. It is not about the general contract of HashSet, but what Sun's implementation of HashSet in JDK6 offers as guarantees concerning determinism. Is it inherently non-deterministic? What influences the order used by its Iterator?
downvote count: 0
possible better answer: http://stackoverflow.com/a/2704613

http://stackoverflow.com/comment/2679460
comment on: http://stackoverflow.com/a/2660563
type: AnswerComment
score: 0
type: Comment
has text: But why does it work when I use `new Font(device, "Andale Mono", SWT.BOLD)`? It just fails when I use the FontData API directly. I also can't see a difference when I call `fd.toString()`. Everything looks ok, I get different font handles but they look wrong on the screen.

http://stackoverflow.com/q/2599919
type: Question
answer count: 8
has answer: http://stackoverflow.com/a/2599953
has answer: http://stackoverflow.com/a/2599948
linked to: http://stackoverflow.com/q/3665554
tagged with: eclipse
has answer: http://stackoverflow.com/a/2601696
tagged with: xml-parsing
has comment: http://stackoverflow.com/comment/45321956
has answer: http://stackoverflow.com/a/10229770
downvote count: 0
duplicate of: http://stackoverflow.com/q/4569123
favorite count: 0
has answer: http://stackoverflow.com/a/13176742
has answer: http://stackoverflow.com/a/10407610
has comment: http://stackoverflow.com/comment/2613652
type: UnansweredQuestion
score: 54
upvote count: 54
has comment: http://stackoverflow.com/comment/8398533
tagged with: http://stackoverflow.com/tag/xml
tagged with: java
has answer: http://stackoverflow.com/a/13336323
has title: Java parsing XML document gives "Content not allowed in prolog." error
has answer: http://stackoverflow.com/a/2601642
has body: I am writing a program in Java that takes a custom XML file and parses it. I'm using the XML file for storage. I am getting the following error in Eclipse. [Fatal Error] :1:1: Content is not allowed in prolog. org.xml.sax.SAXParseException: Content is not allowed in prolog. at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:239) at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:283 ) at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:208) at me.ericso.psusoc.RequirementSatisfier.parseXML(RequirementSatisfier.java:61) at me.ericso.psusoc.RequirementSatisfier.getCourses(RequirementSatisfier.java:35) at me.ericso.psusoc.programs.RequirementSatisfierProgram.main(RequirementSatisfierProgram.java:23 ) The beginning of the XML file is included: <?xml version="1.0" ?> <PSU> <Major id="IST"> Information Science and Technology B.S. Information Systems: Design and Development Option <requirements> <firstlevel type="General_Education" credits="45"> GWS GQ The program is able to read in the XML file but when I call DocumentBuilder.parse(XMLFile) to get a parsed org.w3c.dom.Document, I get the error above. It doesn't seem to me that I have invalid content in the prolog of my XML file. I can't figure out what is wrong. Please help. Thanks.

http://stackoverflow.com/q/2698197
has title: NoClassDefFoundError when running java tool under Xcode
has body: I'm trying to create a Java Tool by using Xcode. I've already changed my build.xml to have Xcode target java 1.6 and not 1.3 so I can use generics. I'm getting no build errors and using 'javac' and 'java' in the terminal works. Now I want it to work in Xcode as well. I keep getting the following error: Exception in thread "main" java.lang.NoClassDefFoundError: MyClass where 'MyClass' is the class containing the main method. It probably has something to do with the classpath, which as the build.xml prescribes is "${bin}". There is a bin folder in my project folder, and it contains all the .class files needed to run the program. If anybody could help me, it'd be great!
answer count: 1
downvote count: 0
favorite count: 0
tagged with: xcode
type: AnsweredQuestion
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/2698685
upvote count: 1
type: Question
accepted answer: http://stackoverflow.com/a/2698685

http://stackoverflow.com/comment/2807919
type: Comment
score: 1
comment on: http://stackoverflow.com/q/2774173
type: QuestionComment
has text: By intersection point do they mean where a group elements intersect, or just a single element overlap?

http://stackoverflow.com/a/2855259
has body: I am not a mainframe expert but I assume you connect not to MVS but to the USS (Unix System Services) which run either FTP or SSH daemon. I only tried to download files via FTP from USS with a regular Windows FTP could exchange and open the files fine. No binary thouhg. Thus, I do not assume that you would get files in EBCDIC encoding. Have you tried downloading a simple text file? Have you tried downloading a text file with special characters? e.g. German umlauts or other non-ASCII?
score: 0
answers question: http://stackoverflow.com/q/2773266
type: Answer

http://stackoverflow.com/comment/49120627
type: Comment
comment on: http://stackoverflow.com/a/2621028
has text: yes, takes care of marshalling and unmarshalling. Only drawback is , we need webserver.
type: AnswerComment
score: 0

http://stackoverflow.com/comment/110320882
type: Comment
has text: you have a lot of slaves.. :)
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/29787295

http://stackoverflow.com/a/2777339
accepted answer of: http://stackoverflow.com/q/2774500
downvote count: 0
answers question: http://stackoverflow.com/q/2774500
has body: It seems there are two options to go with here, either using the embedded EJB API (...) which expects a configured glassfish v3 install to be available. No, you can also use a minimal domain inside your project. I am looking for feedback from someone who has or who is in the process of doing this, links to blogs etc with a simple EJB &amp; test case are dime a dozen. I've done integration testing of EJB 3.1 and JPA on my pet project (under Maven), inspired by Unit Testing EJBs and JPA with Embeddable GlassFish. Reading it is definitely worth it. Did you use any particular test framework for reasons other than it been your preferred tool? Nope. Which JPA 2.0 implementation did you use, and was there a particular reason for doing so? I used EclipseLink (because it was available at that time). If you used glassfish which of the above strategies did you use? If not then which EJB 3.1 container did you use? I used the Embedded EJB API, I was planning to run my code on other Java EE 6 containers when they'll be available. If you successfully did this, was it worth the effort and would you do this again for another existing project? Well, I think that integration / functional testing have value and find that the Embedded EJB API is really nice for that. It was not a pain to use it even if I don't consider my sample as a real life project. For more complex scenarios, I keep an eye on the maven-embedded-glassfish-plugin (see also this answer).
score: 4
type: AcceptedAnswer
type: Answer
upvote count: 4

http://stackoverflow.com/comment/2653086
has text: @Joachim Sauer that is indeed true
comment on: http://stackoverflow.com/q/2636056
score: 0
type: Comment
type: QuestionComment

binary-tree
tag name: binary-tree
tags question: http://stackoverflow.com/q/2706181
tags question: http://stackoverflow.com/q/2597185
type: Tag
tags question: http://stackoverflow.com/q/2635292

sql-server-2008
tags question: http://stackoverflow.com/q/2606653
tag name: sql-server-2008
tags question: http://stackoverflow.com/q/2746488
type: Tag

http://stackoverflow.com/comment/59337733
comment on: http://stackoverflow.com/q/2735736
type: Comment
has text: There *is* a `const` keyword, but there is no underlying feature. Corrected your title and tags accordingly.
score: 3
type: QuestionComment

glassfish
tags question: http://stackoverflow.com/q/2695215
tags question: http://stackoverflow.com/q/2602516
tags question: http://stackoverflow.com/q/2728942
tags question: http://stackoverflow.com/q/2691835
tags question: http://stackoverflow.com/q/2641760
tags question: http://stackoverflow.com/q/2646431
tags question: http://stackoverflow.com/q/2603883
tags question: http://stackoverflow.com/q/2720275
tags question: http://stackoverflow.com/q/2732012
tags question: http://stackoverflow.com/q/2743669
tags question: http://stackoverflow.com/q/2757473
tag name: glassfish
tags question: http://stackoverflow.com/q/2613612
tags question: http://stackoverflow.com/q/2608068
tags question: http://stackoverflow.com/q/2768780
type: Tag

http://stackoverflow.com/q/2612260
has answer: http://stackoverflow.com/a/22583843
linked to: http://stackoverflow.com/q/456002
type: Question
type: AnsweredQuestion
score: 3
has answer: http://stackoverflow.com/a/2612290
upvote count: 3
possible better answer: http://stackoverflow.com/a/22280037
has answer: http://stackoverflow.com/a/4801605
has body: What is the best library to do this? I am surprised this question has not been asked before. Is it impossible? That would be surprising too. Thanks for your help.
favorite count: 0
linked to: http://stackoverflow.com/q/556060
tagged with: latex
has answer: http://stackoverflow.com/a/22280037
answer count: 5
has title: Library to convert latex to png in Java
has answer: http://stackoverflow.com/a/2612354
accepted answer: http://stackoverflow.com/a/2612354
downvote count: 0
tagged with: java

http://stackoverflow.com/comment/3073448
type: AnswerComment
has text: @Ole Jak 1.)When you use JOGL/OpenGL you get the sun dialog.press allow/trust.It should work on most browsers, but I've seen it fail on some PCs with Firefox/JRE.Didn't bother to look into it. 2.) mobile devices usually support OpenGL ES which is a subset of OpenGL, so you need to check if the OpenGL features you plan to use on mobile are present in OpenGL ES. 3.)Here is my OpenGL assignment for the graphics course in term1: http://doc.gold.ac.uk/~ma802gp/abstract.It uses GLSL shaders. Got some Processing/java source code there.Shaders aren't uploaded, most of them are from GLSL Orange Book
score: 0
type: Comment
comment on: http://stackoverflow.com/a/3007482

http://stackoverflow.com/a/2606918
upvote count: 1
downvote count: 0
has body: The C++ destructor is not a way to destruct objects - it's a set of operation that are to be done when the object is destructed. I think you are confusing terminology. Here is how I see it: create object = first allocate memory, then construct via constructor destroy object = first destruct via destructor, then deallocate memory How the memory is allocated and deallocated depends. If you use new and delete, the memory management is done by void* operator new(size_t) and void operator delete(void*).
type: Answer
score: 1
answers question: http://stackoverflow.com/q/2606523

http://stackoverflow.com/q/2741755
tagged with: android
tagged with: http://stackoverflow.com/tag/html
has title: HttpClient POST fails to submit the form + resulting string is cut-off (incomplete)
linked to: http://stackoverflow.com/q/2744110
score: 0
has body: I'm writing an app to check for the bus timetable's. Therefor I need to post some data to a html page, submit it, and parse the resulting page with htmlparser. Though it may be asked a lot, can some one help me identify if 1) this page does support post/get (I think it does) 2) which fields I need to use? 3) How to make the actual request? this is my code so far: String url = "http://busspur02.aseag.de/bs.exe?Cmd=RV&amp;Karten=true&amp;DatumT=30&amp;DatumM=4&amp;DatumJ=2010&amp;ZeitH=&amp;ZeitM=&amp;Suchen=%28S%29uchen&amp;GT0=&amp;HT0=&amp;GT1=&amp;HT1="; String charset = "CP1252"; System.out.println("startFrom: "+start_from); System.out.println("goTo: "+destination); //String tag.v List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); params.add(new BasicNameValuePair("HTO", start_from)); params.add(new BasicNameValuePair("HT1", destination)); params.add(new BasicNameValuePair("GTO", "Aachen")); params.add(new BasicNameValuePair("GT1", "Aachen")); params.add(new BasicNameValuePair("DatumT", day)); params.add(new BasicNameValuePair("DatumM", month)); params.add(new BasicNameValuePair("DatumJ", year)); params.add(new BasicNameValuePair("ZeitH", hour)); params.add(new BasicNameValuePair("ZeitM", min)); UrlEncodedFormEntity query = new UrlEncodedFormEntity(params, charset); HttpPost post = new HttpPost(url); post.setEntity(query); InputStream response = new DefaultHttpClient().execute(post).getEntity().getContent(); // Now do your thing with the facebook response. String source = readText(response,"CP1252"); Log.d(TAG_AVV,response.toString()); System.out.println("STREAM "+source); EDIT: This is my new code: try { HttpClient client = new DefaultHttpClient(); String getURL = "http://busspur02.aseag.de/bs.exe?SID=5FC39&amp;ScreenX=1440&amp;ScreenY=900&amp;CMD=CR&amp;Karten=true&amp;DatumT="+day+"&amp;DatumM="+month+"&amp;DatumJ="+year+"&amp;ZeitH="+hour+"&amp;ZeitM="+min+"&amp;Intervall=60&amp;Suchen=(S)uchen&amp;GT0=Aachen&amp;T0=H&amp;HT0="+start_fro…
has answer: http://stackoverflow.com/a/2741793
type: Question
type: AnsweredQuestion
tagged with: java
tagged with: post
answer count: 2
possible better answer: http://stackoverflow.com/a/2741837
accepted answer: http://stackoverflow.com/a/2741793
has answer: http://stackoverflow.com/a/2741837
tagged with: get

http://stackoverflow.com/comment/2657298
type: Comment
has text: You just saved whole day (for researching the wrong direction)
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2642390

http://stackoverflow.com/comment/2616725
score: 24
has text: -1 for unsubstantiated claims on garbage collection.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2606523

http://stackoverflow.com/comment/82659967
type: AnswerComment
has text: @HiteshSahu They are both implemented with Hash Tables (https://en.wikipedia.org/wiki/Hash_table). This is a good data structure for representing a set, efficient in the right ways, and, essentially, a HashMap's keys are implemented as a HashSet. So whoever named them went to some trouble to implement them and was focused on the implementation rather than their purpose (at a guess).
score: 0
comment on: http://stackoverflow.com/a/2775800
type: Comment

http://stackoverflow.com/a/2631583
has comment: http://stackoverflow.com/comment/2646925
type: Answer
score: 3
downvote count: 0
has body: Here is the pseudo code. Use InputStream, but do not wrap a Reader around it. Read bytes containing header and store them into ByteArrayOutputStream. Create ByteArrayInputStream from ByteArrayOutputStream and decode header, this time wrap ByteArrayInputStream into Reader with ASCII charset. Compute the length of non-ascii input, and read that number of bytes into another ByteArrayOutputStream. Create another ByteArrayInputStream from the second ByteArrayOutputStream and wrap it with Reader with charset from the header.
answers question: http://stackoverflow.com/q/2631507
upvote count: 3

http://stackoverflow.com/a/20787413
has body: It seems you can do this with EclipseLink too. Check this : http://wiki.eclipse.org/EclipseLink/Examples/JPA/Pagination : Query query = em.createQuery... query.setHint(QueryHints.CURSOR, true) .setHint(QueryHints.SCROLLABLE_CURSOR, true) ScrollableCursor scrl = (ScrollableCursor)q.getSingleResult(); Object o = null; while ((o = scrl.next()) != null) { ... }
downvote count: 0
has comment: http://stackoverflow.com/comment/54450824
score: 4
answers question: http://stackoverflow.com/q/2761543
type: Answer
upvote count: 4

http://stackoverflow.com/q/2735098
favorite count: 0
has answer: http://stackoverflow.com/a/2753793
has title: JSF : able to do mass update but unable to update a single row in a datatable
score: 2
tagged with: jsf
upvote count: 2
type: UnansweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/2736396
type: Question
has body: I have a simple data object: Car. I am showing the properties of Car objects in a JSF datatable. If i display the properties using inputText tags, i am able to get the modified values in the managed bean. However i just want a single row editable. So have placed a edit button in a separate column and inputText and outputText for every property of Car. the edit button just toggles the rendering of inputText and outputText. Plus i placed a update button in a separate column which is used to save the updated values. However on clicking the update button, i still get the old values instead of the modified values. Here is the complete code: public class Car { int id; String brand; String color; public Car(int id, String brand, String color) { this.id = id; this.brand = brand; this.color = color; } //getters and setters of id, brand, color } Here is the managed bean: import java.util.ArrayList; import java.util.List; import javax.faces.bean.ManagedBean; import javax.faces.bean.RequestScoped; import javax.faces.component.UIData; @ManagedBean(name = "CarTree") @RequestScoped public class CarTree { int editableRowId; List<Car> carList; private UIData myTable; public CarTree() { carList = new ArrayList<Car>(); carList.add(new Car(1, "jaguar", "grey")); carList.add(new Car(2, "ferari", "red")); carList.add(new Car(3, "camri", "steel")); } public String update() { System.out.println("updating..."); //below statments print old values, was expecting modified values System.out.println("new car brand is:" + ((Car) myTable.getRowData()).brand); System.out.println("new car color is:" + ((Car) myTable.getRowData()).color); //how to get modified row values in this method?? return null; } public int getEditableRowId() { return editableRowId; } public void setEditableRowId(int editableRowId) { this.editableRowId = editableRowId; } public UIData getMyTable() { return myTable; } public void setMyTable(UIData myTable) { this.myTable = myTable; } public List<Car> getCars() { return carList; …
tagged with: jsf-2
answer count: 2
downvote count: 0

http://stackoverflow.com/comment/39657029
type: Comment
score: 8
has text: I prefer `getClass() == o.getClass()`. Otherwise a `Dog` may accidentally equal a `Pug` even though the `Pug` doesn't equal the `Dog`. If the class is final `instanceof` works fine of course, but then it's equivalent to class comparison anyway.
comment on: http://stackoverflow.com/a/2750800
type: AnswerComment

http://stackoverflow.com/comment/5080342
score: 0
type: Comment
comment on: http://stackoverflow.com/a/4606099
type: AnswerComment
has text: Sindri - Just to make sure I made myself clear: Your customers are free to use any SAML compliant software on their end. They can also choose to use ADFSv1 (for WS-Fed). A single instance of PF running in *your* infrastructure can handle all the Federation specifications your customers may be using. There is no requirement that your customers use PingFederate. Feel free to contact us directly for more information.

http://stackoverflow.com/a/2655375
has comment: http://stackoverflow.com/comment/110533024
downvote count: 0
has body: The result of the computation is likely something like 5.999999999994, as the floating-point result is not necessarily exactly an integer. When you cast to an int, you truncate, and the result is 5. For another similar set of arguments, you might see a result of 6.0000000000002, and it would give you 6. But the fact that this is so sensitive to floating-point representation calls into question why you think you want this -- maybe there's a better way to do what you wish to do. For example the answer above is correct, this simplifies, and then it's even less clear what the point is. To really do what I think you imagine you want to do, you need to not use doubles or floats. You need java.util.BigDecimal -- look up how it works. You can use it to "exactly" multiply 5 and 1.2 to get 6.
type: Answer
score: 4
upvote count: 4
answers question: http://stackoverflow.com/q/2655280

http://stackoverflow.com/comment/2802892
type: AnswerComment
comment on: http://stackoverflow.com/a/2769442
type: Comment
has text: @Paul Tomblin: ah ah, I am that kind of guy ;) *The* place to stash a file that the user can't find is on the server-side, on your own server :) Then your co-worker and myself shall re-image/re-use/copy a "clean install" of, say, Windows, forging the MAC adress, and re-install a new "30 days" copy evaluation :) Note that I only do it to understand cracking attempts (see my answer) in order to better protect our software :)
score: 0

http://stackoverflow.com/q/2716002
has comment: http://stackoverflow.com/comment/2741709
has answer: http://stackoverflow.com/a/2716023
has comment: http://stackoverflow.com/comment/2741539
possible better answer: http://stackoverflow.com/a/2716021
has answer: http://stackoverflow.com/a/2716198
has comment: http://stackoverflow.com/comment/2741559
has comment: http://stackoverflow.com/comment/2741558
type: Question
tagged with: jakarta-ee
has answer: http://stackoverflow.com/a/2716014
accepted answer: http://stackoverflow.com/a/2716014
has answer: http://stackoverflow.com/a/2716078
has answer: http://stackoverflow.com/a/2716039
has comment: http://stackoverflow.com/comment/2741617
has comment: http://stackoverflow.com/comment/2741529
favorite count: 0
linked to: http://stackoverflow.com/q/2306257
has answer: http://stackoverflow.com/a/2716026
has answer: http://stackoverflow.com/a/2716030
has answer: http://stackoverflow.com/a/2718533
has comment: http://stackoverflow.com/comment/2743949
upvote count: 24
has answer: http://stackoverflow.com/a/2716021
answer count: 10
has comment: http://stackoverflow.com/comment/2741580
has body: A co-worker asked me to change a signature from using a primitive "boolean" to using a classed "Boolean". He didn't offer a very good explanation why? Have any of you heard of this and can any of you explain why it matters or doesn't matter? Edit: He mentioned that it was good practice for public methods. The use of the field is just a flag that tells me whether to call one flow or another depending on whether it's true or false.
has comment: http://stackoverflow.com/comment/2741564
has answer: http://stackoverflow.com/a/2716202
linked to: http://stackoverflow.com/q/1295170
score: 23
downvote count: 1
type: AnsweredQuestion
has title: Why should I pass Boolean as a parameter instead of "boolean"?
tagged with: java

http://stackoverflow.com/q/2685825
linked to: http://stackoverflow.com/q/218384
tagged with: rmi
has body: I'm currently playing with remote environments using rmi registry. My server is like this: import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; public class Server { public static void main(String args[]){ if(args.length"); System.exit(-1); } try{ Registry r=LocateRegistry.getRegistry(); MethodsImp methods=new MethodsImp(); //have the object to be remotely accessed so will bind it to the registry System.out.println("Will register on "+args[0]); r.rebind(args[0], methods); } catch(Exception e){ System.out.println("Something went wrong when registring the methods"); System.out.println(e.getMessage()); System.exit(-1); } } } When I run the program by: java -classpath /home/outsider/Desktop/RIM/RIM_TP1_correct/src -Djava.rmi.server.codebase=file:/home/outsider/Desktop/RIM/RIM_TP1_correct/src/ Server regsiter_name I get this: Will register on regsiter_name Something went wrong when registring the methods null For some reason when I used r.rebind it throws an exception which has the message null. Before trying to run the program I install the rmiregistry by doing rmiregistry & On the shell. I can't find out what I'm doing wrong. If anyone could help it would be great
tagged with: java
score: -1
duplicate of: http://stackoverflow.com/q/218384
linked to: http://stackoverflow.com/q/2194935
type: Question
upvote count: 0
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/2706775
has title: RMI registry failed....exception sais null
has answer: http://stackoverflow.com/a/2772601
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/2706736
has comment: http://stackoverflow.com/comment/62252934
downvote count: 1

http://stackoverflow.com/a/2777347
answers question: http://stackoverflow.com/q/2777005
upvote count: 1
type: Answer
downvote count: 0
score: 1
has body: I don't think you will find any common ones supporting pipe-lining. Jetty HttpClient seems to support it from document but I couldn't make it to do it. Please note that Pipeline is different from keep-alive. Keep-alive just means reuse the connection but it may still send only one request at a time over the connection. With pipe-lining, you can send several requests at the same time over the same connection and wait for their respective responses.

http://stackoverflow.com/a/2671730
type: Answer
has comment: http://stackoverflow.com/comment/2691308
upvote count: 6
accepted answer of: http://stackoverflow.com/q/2671718
answers question: http://stackoverflow.com/q/2671718
score: 6
has comment: http://stackoverflow.com/comment/57573755
has body: It's because when you are shifting a 32-bit int, it just takes the last 5 bits of the shift distance. (i.e. mod 32), so -1 mod 32 = 31, so you are shifting right by 31 bits. When you are shifting a negative number (the beginning bits of which are all 1s), you end up with a 1. Similarly, shifting right by -2 is shifting right by 30 bits, etc. If you shift a long, it would take 6 bits of the shift distance. See here for the specification of how the shift operators work: http://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.19
has comment: http://stackoverflow.com/comment/2690426
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/2766679
answers question: http://stackoverflow.com/q/2766039
downvote count: 0
type: Answer
score: 1
upvote count: 1
has body: Is there any integrity constraint or trigger on the table ? If so, droping it before inserts will help, but you have to be sure that you can afford the consequences.
has comment: http://stackoverflow.com/comment/2804723

http://stackoverflow.com/comment/2665089
has text: I think I found my problem... This call: env->CallVoidMethod(obj,aMethodId, &rawAudioCopy); was passing by ref instead of by value. Changing to this: env->CallVoidMethod(obj,aMethodId, rawAudioCopy); Seems to address the issue. Is there any good reference manual and examples to keep me going? I'm really hurting for help here.
comment on: http://stackoverflow.com/q/2648877
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/6144782
comment on: http://stackoverflow.com/q/2617662
has text: Writing self-modify code is likely pretty hard to do. Assembler can do this trivially.
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/q/2657432
tagged with: java
score: 17
upvote count: 17
type: Question
answer count: 2
downvote count: 0
possible better answer: http://stackoverflow.com/a/8671538
favorite count: 0
has answer: http://stackoverflow.com/a/2657465
accepted answer: http://stackoverflow.com/a/2657465
tagged with: spring
has title: Make Spring Service Classes Final?
type: AnsweredQuestion
has body: Can I make the spring service classes final? Is there any harm doing that? Nobody is going to extend the class. Is there any issue? public final class MyService { // Depedencies go here. }
has answer: http://stackoverflow.com/a/8671538

http://stackoverflow.com/a/2713385
answers question: http://stackoverflow.com/q/2713216
has body: You can use an Interpreter and a Builder. The Interpreter parses the source and identifies keys and values, which are passed to the Builder, which constructs any data structure you desire.
type: Answer
score: 0

http://stackoverflow.com/q/2771439
tagged with: java
tagged with: pagination
has body: I want to implement pagination using JDBC. The actual thing I want to know is "How can i get first 50 and then next 50 records from database for page 1 and 2 respectively" My Query is Select * from data [data table contains 20,000 rows] For page #1 I get 50 records and for page #2 I want to get next 50 records. How can I implement it efficiently in JDBC? I have searched and found that rs.absolute(row) is the way to skip first page records but it takes some amount of time on large result sets and I don't want to bear this amount of time. Also, I don't want to use rownum and limit + offset in query because these are not good to use in query, I dont know why, still I don't want to use it in query. Can anyone help me how to get limited ResultSet for pagination or is there any way JDBC is giving us?
accepted answer: http://stackoverflow.com/a/2772287
has answer: http://stackoverflow.com/a/3005637
answer count: 13
possible better answer: http://stackoverflow.com/a/2772937
upvote count: 43
tagged with: sql
has answer: http://stackoverflow.com/a/2772937
has answer: http://stackoverflow.com/a/50526351
has title: JDBC Pagination
score: 42
has answer: http://stackoverflow.com/a/35359610
favorite count: 0
has answer: http://stackoverflow.com/a/35245564
has answer: http://stackoverflow.com/a/14566008
linked to: http://stackoverflow.com/q/489360
has answer: http://stackoverflow.com/a/2771557
tagged with: jdbc
has answer: http://stackoverflow.com/a/2806779
has answer: http://stackoverflow.com/a/3006053
has answer: http://stackoverflow.com/a/2772287
has answer: http://stackoverflow.com/a/17524977
linked to: http://stackoverflow.com/q/1986998
has answer: http://stackoverflow.com/a/2772046
downvote count: 1
type: Question
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/470542
has answer: http://stackoverflow.com/a/2771504

http://stackoverflow.com/a/8971603
score: 8
downvote count: 0
upvote count: 8
has body: Example private BigInteger checksum(Object obj) throws IOException, NoSuchAlgorithmException { if (obj == null) { return BigInteger.ZERO; } ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(obj); oos.close(); MessageDigest m = MessageDigest.getInstance("SHA1"); m.update(baos.toByteArray()); return new BigInteger(1, m.digest()); }
answers question: http://stackoverflow.com/q/2644847
type: Answer

http://stackoverflow.com/a/2614761
type: Answer
score: 2
has body: Is this of any use? http://docs.jboss.org/hibernate/core/3.3/reference/en/html/querycriteria.html#querycriteria-ordering
downvote count: 0
upvote count: 2
answers question: http://stackoverflow.com/q/2614361

http://stackoverflow.com/a/2747933
upvote count: 1
has comment: http://stackoverflow.com/comment/2777904
score: 1
has comment: http://stackoverflow.com/comment/2777829
downvote count: 0
answers question: http://stackoverflow.com/q/2747416
has comment: http://stackoverflow.com/comment/2777965
has comment: http://stackoverflow.com/comment/2777719
has body: I'm not sure whether the Android API is different, but a normal Java application could catch a SAXParseException when parsing and look at the line number.
type: Answer

http://stackoverflow.com/a/2786467
accepted answer of: http://stackoverflow.com/q/2786426
type: Answer
upvote count: 13
has comment: http://stackoverflow.com/comment/16139044
score: 13
has comment: http://stackoverflow.com/comment/4774771
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2786426
has body: If you need this in a servlet then use getServletContext().getRealPath("/filepathInContext")!

http://stackoverflow.com/a/2601934
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/2601883
downvote count: 0
score: 1
has body: IOException Signals that an I/O exception of some sort has occurred. This class is the general class of exceptions produced by failed or interrupted I/O operations. Static keyword A Java keyword used to define a variable as a class variable. Classes maintain one copy of class variables regardless of how many instances exist of that class. static can also be used to define a method as a class method. Class methods are invoked by the class instead of a specific instance, and can only operate on class variables.

http://stackoverflow.com/comment/73145556
type: Comment
score: 3
has text: a whole library to simple get a random char?
type: AnswerComment
comment on: http://stackoverflow.com/a/42612994

http://stackoverflow.com/a/2690060
has body: You have to add the inner inputs components to the fragments, in this fashion: Fragment f = new Fragment("estimatedDuration", "duration_fragment", OptionsPanel.this); f.add(new TextField("estimated_duration", new Model&lt;String&gt;("3")); f.add(...); [form.]add(f);
score: 0
answers question: http://stackoverflow.com/q/2689401
type: Answer
has comment: http://stackoverflow.com/comment/2711115

http://stackoverflow.com/a/2747008
has body: There is potential for a minor performance loss, because the compiler sometimes adds synthetic bridge methods. Consider the following example: public class GenericPerformance { public static void main(final String[] args) { final Stuff&lt;Integer&gt; stuff = new IntStuff(); final Integer data = stuff.getData(); stuff.putData(data); } } interface Stuff&lt;T&gt; { T getData(); void putData(T stuff); } class IntStuff implements Stuff&lt;Integer&gt; { private Integer stuff; public Integer getData() { return stuff; } public void putData(final Integer stuff) { this.stuff = stuff; } } If you look at the generated bytecode, you will see: In the main method, the erased interface methods java.lang.Object Stuff.getData() void Stuff.putData(java.lang.Object) are invoked. That methods, implemented in IntStuff with the signatures java.lang.Object getData() void putData(java.lang.Object) both with the modifiers public bridge synthetic, delegate to the "real" methods java.lang.Integer IntStuff.getData() void putData(java.lang.Integer) The first synthetic method merely returns the Integer result, while the second performs a cast from Object to Integer before calling putData(Integer). If you change the stuff variable to type IntStuff, then both Integer methods are called instead of the synthetic Object methods.
type: AcceptedAnswer
upvote count: 11
has comment: http://stackoverflow.com/comment/2777454
accepted answer of: http://stackoverflow.com/q/2745944
type: Answer
score: 11
answers question: http://stackoverflow.com/q/2745944
has comment: http://stackoverflow.com/comment/2776644
downvote count: 0

http://stackoverflow.com/q/2612633
favorite count: 0
score: 128
answer count: 5
upvote count: 128
has answer: http://stackoverflow.com/a/36695909
linked to: http://stackoverflow.com/q/17269843
has answer: http://stackoverflow.com/a/2612650
accepted answer: http://stackoverflow.com/a/2612688
tagged with: templates
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/79351252
has body: I dislike the default Javadocs generated for me when I create a Class or methods, especially the @author variable, which is the current system username on my windows box. I would like to change it. Is this possible?
possible better answer: http://stackoverflow.com/a/2612650
tagged with: java
tagged with: javadoc
has answer: http://stackoverflow.com/a/23510251
linked to: http://stackoverflow.com/q/935711
type: Question
has title: How do I change the Javadocs template generated in Eclipse?
has answer: http://stackoverflow.com/a/15357579
tagged with: eclipse
has answer: http://stackoverflow.com/a/2612688
has comment: http://stackoverflow.com/comment/45795070
downvote count: 0

http://stackoverflow.com/comment/2671417
comment on: http://stackoverflow.com/a/2654986
score: 0
type: AnswerComment
type: Comment
has text: Fixed the problem by reinstalling netbeans :/ how bizarre is that!

http://stackoverflow.com/a/2739759
answers question: http://stackoverflow.com/q/2739704
score: 1
upvote count: 1
type: Answer
has body: Make sure you call JComponent.setOpaque(boolean) for the component you're working with.... some Swing components default to opaque == false and just show the color of whatever is behind it (e.g. a button in a textured panel).
downvote count: 0

http://stackoverflow.com/comment/2775048
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2745345
has text: that was a joke, i wasn't saying you should do it in perl. but do consider a simple parser. try to find the snort rule syntax definition (let me know if you do find it). if you're lucky, it you may even find it defined in a lexer/parser syntax understandable by a java lib.
type: AnswerComment

http://stackoverflow.com/q/2669414
type: Question
has answer: http://stackoverflow.com/a/59783710
has answer: http://stackoverflow.com/a/69617858
downvote count: 0
has answer: http://stackoverflow.com/a/2669514
favorite count: 0
has body: I wanted to choose the order to execute the JUnit tests. I have 4 classes with several test methods in it, my goal is to execute, for instance, method Y of class A, then method X from class B, and finally method Z from class A. Would you help please?
possible better answer: http://stackoverflow.com/a/22987758
answer count: 9
has answer: http://stackoverflow.com/a/3656677
upvote count: 10
tagged with: junit
has title: Choose order to execute JUnit tests
has answer: http://stackoverflow.com/a/2669449
tagged with: netbeans
has answer: http://stackoverflow.com/a/22987758
has answer: http://stackoverflow.com/a/22956026
tagged with: testing
type: AnsweredQuestion
tagged with: java
score: 10
has answer: http://stackoverflow.com/a/2669508
has answer: http://stackoverflow.com/a/2669475
accepted answer: http://stackoverflow.com/a/2669514

http://stackoverflow.com/a/2735082
downvote count: 0
has comment: http://stackoverflow.com/comment/2767361
has comment: http://stackoverflow.com/comment/2770953
accepted answer of: http://stackoverflow.com/q/2735037
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2735037
upvote count: 13
has body: It depends what you mean by "correct". Assuming that you're using the hashCode() of all the relevant equals()-defining fields, then yes, it's "correct". However, such formulas probably will not have a good distribution, and therefore would likely cause more collisions than otherwise, which will have a detrimental effect on performance. Here's a quote from Effective Java 2nd Edition, Item 9: Always override hashCode when you override equals While the recipe in this item yields reasonably good hash functions, it does not yield state-of-the-art hash functions, nor do Java platform libraries provide such hash functions as of release 1.6. Writing such hash functions is a research topic, best left to mathematicians and computer scientists. [...Nonetheless,] the techniques described in this item should be adequate for most applications. It may not require a lot of mathematical power to evaluate how good your proposed hash function is, but why even bother? Why not just follow something that has been anecdotally proven to be adequate in practice? Josh Bloch's recipe Store some constant nonzero value, say 17, in an int variable called result. Compute an int hashcode c for each field: If the field is a boolean, compute (f ? 1 : 0) If the field is a byte, char, short, int, compute (int) f If the field is a long, compute (int) (f ^ (f &gt;&gt;&gt; 32)) If the field is a float, compute Float.floatToIntBits(f) If the field is a double, compute Double.doubleToLongBits(f), then hash the resulting long as in above. If the field is an object reference and this class's equals method compares the field by recursively invoking equals, recursively invoke hashCode on the field. If the value of the field is null, return 0. If the field is an array, treat it as if each element is a separate field. If every element in an array field is significant, you can use one of the Arrays.hashCode methods added in release 1.5. Combine the hashcode c into result as follows: result = 31 * result + c; Now,…
type: Answer
score: 13

http://stackoverflow.com/a/2680895
answers question: http://stackoverflow.com/q/2680890
type: Answer
has comment: http://stackoverflow.com/comment/2700593
has comment: http://stackoverflow.com/comment/2700586
score: 0
has comment: http://stackoverflow.com/comment/2700599
has body: have a look here from the sun site. extract Variable names should be short yet meaningful. The choice of a variable name should be mnemonic- that is, designed to indicate to the casual observer the intent of its use. One-character variable names should be avoided except for temporary "throwaway" variables. Common names for temporary variables are i, j, k, m, and n for integers; c, d, and e for characters.
has comment: http://stackoverflow.com/comment/2700566

http://stackoverflow.com/a/2784589
has body: your customComparator class must implement java.util.Comparator in order to be used. it must also overide compare() AND equals() compare() must answer the question: Is object 1 less than, equal to or greater than object 2? full docs: http://java.sun.com/j2se/1.5.0/docs/api/java/util/Comparator.html
answers question: http://stackoverflow.com/q/2784514
downvote count: 0
type: Answer
score: 3
upvote count: 3

http://stackoverflow.com/comment/2751392
has text: Looking for a code example, I have no idea what and how to build.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/2724772
type: Comment

http://stackoverflow.com/a/2766103
answers question: http://stackoverflow.com/q/2764842
downvote count: 1
upvote count: 0
score: -1
has body: I wonder if there is some framework (both client and server side) to deal with this issues. As far as I know, there isn't You're kidding! There's a squillion Java Ajax frameworks: Top of the list of a google for "java ajax framework" was: http://ajaxpatterns.org/Java_Ajax_Frameworks
type: Answer

http://stackoverflow.com/a/8160729
answers question: http://stackoverflow.com/q/2598129
has body: char[] chars = s.toCharArray(); HashSet&lt;Character&gt; charz = new HashSet&lt;Character&gt;(); for(Character c : s.toCharArray() ) { if(!charz.contains(c)) { charz.add(c); //System.out.print(c); } } for(Character c : charz) { System.out.print(c); }
type: Answer
upvote count: 4
downvote count: 0
has comment: http://stackoverflow.com/comment/72890675
score: 4

http://stackoverflow.com/comment/2614569
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2604614
has text: it will still work though won't it?

http://stackoverflow.com/a/2631333
answers question: http://stackoverflow.com/q/2630775
score: 0
has comment: http://stackoverflow.com/comment/2645175
type: Answer
has body: Just a few HINTs: There is no way to set file permissions within a war/jar. The permissions depend on the oracleas user's umask. Change that and you'll be all set. Is there a way you can keep the war packaged?

http://stackoverflow.com/comment/2817533
type: Comment
has text: Ok. I see your point. You might want to change JForm to JFrame though... or am I misunderstanding anything else?
comment on: http://stackoverflow.com/a/2782303
score: 0
type: AnswerComment

http://stackoverflow.com/q/2752192
has answer: http://stackoverflow.com/a/5206601
upvote count: 17
linked to: http://stackoverflow.com/q/4480334
linked to: http://stackoverflow.com/q/122407
has answer: http://stackoverflow.com/a/2752198
has answer: http://stackoverflow.com/a/2752203
tagged with: java
duplicate of: http://stackoverflow.com/q/4480334
has answer: http://stackoverflow.com/a/2752205
tagged with: function
has answer: http://stackoverflow.com/a/2752218
tagged with: arrays
downvote count: 0
has title: Array of function pointers in Java
tagged with: pointers
has answer: http://stackoverflow.com/a/13640572
possible better answer: http://stackoverflow.com/a/2752218
type: AnsweredQuestion
has body: I have read this question and I'm still not sure whether it is possible to keep pointers to methods in an array in Java. If anyone knows if this is possible (or not), it would be a real help. I'm trying to find an elegant solution of keeping a list of Strings and associated functions without writing a mess of hundreds of if statements. Cheers
accepted answer: http://stackoverflow.com/a/2752205
favorite count: 0
answer count: 6
score: 17
type: Question

http://stackoverflow.com/comment/2692432
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2673540
has text: but the problem here is, how can i achieve mydomain.com/something/companyname/pages/somepage.jsf pattern ? the URL in browser must include companyName .

http://stackoverflow.com/comment/138095708
type: QuestionComment
comment on: http://stackoverflow.com/q/2597083
has text: So I ran into this same problem. It's a bandaid workaround but you can edit your input as it comes in to replace the 'T' with a space, then change your format to "yyyy-MM-dd hh:mm:ss'Z'"
score: 0
type: Comment

http://stackoverflow.com/a/2704036
score: 20
has body: The difference between offer and add is explained by these two excerpts from the javadocs: From the Collection interface: If a collection refuses to add a particular element for any reason other than that it already contains the element, it must throw an exception (rather than returning false). This preserves the invariant that a collection always contains the specified element after this call returns. From the Queue interface When using queues that may impose insertion restrictions (for example capacity bounds), method offer is generally preferable to method Collection.add(E), which can fail to insert an element only by throwing an exception. PriorityQueue is a Queue implementation that does not impose any insertion restrictions. Therefore the add and offer methods have the same semantics. By contrast, ArrayBlockingQueue is an implementation in which offer and add behave differently, depending on how the queue was instantiated.
type: Answer
upvote count: 20
downvote count: 0
answers question: http://stackoverflow.com/q/2703984

http://stackoverflow.com/comment/2811489
score: 1
comment on: http://stackoverflow.com/a/2776605
type: AnswerComment
type: Comment
has text: It avoids putting all of the if/else logic in one place by dispersing it through many classes! That's not a bonus in my book. (When in doubt, avoid following design patterns.)

http://stackoverflow.com/comment/15530457
has text: Use "@Override public Void visitCompilationUnit( CompilationUnitTree unit, Void arg ) { System.out.println( "Package: " + unit.getPackageName() ); return super.visitCompilationUnit( unit, arg ); };" to get the package.
comment on: http://stackoverflow.com/a/2637147
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/2785891
type: Question
has answer: http://stackoverflow.com/a/2785900
has answer: http://stackoverflow.com/a/2785920
tagged with: function
has answer: http://stackoverflow.com/a/2786129
has body: I'm a java programmer and am trying to understand the difference between a method (java methods) and a function (such as in c++). I used to think that they are the same, just different naming conventions for different programming languages. But now that I know they are not, I am having trouble understanding the difference. I know that a method relates to an instance of a class and has access to class data (member variables), while a function does not (?). So is a function kind of like a static method? See here for explanations I read which led me to think this.
tagged with: programming-languages
has comment: http://stackoverflow.com/comment/2821800
downvote count: 0
favorite count: 0
answer count: 5
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2792569
has answer: http://stackoverflow.com/a/2785909
linked to: http://stackoverflow.com/q/155609
score: 7
tagged with: java
has title: Is a function kind of like a static method?
upvote count: 7
tagged with: methods

http://stackoverflow.com/comment/2674917
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2653469
has text: AFAIK, as of now only Oracle has these features.

http://stackoverflow.com/comment/2684813
type: Comment
comment on: http://stackoverflow.com/q/2666758
has text: When you drag the side of the column every column in the table resizes instead of the one beeing dragged. Moreover it is happening in a crazy manner like thousands of events were wrongly processed
score: 0
type: QuestionComment

blobstore
tags question: http://stackoverflow.com/q/2643744
type: Tag
tags question: http://stackoverflow.com/q/2724696
tag name: blobstore
tags question: http://stackoverflow.com/q/2605687
tags question: http://stackoverflow.com/q/2637521

http://stackoverflow.com/a/4661068
has comment: http://stackoverflow.com/comment/42692339
has comment: http://stackoverflow.com/comment/52119941
downvote count: 2
upvote count: 24
has body: I don't quite see why you would not want to use abstract modifier -- this is intended for forcing implementation by sub-class, and only need to be used for some methods, not all. Or maybe you are thinking of C++ style "pure abstract" classes? But one other thing that many Java developers are not aware of is that it is also possible to override non-abstract methods and declare them abstract; like: public abstract String toString(); // force re-definition so that even though java.lang.Object already defines an implementation, you can force sub-classes to define it again.
answers question: http://stackoverflow.com/q/2742463
has comment: http://stackoverflow.com/comment/74332195
score: 22
type: Answer

http://stackoverflow.com/a/2606456
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2616879
score: 8
answers question: http://stackoverflow.com/q/2606424
type: Answer
accepted answer of: http://stackoverflow.com/q/2606424
has comment: http://stackoverflow.com/comment/2616654
has body: Obfuscation tools such as ProGuard usually provide a feature to remove unused classes (and even fields and methods) from the jar file. You have to be careful to verify everything still works, 'though, because you might be using reflecton to access classes or methods that ProGuard can't analyze. You can use only that feature and already get quite some saving Or you could combine it with other space-saving obfuscation techniques (such as class and method renaming) to save even more space at the cost of harder debugging (your stack traces will become harder to parse).
upvote count: 8
has comment: http://stackoverflow.com/comment/2616847
has comment: http://stackoverflow.com/comment/2616709

http://stackoverflow.com/comment/96592266
score: 0
type: AnswerComment
type: Comment
has text: >> … when you click on Go, it compares it to Java, and when you click on Java it compares it to C… << —— When you click on Go you have the choice of comparison with C++ C# .NET Core Java JavaScript Python —— When you click on Java you have the choice of comparison with C C++ C# .NET Core Substrate VM.
comment on: http://stackoverflow.com/a/52325174

http://stackoverflow.com/q/2600608
favorite count: 0
has comment: http://stackoverflow.com/comment/2610254
upvote count: 5
possible better answer: http://stackoverflow.com/a/2600759
has answer: http://stackoverflow.com/a/2600691
has comment: http://stackoverflow.com/comment/2609748
has answer: http://stackoverflow.com/a/2600683
answer count: 4
has title: Most frequent words
accepted answer: http://stackoverflow.com/a/2600683
has answer: http://stackoverflow.com/a/2600672
type: AnsweredQuestion
has body: What's the most efficient way in Java to get the 50 most frequent words with their frequency out of a text? I want to search around ~1,000,000 texts with each have around ~10,000 words and hope that it works in a reasonable time frame.
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/9431805
has answer: http://stackoverflow.com/a/2600759
score: 5
downvote count: 0
has comment: http://stackoverflow.com/comment/2616348
has comment: http://stackoverflow.com/comment/2610779

http://stackoverflow.com/comment/2790833
comment on: http://stackoverflow.com/a/2756265
type: AnswerComment
score: 0
type: Comment
has text: @Dan: you should make clear in the answer that the `std::stack::pop()` has a different interface than in the question (ie., that `pop()` on;y adjusts the container, it doesn't return the top element either as a rturn value or via a passed in reference).

http://stackoverflow.com/q/2611496
has comment: http://stackoverflow.com/comment/2622191
has title: Value isn't being saved in the strings
type: AnsweredQuestion
has body: I'm trying to make a class where I put a key and value into the put method which puts the key in the k string array and value into the v string array, however it is not being saved in the array when I do get or display. For example: put(dan,30) get(dan) returns null display returns null null 10 times. Does anyone know what's wrong? public class Memory { final int INITIAL_CAPACITY = 10; String[] k = new String[INITIAL_CAPACITY]; String[] v = new String[INITIAL_CAPACITY]; int count = 0; public Memory() { count = 0; } public int size() { return count; } public void put(String key, String value) { int a = 0; boolean found = false; for (int i = 0; i &lt; k.length; i++) { //System.out.println("key is " + key.equals(k[i])); if (key.equalsIgnoreCase(k[i])) { v[i] = value; found = true; } if (found) break; a++; } //System.out.println(a == k.length); if (a == k.length); { k[count] = key; v[count] = value; //System.out.println(k[count] + " " + v[count]); count++; //System.out.println(count); } } public String get(String key) { String output = "a"; for(int i = 0; i &lt; k.length; i++) { if(!key.equalsIgnoreCase(k[i])) { output = null; } else { output = v[i]; return output; } } return output; } public void clear() { for (int i = 0; i &lt; k.length; i++) { k[i] = null; v[i] = null; } count = 0; } public void display() { for (int i = 0; i &lt; k.length; i++) { System.out.println(k[i] + " " + v[i]); } } }
has comment: http://stackoverflow.com/comment/2622179
accepted answer: http://stackoverflow.com/a/2611532
tagged with: java
has comment: http://stackoverflow.com/comment/2622182
type: Question
score: 0
answer count: 3
has comment: http://stackoverflow.com/comment/2622132
tagged with: arrays
tagged with: string
has answer: http://stackoverflow.com/a/2611530
has answer: http://stackoverflow.com/a/2611579
has answer: http://stackoverflow.com/a/2611532
has comment: http://stackoverflow.com/comment/2622240
possible better answer: http://stackoverflow.com/a/2611530
has comment: http://stackoverflow.com/comment/2622162
has comment: http://stackoverflow.com/comment/2622157

http://stackoverflow.com/comment/20539594
type: Comment
comment on: http://stackoverflow.com/a/2622870
score: 0
type: AnswerComment
has text: Have you had any luck CHiRo79? I'm 14 and just starting out with programming... would love to do something with my music for final projec!!!

http://stackoverflow.com/q/2729947
favorite count: 0
tagged with: media-player
type: UnansweredQuestion
tagged with: android
tagged with: rtsp
has answer: http://stackoverflow.com/a/7967380
has title: How to resume video playback after the surface was destroyed?
has comment: http://stackoverflow.com/comment/37149874
type: Question
score: 5
upvote count: 5
tagged with: java
has body: I'm working with the media player on a streaming application (RTSP): Video and sound are played great but when an incoming call pauses the Activity, the Surface is destroyed (I know this because of traces in SurfaceHolder.Callback). Once the call finishes, the activity is resumed and a new Surface is created. I've tried to assign it to the player via setDisplay(SurfaceHolder sh) method but so far, only the sound of the video can be heard. The work around to resume a video stream is: Restart the MediaPlayer object. Wait for the buffer to fill. Perform a seek via the mediaPlayer. Wait for the buffer to fill. This is annoying as the player should be able to be paused when a call is received, bind the new surface when the call completed and the Activity resume and play the video with no buffering at all.
answer count: 1
downvote count: 0

http://stackoverflow.com/q/2632033
answer count: 2
tagged with: guice
tagged with: user-interface
downvote count: 0
has comment: http://stackoverflow.com/comment/2650033
has body: I have a Swing application that I would like to convert from spaghetti to using dependency injection with Guice. Using Guice to provide services like configuration and task queues is going great but I'm now starting on the GUI of the app and am unsure of how to proceed. The application is basically a JFrame with a bunch of tabs in a JTabbedPane. Each of the tabs is a separate JPanel subclass that lays out the various components and needs services to perform actions when certain buttons are pressed. In the current application, this looks somewhat like this: @Inject public MainFrame(SomeService service, Executor ex, Configuration config) { tabsPane = new JTabbedPane(); // Create the panels for each tab and add them to the tabbedpane somePanel = new SomeTabPanel(service, ex, config); tabsPane.addTab("Panel 1", somePanel); someOtherPanel = new SomeOtherTabPanel(service, ex, config); tabsPane.addTab("Panel 2", someOtherPanel); ... do more stuff } Obviously, this doesn't exactly follow DI best practices. I don't want to have to @Inject the tabs because that would get me a constructor with dozens of parameters. I do want to use Guice to inject the required dependencies into whatever tab objects I need without me having to pass all of those dependencies to the tab constructors. All of the dependencies for the tab objects are services that my Module knows about, so basically all I think I want to do is to ask Guice for the required objects and have them constructed for me.
favorite count: 0
has comment: http://stackoverflow.com/comment/2648492
possible better answer: http://stackoverflow.com/a/2632130
accepted answer: http://stackoverflow.com/a/2632151
has answer: http://stackoverflow.com/a/2632130
type: AnsweredQuestion
score: 7
tagged with: java
tagged with: swing
upvote count: 7
type: Question
tagged with: dependency-injection
has title: How to use Guice in Swing application
has answer: http://stackoverflow.com/a/2632151

http://stackoverflow.com/q/2777509
has answer: http://stackoverflow.com/a/3666894
tagged with: numbers
has answer: http://stackoverflow.com/a/2778069
tagged with: math
tagged with: java
has answer: http://stackoverflow.com/a/3667096
has answer: http://stackoverflow.com/a/2777526
score: 9
type: Question
has answer: http://stackoverflow.com/a/2777563
has comment: http://stackoverflow.com/comment/33022028
upvote count: 9
has answer: http://stackoverflow.com/a/2807989
answer count: 11
has comment: http://stackoverflow.com/comment/2812648
has title: Checking if an int is prime more efficiently
has answer: http://stackoverflow.com/a/2777523
downvote count: 0
has answer: http://stackoverflow.com/a/2799732
favorite count: 0
has answer: http://stackoverflow.com/a/2777532
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2777557
has body: I recently was part of a small java programming competition at my school. My partner and I have just finished our first pure oop class and most of the questions were out of our league so we settled on this one (and I am paraphrasing somewhat): "given an input integer n return the next int that is prime and its reverse is also prime for example if n = 18 your program should print 31" because 31 and 13 are both prime. Your .class file would then have a test case of all the possible numbers from 1-2,000,000,000 passed to it and it had to return the correct answer within 10 seconds to be considered valid. We found a solution but with larger test cases it would take longer than 10 seconds. I am fairly certain there is a way to move the range of looping from n,..2,000,000,000 down as the likely hood of needing to loop that far when n is a low number is small, but either way we broke the loop when a number is prime under both conditions is found. At first we were looping from 2,..n no matter how large it was then i remembered the rule about only looping to the square root of n. Any suggestions on how to make my program more efficient? I have had no classes dealing with complexity analysis of algorithms. Here is our attempt. public class P3 { public static void main(String[] args){ long loop = 2000000000; long n = Integer.parseInt(args[0]); for(long i = n; i&lt;loop; i++) { String s = i +""; String r = ""; for(int j = s.length()-1; j&gt;=0; j--) r = r + s.charAt(j); if(prime(i) &amp;&amp; prime(Long.parseLong(r))) { System.out.println(i); break; } } System.out.println("#"); } public static boolean prime(long p){ for(int i = 2; i&lt;(int)Math.sqrt(p); i++) { if(p%i==0) return false; } return true; } } ps sorry if i did the formatting for code wrong this is my first time posting here. Also the output had to have a '#' after each line thats what the line after the loop is about Thanks for any help you guys offer!!!
tagged with: primes
has answer: http://stackoverflow.com/a/2777531

content-management-system
tags question: http://stackoverflow.com/q/2710246
type: Tag
tag name: content-management-system
tags question: http://stackoverflow.com/q/2654653

http://stackoverflow.com/a/2733626
score: 3
has comment: http://stackoverflow.com/comment/2761618
type: AcceptedAnswer
downvote count: 0
has body: I SD really there? Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) == true If targeting 1.6+, have you declared &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt; ? The exact Exception could help.
upvote count: 3
answers question: http://stackoverflow.com/q/2733576
type: Answer
accepted answer of: http://stackoverflow.com/q/2733576

http://stackoverflow.com/comment/106927300
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2671938
has text: @Andy Fair enough!
type: AnswerComment

hour
tags question: http://stackoverflow.com/q/2702971
type: Tag
tag name: hour

http://stackoverflow.com/comment/102536604
score: 0
type: Comment
comment on: http://stackoverflow.com/a/52325174
has text: also, java is NOT faster (not even comparable with) c++. period. the quality of stack based code (vs registered) is inferior. no matter what you and other blue collar java developers think (git, etc). java (and any other vm related language) is slower because of unacceptable garbage collection, which is: 1. completely unnecessary, see RAII, being unable to deal with type unsafe circular references && 2. slow and nondeterministic.
type: AnswerComment

http://stackoverflow.com/comment/2611319
comment on: http://stackoverflow.com/q/2601978
has text: May I suggest that you `System.out.println(myString)` immediately before the if-block so you can see what's there?
type: Comment
type: QuestionComment
score: 1

http://stackoverflow.com/q/2671768
has comment: http://stackoverflow.com/comment/2690405
possible better answer: http://stackoverflow.com/a/2671804
type: AnsweredQuestion
has body: I'm trying to call Jython from a Java 6 application using javax.script: import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; public class jythonEx { public static void main (String args[]) throws ScriptException { ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine pyEngine = mgr.getEngineByName("python"); try { pyEngine.eval("print \"Python - Hello, world!\""); } catch (Exception ex) { ex.printStackTrace(); } } } This is causing a NullPointerException: java.lang.NullPointerException at jythonEx.main(jythonEx.java:12) Does anyone have any idea what I'm doing wrong here? Edit: Thanks for the responses! I added jython.jar to the classpath and it runs properly: java -cp "./;jython.jar" jythonEx
tagged with: java
score: 10
accepted answer: http://stackoverflow.com/a/2671799
type: Question
answer count: 2
tagged with: jython
has title: Calling Python from Java through scripting engine (jython)?
favorite count: 0
has answer: http://stackoverflow.com/a/2671799
has answer: http://stackoverflow.com/a/2671804
upvote count: 10
tagged with: python
tagged with: javax.script
has comment: http://stackoverflow.com/comment/2690385
downvote count: 0
has comment: http://stackoverflow.com/comment/2690399

http://stackoverflow.com/comment/2697456
comment on: http://stackoverflow.com/a/2676321
has text: I think the OP meant in the Java language.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/2640231
has body: I just realized that the method Element.getElementsByTagName("someTagName") returns a nodelist of all elements in the document that have a given tagname. What if I just want to get all child elements by tag name? For example... Bob Toyota Corolla
score: 28
answer count: 5
accepted answer: http://stackoverflow.com/a/2640301
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/37033230
tagged with: dom
has title: W3C DOM API in Java, get child elements by name
type: Question
tagged with: w3c
downvote count: 0
has answer: http://stackoverflow.com/a/2956060
favorite count: 0
possible better answer: http://stackoverflow.com/a/12910872
has answer: http://stackoverflow.com/a/2640265
has answer: http://stackoverflow.com/a/2640301
has answer: http://stackoverflow.com/a/12910872
upvote count: 28

http://stackoverflow.com/a/58750103
answers question: http://stackoverflow.com/q/2751733
type: Answer
has body: My own solution to solve this kind of Enum JPA mapping is the following. Step 1 - Write the following interface that we will use for all enums that we want to map to a db column: public interface IDbValue&lt;T extends java.io.Serializable&gt; { T getDbVal(); } Step 2 - Implement a custom generic JPA converter as follows: import javax.persistence.AttributeConverter; public abstract class EnumDbValueConverter&lt;T extends java.io.Serializable, E extends Enum&lt;E&gt; &amp; IDbValue&lt;T&gt;&gt; implements AttributeConverter&lt;E, T&gt; { private final Class&lt;E&gt; clazz; public EnumDbValueConverter(Class&lt;E&gt; clazz){ this.clazz = clazz; } @Override public T convertToDatabaseColumn(E attribute) { if (attribute == null) { return null; } return attribute.getDbVal(); } @Override public E convertToEntityAttribute(T dbData) { if (dbData == null) { return null; } for (E e : clazz.getEnumConstants()) { if (dbData.equals(e.getDbVal())) { return e; } } // handle error as you prefer, for example, using slf4j: // log.error("Unable to convert {} to enum {}.", dbData, clazz.getCanonicalName()); return null; } } This class will convert the enum value E to a database field of type T (e.g. String) by using the getDbVal() on enum E, and vice versa. Step 3 - Let the original enum implement the interface we defined in step 1: public enum Right implements IDbValue&lt;Integer&gt; { READ(100), WRITE(200), EDITOR (300); private final Integer dbVal; private Right(Integer dbVal) { this.dbVal = dbVal; } @Override public Integer getDbVal() { return dbVal; } } Step 4 - Extend the converter of step 2 for the Right enum of step 3: public class RightConverter extends EnumDbValueConverter&lt;Integer, Right&gt; { public RightConverter() { super(Right.class); } } Step 5 - The final step is to annotate the field in the entity as follows: @Column(name = "RIGHT") @Convert(converter = RightConverter.class) private Right right; Conclusion IMHO this is the cleanest and most elegant solution if you have…
score: 6
upvote count: 6
downvote count: 0

http://stackoverflow.com/q/2775514
favorite count: 0
upvote count: 8
has body: JAXB treets empty int XML attribute as 0, which is fine with me, but I've got requirement to store it as a null. Seems I can't change DataConverterImpl class to custom implementation. What could be done if at all? &lt;xs:attribute name="Count" type="Integer0to999" use="optional"&gt; &lt;xs:simpleType name="Integer0to999"&gt; &lt;xs:annotation&gt; &lt;xs:documentation xml:lang="en"&gt;Used for Integer values, from 0 to 999 inclusive&lt;/xs:documentation&gt; &lt;/xs:annotation&gt; &lt;xs:restriction base="xs:integer"&gt; &lt;xs:minInclusive value="0"/&gt; &lt;xs:maxInclusive value="999"/&gt; &lt;/xs:restriction&gt; &lt;/xs:simpleType&gt; After xjc schema compilation I got class with the following: @XmlAttribute(name = "Count") protected Integer passengerCount; During XML parse parseInt() get called from DataConverterImpl.class from Sun(Oracle) which code is below, your neve going to get null from this code : public static int _parseInt(CharSequence s) { int len = s.length(); int sign = 1; int r = 0; for( int i=0; i&lt;len; i++ ) { char ch = s.charAt(i); if(WhiteSpaceProcessor.isWhiteSpace(ch)) { // skip whitespace } else if('0'&lt;=ch &amp;&amp; ch&lt;='9') { r = r*10 + (ch-'0'); } else if(ch=='-') { sign = -1; } else if(ch=='+') { ; // noop } else throw new NumberFormatException("Not a number: "+s); } return r*sign; }
type: UnansweredQuestion
has title: JAXB treets empty int XML attribute as 0
tagged with: jaxb
has answer: http://stackoverflow.com/a/4713065
score: 8
tagged with: java
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/3630209
downvote count: 0

http://stackoverflow.com/comment/2820304
has text: edited the methods signatures, i can post the rest if you want
score: 0
comment on: http://stackoverflow.com/q/2784816
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2611481
tagged with: java
score: 0
upvote count: 1
downvote count: 1
type: Question
has body: I have an html-like xml, basically it is html. I need to get the elements in each . Each element looks like this: 1414 31 title1 author1 date1 My code is as below, it does recognize that there are 50 in the file, but it gives me NULLPointException when parsing NodeList fstNmElmntLst = fstElmnt.getElementsByTagName("attr"); Any idea why this is happening? The same code has been used for other applications without problems. DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(cleanxml)); Document doc = db.parse(is); doc.getDocumentElement().normalize(); System.out.println("Root element " + doc.getDocumentElement().getNodeName()); NodeList nodeLst = doc.getElementsByTagName("line"); for (int s = 0; s < nodeLst.getLength(); s++) { System.out.println(nodeLst.getLength()); Node fstNode = nodeLst.item(s); if (fstNode.getNodeType() == Node.ELEMENT_NODE) { Element fstElmnt = (Element) fstNode; NodeList fstNmElmntLst = fstElmnt.getElementsByTagName("attr"); Element fstNmElmnt = (Element) fstNmElmntLst.item(0); NodeList fstNm = fstNmElmnt.getChildNodes(); System.out.println("attr : " + ((Node) fstNm.item(0)).getNodeValue()); } }
accepted answer: http://stackoverflow.com/a/2611512
answer count: 1
favorite count: 0
tagged with: http://stackoverflow.com/tag/html
tagged with: http://stackoverflow.com/tag/xml
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2611512
has title: java: how to parse html-like xml

http://stackoverflow.com/q/2713216
has comment: http://stackoverflow.com/comment/2739920
has title: Parsing plain text to some structured object
has comment: http://stackoverflow.com/comment/2739915
has comment: http://stackoverflow.com/comment/2745267
answer count: 2
has answer: http://stackoverflow.com/a/2734057
possible better answer: http://stackoverflow.com/a/2713385
accepted answer: http://stackoverflow.com/a/2734057
has comment: http://stackoverflow.com/comment/2738091
favorite count: 0
tagged with: parsing
upvote count: 5
tagged with: key-value
has comment: http://stackoverflow.com/comment/2740799
has comment: http://stackoverflow.com/comment/2747214
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2738113
downvote count: 0
has answer: http://stackoverflow.com/a/2713385
tagged with: java
has body: I am working on parsing plain text and converting it to key-value pairs. For example, plain text: some_uninteresting_thing key1 valueA, some_uninteresting_thing valueB key2 valueD key3 some_uninteresting_thing valueE key4 valueG(valueH, valueI) key5 some_uninteresting_thing And possible mappings: Map( key1 -&gt;(valueA, valueB,valueC), key2 -&gt;(valueD, valueE), key3 -&gt;(valueF) key4 -&gt;(valueH, valueI) ... ) Amd result will be : key1 -&gt;(valueA, valueB) key2 -&gt;(valueD) key4 -&gt;(valueH, valueI) (key5 shouldn't be mapped because has no appropriate values. As you can see plain text is lenient. What java library will help to handle this?
has comment: http://stackoverflow.com/comment/2739931
type: Question
score: 5
has comment: http://stackoverflow.com/comment/2738094

http://stackoverflow.com/comment/2752131
type: Comment
type: QuestionComment
has text: Do you mean to change the default Input Language or the default Regional Settings?
comment on: http://stackoverflow.com/q/2724710
score: 0

http://stackoverflow.com/comment/2816083
comment on: http://stackoverflow.com/q/2780255
has text: Use FindBugs, it will advice you on that and more bad practice
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2746578
possible better answer: http://stackoverflow.com/a/2746941
has answer: http://stackoverflow.com/a/13059764
has answer: http://stackoverflow.com/a/2746666
type: Question
has answer: http://stackoverflow.com/a/2746941
upvote count: 15
answer count: 8
downvote count: 0
score: 15
has answer: http://stackoverflow.com/a/2746845
has comment: http://stackoverflow.com/comment/9137399
accepted answer: http://stackoverflow.com/a/2746666
has title: Advantage of log4j
has answer: http://stackoverflow.com/a/46364823
tagged with: log4j
favorite count: 0
has answer: http://stackoverflow.com/a/2746606
tagged with: logging
has answer: http://stackoverflow.com/a/2746614
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/2746778
has body: What's the advantage of log4j over set System.out and System.err to output to a log file?

http://stackoverflow.com/comment/2605883
has text: And I'd need to see `Node.getSeq()` and related methods. Are you using this to check equality? Why not just use ==?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2597301
score: 0

http://stackoverflow.com/comment/2696583
has text: You should clarify exactly what you mean. Start with why you want the information.
score: 0
comment on: http://stackoverflow.com/q/2677419
type: Comment
type: QuestionComment

http://stackoverflow.com/a/2676201
has comment: http://stackoverflow.com/comment/2700193
downvote count: 0
has comment: http://stackoverflow.com/comment/2696152
score: 6
has body: If it is always going to be a subtype of Sim then why not just specify that in your method and be done with it? It doesn't seem like generics is buying you very much here. But anyway, I think you want loadScenario to be: public void loadScenario(Scenario&lt;? extends Sim&gt; scenario) EDIT: Okay now I actually thought about it, that won't work either. Your loadScenario is going to get passed a Scenario with a type parameter T that is a subtype of Sim. But you are trying to pass it a Sim which has no guarantees of being the right subtype of Sim. The solution is that the Scenario.load method needs to take a Sim viz: public interface Scenario&lt;T extends Sim&gt; { public void load(Sim sim); } and Sim stays the way you wrote it. Note your MySim class must implement this and explictily narrowcast it to it's type parameter. EDIT: Another approach is to use a static method in your Sim base class: public class Sim { public static &lt;T extends Sim&gt; void loadScenario(Scenario&lt;T&gt; scenario, T sim) { scenario.load(sim); } } It is not however possible to make this an instance method since passing an instance of Sim to something of type T extends Sim is not typesafe. By making a static method that also passes the Sim you give the compiler the opportunity to check that the T for Scenario type parameter and the T for sim match.
type: Answer
has comment: http://stackoverflow.com/comment/2695634
upvote count: 6
has comment: http://stackoverflow.com/comment/2697975
has comment: http://stackoverflow.com/comment/2699847
answers question: http://stackoverflow.com/q/2676153

http://stackoverflow.com/comment/2822155
type: Comment
has text: I've set "Project Properties > Build > Compile > Compile On Save: For both application and test execution" but cannot see changes in the browser after saving when using GlassFish.
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/2784477

http://stackoverflow.com/q/2775921
type: Question
upvote count: 4
accepted answer: http://stackoverflow.com/a/4440954
has answer: http://stackoverflow.com/a/2776879
tagged with: mongodb
answer count: 2
downvote count: 0
score: 4
has body: Is it possible to execute raw commands as javascript through the Java driver for MongoDB? I'm tired of wrapping everything in Java objects using Rhino, and would happily sacrifice performance for the convenience of passing javascript directly through to the DB. If not, I can always use sleepymongoose or something, but I don't really want to add yet another language (python) to the stack at this point. Any insights are appreciated.
has title: mongodb java driver - raw command?
favorite count: 0
has answer: http://stackoverflow.com/a/4440954
type: AnsweredQuestion
tagged with: java
possible better answer: http://stackoverflow.com/a/2776879

http://stackoverflow.com/a/2729064
has comment: http://stackoverflow.com/comment/7452617
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2723564
score: 3
has comment: http://stackoverflow.com/comment/2801264
upvote count: 3
has body: You may want to have a look at JRebel. It reloads your classes in a running tomcat, so your changes are near instantaneous. I haven't used it much, but it appears to solicit good comments.

jakarta-mail
tags question: http://stackoverflow.com/q/2681577
tags question: http://stackoverflow.com/q/2724441
tag name: jakarta-mail
tags question: http://stackoverflow.com/q/2773108
tags question: http://stackoverflow.com/q/2617181
tags question: http://stackoverflow.com/q/2690441
tags question: http://stackoverflow.com/q/2732640
type: Tag
tags question: http://stackoverflow.com/q/2686889
tags question: http://stackoverflow.com/q/2704103
tags question: http://stackoverflow.com/q/2618595
tags question: http://stackoverflow.com/q/2739596
tags question: http://stackoverflow.com/q/2764504
tags question: http://stackoverflow.com/q/2681481
tags question: http://stackoverflow.com/q/2723809

hql
tag name: hql
tags question: http://stackoverflow.com/q/2627180
tags question: http://stackoverflow.com/q/2746756
tags question: http://stackoverflow.com/q/2700680
tags question: http://stackoverflow.com/q/2731234
tags question: http://stackoverflow.com/q/2677497
tags question: http://stackoverflow.com/q/2783774
tags question: http://stackoverflow.com/q/2738880
tags question: http://stackoverflow.com/q/2751941
type: Tag
tags question: http://stackoverflow.com/q/2691815
tags question: http://stackoverflow.com/q/2643470

http://stackoverflow.com/comment/2784890
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2753914
has text: i didnt get what you stated sorry,,
type: AnswerComment

http://stackoverflow.com/a/9190596
has comment: http://stackoverflow.com/comment/46106695
upvote count: 0
has comment: http://stackoverflow.com/comment/15966628
type: Answer
has body: You can find the standard Java Tutorial Example here: Click Here to Open the example java file The example has only one text box, but the example is clear enough for you to extend it.
downvote count: 1
score: -1
answers question: http://stackoverflow.com/q/2729642

http://stackoverflow.com/a/2617389
answers question: http://stackoverflow.com/q/2617369
score: 6
type: Answer
downvote count: 0
upvote count: 6
has body: Overriding equals and hashCode methods is enough to make method removeAll work on custom objects. It's likely that you didn't override them in a proper way. Some code will help us a lot.
has comment: http://stackoverflow.com/comment/95996610

http://stackoverflow.com/comment/42927405
type: QuestionComment
has text: @PaulTaylor The job where I implemented this solution has been superceded. :-)
comment on: http://stackoverflow.com/q/2758612
score: 0
type: Comment

http://stackoverflow.com/a/2655696
upvote count: 2
type: Answer
score: 2
has body: A better solution is to request a .jar file download that you can run with java -jar program.jar because the files that are stored after the launch of the .jnlp isn't really "readable", you will find that resources and classes names are somewhat obfuscated.
answers question: http://stackoverflow.com/q/2655677
downvote count: 0
has comment: http://stackoverflow.com/comment/2672985

http://stackoverflow.com/a/2686278
has body: definitely nail down java syntax, so as little as possible confuses you in android development. android has some interesting objects to say the least--and their names don't hold traditional data structure names that you would be used to seeing. so, again, master the syntax, write some apps, then think about diving into android.
upvote count: 3
type: Answer
has comment: http://stackoverflow.com/comment/2706727
answers question: http://stackoverflow.com/q/2686264
has comment: http://stackoverflow.com/comment/2707497
score: 3
downvote count: 0

http://stackoverflow.com/comment/2653732
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2639372
has text: The second question is not related to the use of GridBagLayout, but how to scale the image in a JLabel.

http://stackoverflow.com/comment/2815198
type: AnswerComment
type: Comment
has text: the description of getRuntime() is : Returns: the Runtime object associated with the current Java application. Making me think there is only 1.
comment on: http://stackoverflow.com/a/2780003
score: 0

http://stackoverflow.com/comment/2724840
type: Comment
has text: It happens to everyone who uses the site :[. On Windows machines, I've looked thru the Java Control Panel and only 'caching' settings I can find are under Temporary Internet Files->Settings. Those settings all looked good though. I've also looked under Temporary Internet Files->View to verify that the .jar file in question is not present in the cache :[
score: 0
comment on: http://stackoverflow.com/a/2694200
type: AnswerComment

http://stackoverflow.com/comment/28596690
type: Comment
score: 8
type: AnswerComment
comment on: http://stackoverflow.com/a/4591900
has text: Note that `fill_parent` should be replaced with `match_parent` for API level 8 and higher.

http://stackoverflow.com/q/2755012
has comment: http://stackoverflow.com/comment/2786501
has answer: http://stackoverflow.com/a/2755032
linked to: http://stackoverflow.com/q/2753876
has answer: http://stackoverflow.com/a/2755021
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2755021
tagged with: java
accepted answer: http://stackoverflow.com/a/4481564
has comment: http://stackoverflow.com/comment/2786159
type: Question
answer count: 6
has title: Write a program that allows the user to enter a string and then prints the letters of the String separated by comma
has answer: http://stackoverflow.com/a/2755029
has comment: http://stackoverflow.com/comment/2786136
score: 0
has body: The output is always a String, for example H,E,L,L,O,. How could I limit the commas? I want the commas only between letters, for example H,E,L,L,O. import java.util.Scanner; import java.lang.String; public class forLoop { public static void main(String[] args) { Scanner Scan = new Scanner(System.in); System.out.print("Enter a string: "); String Str1 = Scan.next(); String newString=""; String Str2 =""; for (int i=0; i &lt; Str1.length(); i++) { newString = Str1.charAt(i) + ","; Str2 = Str2 + newString; } System.out.print(Str2); } }
has answer: http://stackoverflow.com/a/4481564
has answer: http://stackoverflow.com/a/2755623
has answer: http://stackoverflow.com/a/2755044
has comment: http://stackoverflow.com/comment/2786323

http://stackoverflow.com/comment/2789554
score: 6
type: Comment
comment on: http://stackoverflow.com/a/2757576
type: AnswerComment
has text: And if you will be having more connections allowed adjust memory parameters as well to align with increased connections.

http://stackoverflow.com/a/2873296
has body: What the others have said is correct. Java's "old I/O" library in java.io contains blocking calls. But they do not busy wait. They are blocking on I/O and the kernel will reschedule them once more I/O is available. I wasn't totally sure, so I tried it out for myself. Take this sample class: import java.io.*; public class Test { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String line = reader.readLine(); System.out.println(line); } } And compile it on the command line. Then run it, but don't type anything. The program should be blocking on input until you type a character, and it will not progress past readline until you type enter. ps should be able to tell us more details about this process. Use the a flag to get more detailed information from ps: japeters@&lt;computer-name&gt;] ps a PID TT STAT TIME COMMAND 3846 s000 S 0:00.16 -zsh 3992 s000 S+ 0:00.40 /usr/bin/java Test The man page for PS says: state The state is given by a sequence of characters, for example, ``RWNA''. The first character indicates the run state of the process: I Marks a process that is idle (sleeping for longer than about 20 seconds). R Marks a runnable process. S Marks a process that is sleeping for less than about 20 seconds. And since I just started the process, S makes sense. The process is sleeping, awaiting scheduling by the OS. Indeed, if you check top, you'll notice the process is taking 0% CPU. So don't worry about the performance of this call, there's no busy waiting or polling going on: the system is taking care of the I/O events for you and will intelligently handle your process.
score: 21
upvote count: 21
downvote count: 0
answers question: http://stackoverflow.com/q/2776724
type: Answer

http://stackoverflow.com/a/2635325
answers question: http://stackoverflow.com/q/2635292
upvote count: 7
type: Answer
has body: n = null; won't help you, since n is just a local variable of your function. Instead, you'd need to set n.left = null; or n.right = null; on the parent. I won't give you a complete solution, since this smells a lot like homework, but you could, for example, add a return value to your function to indicate whether the node in question is a leaf or not and take appropriate actions in the parent (after the call to removeLeaves).
downvote count: 0
score: 7

http://stackoverflow.com/a/39976420
has body: I've had this problem today and for me the reason was pure stupidity – if the unit test outputs something to the console at first and throws an exception afterwards, both before reaching the breakpoint, you do not see the exception in eclipse's debug perspective because it gets printed in the JUnit view, but the output before switched away from that view to the Console output.
score: 0
answers question: http://stackoverflow.com/q/2744351
type: Answer

http://stackoverflow.com/comment/64316720
type: Comment
has text: Does the auto-generated annotation on the ID field mean that I don't need to set the ID when creating a new object? I just set all the other not-null fields and call the em.persist() function and that's is? I know it's a dumb question I'm just a beginner in Java development in general. :)
comment on: http://stackoverflow.com/a/2702782
score: 0
type: AnswerComment

http://stackoverflow.com/comment/2740787
has text: Then you can't use App Engine - just because it comes in on port 80 doesn't mean it will reach your app!
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/2713432
type: Comment

http://stackoverflow.com/q/2734318
has answer: http://stackoverflow.com/a/2734451
has comment: http://stackoverflow.com/comment/2762410
has title: How to define function in a string in Android?
answer count: 2
upvote count: 1
tagged with: string
favorite count: 0
has answer: http://stackoverflow.com/a/2734565
type: UnansweredQuestion
tagged with: android
tagged with: http://stackoverflow.com/tag/xml
downvote count: 0
score: 1
tagged with: java
type: Question
has body: I have an event handler that I want to be connected to a button through xml. Basically, I want to define it as a string in my xml file, then use the property inspector to select the name of the handler for my button (the "on Click" property). How do I define a call to the function in the string?

http://stackoverflow.com/comment/2812331
type: QuestionComment
type: Comment
score: 0
has text: Sorry. I'm not talking about performance problems here. Our problems are in performance monitoring. We want to have a complete solution which would tell us if all our sites are preforming well.
comment on: http://stackoverflow.com/q/2760289

http://stackoverflow.com/comment/2779981
has text: Another duplicate: http://stackoverflow.com/questions/155672/starting-graphics-games-programming-java-and-maybe-c
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2749889
score: 0

http://stackoverflow.com/a/2626193
has body: readObject() doesn't return null at EOF. You could catch the EOFException and interpret it as EOF, but this would fail to distinguish a normal EOF from a file that has been truncated. A better approach would be to use some meta-data. That is, rather than asking the ObjectInput how many objects are in the stream, you should store the count somewhere. For example, you could create a meta-data class that records the count and other meta-data and store an instance as the first object in each file. Or you could create a special EOF marker class and store an instance as the last object in each file.
has comment: http://stackoverflow.com/comment/2641739
has comment: http://stackoverflow.com/comment/2639292
has comment: http://stackoverflow.com/comment/2640762
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2642523
score: 32
has comment: http://stackoverflow.com/comment/2639467
type: Answer
upvote count: 32
accepted answer of: http://stackoverflow.com/q/2626163
answers question: http://stackoverflow.com/q/2626163

http://stackoverflow.com/a/2725834
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2725795
answers question: http://stackoverflow.com/q/2725795
upvote count: 1
has comment: http://stackoverflow.com/comment/2752836
has body: You would probably be better off attempting to eliminate the launcher use a standard JVM. See if you can figure out what parameters Java is being launched with--it might help to dump the launcher and any associated configuration files. Then you just call java yourself. This may not work at all depending on what else the launcher is doing. edit: try: java -Djava.system.class.loader=com.company.loader.NativeClassLoader -Xmx160m -Xms160m -Xincgc from the command line against a real JVM. There is a good chance it will fail because of the NativeClassLoader or other stuff set up by the java loader. Also you may be missing the actual java class it is trying to start (I don't know if that "NativeClassLoader" needs the actual main class or not). Without knowing more about the C class loader, I don't know if anyone can help you much. Perhaps you could contact the vendor? You might dump the .exe file and see if there is any identifying text--if you could figure out where it came from, you might be able to find docs on it telling you how to forward parameters to the JVM
has comment: http://stackoverflow.com/comment/2752711
type: Answer
downvote count: 0
score: 1

http://stackoverflow.com/comment/64133654
has text: Sorry I did not see that you had binding in your answer as well I feel that your answer is also very elegant.
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/37774966
type: Comment

http://stackoverflow.com/a/2633401
score: 3
has body: add an enabled flag to the listeners and disable them before manually setting the value I wouldn't add and remove listeners as that just triggers more listeners!
upvote count: 3
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2633323
has comment: http://stackoverflow.com/comment/2653170
type: Answer
answers question: http://stackoverflow.com/q/2633323

http://stackoverflow.com/a/2749911
answers question: http://stackoverflow.com/q/2749889
downvote count: 0
upvote count: 8
has body: C++ is horrible for beginners. It's a sprawling mixed metaphor of a language. You would certainly find it easier to approach once comfortable with object-orientation through more disciplined environments like C# or Java. Scripting languages like Python are a much better place to start. Bash up some stuff in Pygame or whatever to get some practice. Modern games typically use a scripting language for controlling the high-level game logic anyway. If you're a beginner, it's going to be a long slog before you'll be capable of writing full game engines in C++. Take your time!
type: Answer
score: 8

http://stackoverflow.com/a/2727926
type: Answer
answers question: http://stackoverflow.com/q/2727860
has body: To follow on from the others any decent XML reference will get you started, try here: w3schools
score: 0

http://stackoverflow.com/comment/2763982
has text: But the value formatted will be inserted in database under this format dd/MM/yyyy 00:00:00 so it will not be accepted like a valis value.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2735673

http://stackoverflow.com/q/2704882
linked to: http://stackoverflow.com/q/2699029
tagged with: sorting
has answer: http://stackoverflow.com/a/2704890
score: 0
answer count: 4
has comment: http://stackoverflow.com/comment/2728423
has answer: http://stackoverflow.com/a/2707526
has title: More than one unique key for HashMap problem (Java)
has body: This question is a continuation of this thread: In short: To solve my problem, I want to use Map&lt;Set&lt;String&gt;, String&gt;. However, after I sort my data entries in Excel, remove the unnecessary parameters, and the following came out: flow content ==&gt; content content flow content ==&gt; content depth distance flow content ==&gt; content depth within flow content ==&gt; content depth within distance flow content ==&gt; content within flow content ==&gt; content within distance I have more than one unique key for the hashmap if that is the case. How do I go around this... anyone have any idea? I was thinking of maybe Map&lt;Set &lt;String&gt;, List &lt;String&gt;&gt; so that I can do something like: Set &lt;flow content&gt;, List &lt;'content content','content depth distance','content depth within ', ..., 'content within distance'&gt; But because I am parsing the entries line by line I can't figure out the way how to store values of the same repeated keys (flow content) into the same list and add it to the map. Anyone have a rough logic on how can this be done in Java? Thanks in advance. --EDIT: Trying Multimap but somehow have slight problem: public static void main(String[] args) { File file = new File("apriori.txt"); Multimap&lt;Set &lt;String&gt;, String&gt; mm = HashMultimap.create(); Set&lt;String&gt; s = null; List l = null; BufferedReader br = null; try { br = new BufferedReader(new FileReader(file)); String line = ""; while ((line = br.readLine()) != null) { //Regex delete only tokenize String[] string = line.split(";"); System.out.println(string[0] + " " + string[1]); StringTokenizer st = new StringTokenizer(string[0].trim()); while (st.hasMoreTokens()) { //System.out.println(st.nextToken()); s = new HashSet&lt;String&gt;(); s.add(st.nextToken()); } mm.put(s,string[1]); } // dispose all the resources after using them. br.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } Set&lt;String&…
accepted answer: http://stackoverflow.com/a/2704890
possible better answer: http://stackoverflow.com/a/2704900
has answer: http://stackoverflow.com/a/2704900
type: Question
has answer: http://stackoverflow.com/a/2706091
type: AnsweredQuestion
tagged with: hashmap
tagged with: java

http://stackoverflow.com/comment/2838557
type: Comment
has text: @yesraaj - yes and no :-) `ChildSingleton.getInstance()` will return an instance of `ChildSingleton`, because the instance is created with `new ChildSingleton()`. But it's also correct to say that this method returns an instance of `ParentSingleton`, since `ChildSingleton` extends that class, i.e. `ChildSingleton` is a `ParentSingleton`.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2773033

http://stackoverflow.com/a/2765109
has body: I could see a case for a stateless singleton being used instead of a static methods class, namely for Dependency Injection. If you have a helper class of utility functions that you're using directly, it creates a hidden dependency; you have no control over who can use it, or where. Injecting that same helper class via a stateless singleton instance lets you control where and how it's being used, and replace it / mock it / etc. when you need to. Making it a singleton instance simply ensures that you're not allocating any more objects of the type than necessary (since you only ever need one).
answers question: http://stackoverflow.com/q/2765060
downvote count: 0
has comment: http://stackoverflow.com/comment/69281565
score: 43
has comment: http://stackoverflow.com/comment/50893831
type: Answer
upvote count: 43

http://stackoverflow.com/a/2661522
upvote count: 3
answers question: http://stackoverflow.com/q/2660961
score: 3
downvote count: 0
has body: Problems with deleting things for me under Windows usually come down to one of two things: The file being open by a program. This includes the JVM. This usually doesn't go away by itself. The Antivirus-program on the computer has the file open for whatever it needs to do. This usually goes away after a while. I frequently recreate workspaces, and if this happens too fast, Eclipse complains that it cannot delete files.
type: Answer

http://stackoverflow.com/a/2623202
downvote count: 0
has comment: http://stackoverflow.com/comment/78842749
has comment: http://stackoverflow.com/comment/2635725
has comment: http://stackoverflow.com/comment/2635786
type: Answer
has comment: http://stackoverflow.com/comment/2635715
score: 7
has comment: http://stackoverflow.com/comment/2639523
has comment: http://stackoverflow.com/comment/2637081
answers question: http://stackoverflow.com/q/2623091
has body: Google Gson can do this particular task in a single line: String json = new Gson().toJson(animal); The other way round is by the way also as easy: Animal animal = new Gson().fromJson(json, Animal.class); I haven't seen another JSON serializer yet with better support for generics, collections/maps and (nested) javabeans. Update: To the point, you just need to learn about reflection API. I recommend to get yourself through the Sun tutorial on the subject first. In a nutshell, you can use Object#getClass() and all the methods provided by java.lang.Class, java.lang.reflect.Method, etc to determine the one and other. Google Gson is open source, take your benefit of it as well.
upvote count: 7

http://stackoverflow.com/comment/2613555
type: Comment
has text: Yep, I was going to say something about permissions.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2603885

http://stackoverflow.com/comment/2678627
has text: Also note that anachronism is not friendly for search engines and for people that uses non-is browsers. So I don't think it will be fully Ajax based.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2661329
score: 0

http://stackoverflow.com/comment/12615777
has text: I would not that even with JUnit 4.8.2 that on Windows 7 the TemporaryFolder rule doesn't work correctly. Looks like it's a permissions issue.
type: Comment
score: 2
comment on: http://stackoverflow.com/a/2773558
type: AnswerComment

http://stackoverflow.com/a/2607303
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/2622909
answers question: http://stackoverflow.com/q/2606214
has comment: http://stackoverflow.com/comment/2622629
has body: Is there a simpler regex-based solution? It took me a while, but eventually I managed to simplify the regex to: "(?=.{0,N}$(?&lt;=(.{N}))).|." // repeatEnd -or- ".(?&lt;=^(?=(.{N})).{0,N})|." // repeatBegin Like Alan Moore's answer, this removes the negative assertion, but doesn't even replace it with a positive one, so it now only has 2 assertions instead of 3. I also like the fact that the "else" case is just a simple .. I prefer to put the bulk of my regex into the "working" side of the alternation, and keep the "non-working" side as simple as possible (usually a simple . or .*).
has comment: http://stackoverflow.com/comment/2624162

http://stackoverflow.com/a/2623631
has comment: http://stackoverflow.com/comment/2636289
type: Answer
answers question: http://stackoverflow.com/q/2623610
score: 13
downvote count: 1
upvote count: 14
has body: Calendar.DAY_OF_YEAR is the proper way to subtract days You can also subtract a year (taking in to account leap years) by using Calendar calendar = Calendar.getInstance(); calendar.setTime(givenDate); calendar.add(Calendar.YEAR, -1);

http://stackoverflow.com/comment/12072934
type: Comment
has text: @David that's because those are not really informative log files but files crucial to Atomikos functionality. The logging that is being spoken of here is informative logging which can be switched off by using log4j.logger.atomikos=ERROR
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2716614

http://stackoverflow.com/comment/2801439
type: AnswerComment
has text: I'm confused, i actually looked at your numbers and rotating the points (7,1), (7,2), (7,3), (7,4) 90 degrees around the origin should result in (7,-1), (7,-2), (7,-3), (7,-4). Which is what you got. You example is the correct rotation of these points.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2768001

http://stackoverflow.com/a/2639296
has body: Check run config of the JUnit test. In the classpath tab, resotre default entries once in case that is not the case already. In project properties check if both junit package and classes source folder is in the source package and there is an actual class compilation existring for the class under test in your expected target folder.
answers question: http://stackoverflow.com/q/2639018
score: 0
type: Answer

http://stackoverflow.com/q/2694526
tagged with: java
answer count: 3
tagged with: treemap
tagged with: comparable
has body: I have the following object Node: private class Node implements Comparable&lt;Node&gt;(){ private String guid(); ... public boolean equals(Node o){ return (this == o); } public int hashCode(){ return guid.hashCode(); } public int compareTo(Node o){ return (this.hashCode() - o.hashCode()); } ... } And I use it in the following TreeMap: TreeMap&lt;Node, TreeSet&lt;Edge&gt;&gt; nodes = new TreeMap&lt;Node, TreeSet&lt;Edge&gt;&gt;(); Now, the tree map is used in a class called Graph to store nodes currently in the graph, along with a set of their edges (from the class Edge). My problem is when I try to execute: public containsNode(n){ for (Node x : nodes.keySet()) { System.out.println("HASH CODE: "); System.out.print(x.hashCode() == n.hashCode()); System.out.println("EQUALS: "); System.out.print(x.equals(n)); System.out.println("CONTAINS: "); System.out.print(nodes.containsKey(n)); System.out.println("N: " + n); System.out.println("X: " + x); System.out.println("COMPARES: "); System.out.println(n.compareTo(x)); } } I sometimes get the following: HASHCODE: true EQUALS: true CONTAINS: false N: foo X: foo COMPARES: 0 Anyone have an idea as to what I'm doing wrong? I'm still new to all this, so I apologize in advance if I'm overlooking something simple (I know hashCode() doesn't really matter for TreeMap, but I figured I'd include it). edit1: added compareTo() method information.
linked to: http://stackoverflow.com/q/608704
has answer: http://stackoverflow.com/a/2694591
score: 2
type: AnsweredQuestion
downvote count: 0
possible better answer: http://stackoverflow.com/a/2694591
favorite count: 0
tagged with: equals
has title: Consistent Equals() results, but inconsistent TreeMap.containsKey() result
type: Question
upvote count: 2
has answer: http://stackoverflow.com/a/2694658
has comment: http://stackoverflow.com/comment/2716316
has answer: http://stackoverflow.com/a/2694584
tagged with: hashcode
accepted answer: http://stackoverflow.com/a/2694658

http://stackoverflow.com/comment/84878775
score: 1
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2675416
has text: If the server is listening on a random port like this, how does the client know which port to send to? I tried this, but realized that the Socket() constructor on the client side needs a specific port to send to.

http://stackoverflow.com/a/2713662
has comment: http://stackoverflow.com/comment/78247297
answers question: http://stackoverflow.com/q/2713655
has comment: http://stackoverflow.com/comment/2739071
has comment: http://stackoverflow.com/comment/2738703
upvote count: 26
has body: You split the string by the space then iterate over it backwards to assemble the reversed sentence. String[] words = "This is interview question".split(" "); String rev = ""; for(int i = words.length - 1; i &gt;= 0 ; i--) { rev += words[i] + " "; } // rev = "question interview is This " // can also use StringBuilder: StringBuilder revb = new StringBuilder(); for(int i = words.length - 1; i &gt;= 0 ; i--) { revb.append(words[i]); revb.append(" "); } // revb.toString() = "question interview is This "
type: Answer
has comment: http://stackoverflow.com/comment/2738697
has comment: http://stackoverflow.com/comment/2738857
score: 24
downvote count: 2
has comment: http://stackoverflow.com/comment/2738740

http://stackoverflow.com/comment/2662274
type: Comment
has text: Hmmm, how would you decide if characters are different? e.g. if two strings are different lengths would the characters of the longer string count as different characters or the same? Is the order of the characters important?
comment on: http://stackoverflow.com/q/2646918
score: 0
type: QuestionComment

http://stackoverflow.com/a/2791073
has comment: http://stackoverflow.com/comment/2827538
accepted answer of: http://stackoverflow.com/q/2773722
upvote count: 1
answers question: http://stackoverflow.com/q/2773722
has body: I can't reproduce the problem... below I used the xml text in your example, the output I got is : new text Below is the test code I used String s = " previoustext "; vg.setDoc(s.getBytes()); vg.parse(true); vn = vg.getNav(); AutoPilot testAP = new AutoPilot(vn); testAP.selectXPath("/pn[@category]"); xm.bind(vn); int j; while((j = testAP.evalXPath()) != -1) { int p = vn.getText(); xm.updateToken(p, "new text"); } XMLByteOutputStream xbos =new XMLByteOutputStream(xm.getUpdatedDocumentSize()); xm.output(xbos); System.out.println(new String(xbos.getXML())); Did you use the latest version of vtd-xml?
type: AcceptedAnswer
downvote count: 0
type: Answer
score: 1

http://stackoverflow.com/a/2692626
answers question: http://stackoverflow.com/q/2690802
accepted answer of: http://stackoverflow.com/q/2690802
type: AcceptedAnswer
downvote count: 0
score: 1
has body: If the package-build-deploy process is necessary, but heavyweight enough that you want to minimize or avoid it, you might also consider making that process easier, faster, or more automated.
type: Answer
upvote count: 1

http://stackoverflow.com/q/2685534
tagged with: socketchannel
has comment: http://stackoverflow.com/comment/2705862
has title: Java ServerSocketChannel SocketChannel (Callback)
downvote count: 0
type: Question
has answer: http://stackoverflow.com/a/2685842
type: AnsweredQuestion
favorite count: 0
score: 5
answer count: 1
accepted answer: http://stackoverflow.com/a/2685842
has body: I am trying to learn Java. I would like to implement a simple networked connect 4 game as well as a chat feature. I want my network logic to be non blocking so after much study I found that SocketChannel is what I am after regrading my needs. What has not made sense still is the lack of CallBack functions in SocketChannels.. Like one finds in C#. My query for this time is: How do I deliver the data received to the Chat or Game form (JFrame)? Some guidance is most welcome.
upvote count: 5
tagged with: java

http://stackoverflow.com/q/2774043
tagged with: java
has body: I'm developing a poker game. On the betting stage I create a scheduled job using Red5 iSchedulingService that will run every 8 seconds to forward to the next player to place a bet. Now if the user placed a bet before the 8 seconds are over, I want to manually force the next scheduled job to start. Is there a way to force the scheduled job to start immediately when required?
upvote count: 1
type: Question
accepted answer: http://stackoverflow.com/a/2812027
has comment: http://stackoverflow.com/comment/2807849
answer count: 2
tagged with: ischedulingservice
downvote count: 0
has answer: http://stackoverflow.com/a/2774301
favorite count: 0
tagged with: red5
possible better answer: http://stackoverflow.com/a/2774301
has answer: http://stackoverflow.com/a/2812027
type: AnsweredQuestion
has title: Java: addScheduledJobAfterDelay() - can I force a scheduled job to start?
score: 1

http://stackoverflow.com/a/2648420
answers question: http://stackoverflow.com/q/2648398
has comment: http://stackoverflow.com/comment/2664231
type: Answer
has body: Erm, ever thought about what would happen if you ran this code in a MaxHeap of, say, String objects? T does not exist until you actually instantiate the generic class. So, it does not make sense to create an array of T with integers if you don't know what T is. EDIT: Also, generics in Java only work with reference types, and int is a value type. Try using Integer (int's wrapper class) instead.
has comment: http://stackoverflow.com/comment/2664160
score: 0

http://stackoverflow.com/q/2635807
downvote count: 0
has body: The question is why it's been decided to have variable as final and static and methods as public and abstract by default. Is there any particular reason for making them implicit,variable as final and static and methods as public and abstract. Why they are not allowing static method but allowing static variable? We have interface to have feature of multiple inheritance in Java and to avoid diamond problem. But how it solves diamond problem,since it does not allow static methods. In the following program, both interfaces have method with the same name..but while implementing only one we implement...is this how diamond problem is solved? interface testInt { int m = 0; void testMethod(); } interface testInt1 { int m = 10; void testMethod(); } public class interfaceCheck implements testInt, testInt1{ public void testMethod() { System . out . println ( "m is"+ testInt.m ); System . out . println ( "Hi World!" ); } }
favorite count: 0
type: Question
has comment: http://stackoverflow.com/comment/125198465
has answer: http://stackoverflow.com/a/2635947
accepted answer: http://stackoverflow.com/a/2635959
score: 4
tagged with: java
answer count: 3
upvote count: 4
possible better answer: http://stackoverflow.com/a/2635972
has answer: http://stackoverflow.com/a/2635959
type: AnsweredQuestion
has title: interface variables are final and static by default and methods are public and abstract
has answer: http://stackoverflow.com/a/2635972

http://stackoverflow.com/q/2682879
type: Question
tagged with: jpa
linked to: http://stackoverflow.com/q/2581665
accepted answer: http://stackoverflow.com/a/2682973
tagged with: transient
answer count: 1
downvote count: 0
favorite count: 0
has body: I have a method annotated with @PrePersist annotation but I've seen that when this method is executed all my transient attributes (the attributes with the @Transient annotation) are null. When I debug the applicaion I can see that this transient attributes are not null just before calling the persist() method and when it enters my PrePersist method all transient attributes changes to null. It also happens with PostPersist methods and I need the transient information in this methods. Is this behaviour normal? Can I avoid it without saving this information in my database? If it helps I use Hibernate 3.5 and JPA 2. Thanks
has title: Null transient attributes
has answer: http://stackoverflow.com/a/2682973
type: AnsweredQuestion
score: 2
upvote count: 2
tagged with: java
tagged with: hibernate

http://stackoverflow.com/a/2747262
score: 1
has body: This example uses an enum of named functions and an abstract FunctionAdapter to invoke functions with a variable number of homogeneous parameters without reflection. The lookup() function simply uses Enum.valueOf, but a Map might be worth it for a large number of functions.
answers question: http://stackoverflow.com/q/2745796
upvote count: 1
type: Answer
downvote count: 0

http://stackoverflow.com/q/2660961
has answer: http://stackoverflow.com/a/15923023
type: Question
has comment: http://stackoverflow.com/comment/11766693
has answer: http://stackoverflow.com/a/10541987
has answer: http://stackoverflow.com/a/3578720
has answer: http://stackoverflow.com/a/40587625
has answer: http://stackoverflow.com/a/17406940
has answer: http://stackoverflow.com/a/24585526
answer count: 29
has answer: http://stackoverflow.com/a/38832243
has answer: http://stackoverflow.com/a/2661265
has answer: http://stackoverflow.com/a/31084291
has answer: http://stackoverflow.com/a/30958569
has body: I'm working on a project with Eclipse and by now everything was fine, but last time I've tried building it, it returned the error, "The project was not built due to "Could not delete '/Torpedo/bin/bin'.". Fix the problem, then try refreshing this project and building it since it may be inconsistent Torpedo Unknown Java Problem" And it deleted my bin folder which stores all the images and stuff needed for the program. (Fortunately I had a backup). I've tried googling it and tried every solution I found, but nothing helped, and also most of them suggests to delete the folder by hand, which I can't. What should I do?
has answer: http://stackoverflow.com/a/16179533
has comment: http://stackoverflow.com/comment/2678225
has title: Eclipse could not delete error
has answer: http://stackoverflow.com/a/42693782
has answer: http://stackoverflow.com/a/12369431
has answer: http://stackoverflow.com/a/13860182
has answer: http://stackoverflow.com/a/37654571
favorite count: 0
has answer: http://stackoverflow.com/a/7601382
has comment: http://stackoverflow.com/comment/9524833
has comment: http://stackoverflow.com/comment/9191824
has answer: http://stackoverflow.com/a/44964393
has answer: http://stackoverflow.com/a/3457771
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/5688144
upvote count: 54
has answer: http://stackoverflow.com/a/7570049
has answer: http://stackoverflow.com/a/51540747
tagged with: build
has comment: http://stackoverflow.com/comment/2678227
has answer: http://stackoverflow.com/a/2661522
has answer: http://stackoverflow.com/a/23564737
has answer: http://stackoverflow.com/a/44804617
score: 53
tagged with: java
has answer: http://stackoverflow.com/a/19882503
has answer: http://stackoverflow.com/a/7023493
has answer: http://stackoverflow.com/a/41933184
tagged with: eclipse
downvote count: 1
has answer: http://stackoverflow.com/a/33940353
has answer: http://stackoverflow.com/a/7606701

http://stackoverflow.com/comment/14137260
type: Comment
type: AnswerComment
has text: @Ryan Seems like if you are using up-to-date tools that shouldn't be an issue. I assume most of the problems you are talking about are configuration issues which should be mostly easy with new tools and not too much mix & match. Lots of the other problems have gone away in recent version (Beans are much easier to work with, etc), but if you have different experiences I'm actually curious as to where you've encounterd problems.
comment on: http://stackoverflow.com/a/2783825
score: 0

http://stackoverflow.com/a/2640472
type: Answer
score: 1
upvote count: 1
has body: You can try something like this in a stored procedure or parameterized SQL statement. This way you can pass in all of the fields even if only a few have values. @param1 varchar(25), @param2 int, @param3 varchar(10), @param4 char(1) SELECT column1, column2, column3, column4 FROM TABLE WHERE (column1 = @param1 OR @param1 IS NULL) AND (column2 = @param2 OR @param2 IS NULL) AND (column3 = @param3 OR @param3 IS NULL) AND (column4 = @param4 OR @param4 IS NULL)
answers question: http://stackoverflow.com/q/2640297
downvote count: 0

http://stackoverflow.com/comment/2766921
score: 0
type: AnswerComment
has text: With apologies, I updated your link so it worked correctly (SO breaks on the space) and also so it links to the current 1.6 docs rather than 1.4.2 (and by name rather than IP). +1, btw
type: Comment
comment on: http://stackoverflow.com/a/2738466

http://stackoverflow.com/q/2639343
answer count: 4
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2639372
tagged with: swing
type: Question
tagged with: java
has answer: http://stackoverflow.com/a/2639359
accepted answer: http://stackoverflow.com/a/2639359
has comment: http://stackoverflow.com/comment/2653756
has answer: http://stackoverflow.com/a/2639467
score: 0
has answer: http://stackoverflow.com/a/2639385
has body: i am learning Java at the moment and have the following question: i am adding my controls to JFrame and then pack() before displaying. this runs the application and all is very nice. i was wondering is there a way to stop the user from resizing the application window? also is there a way to for the image in JLabel to expand as the user changes the application window? at the moment i have it as: constraints.fill = GridBagConstraints.BOTH; constraints.anchor = GridBagConstraints.CENTER; and it only centers the image, i would like to be able to expand/shrink the image. thanks.
has answer: http://stackoverflow.com/a/2639372
tagged with: resize
has title: Java Pack No Resize

http://stackoverflow.com/comment/2766183
type: Comment
has text: Should be added to `<properties>` section in persistent unit in `persistence.xml`.
comment on: http://stackoverflow.com/a/2737534
type: AnswerComment
score: 4

http://stackoverflow.com/q/2635851
type: AnsweredQuestion
tagged with: types
downvote count: 0
score: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/2650047
type: Question
has answer: http://stackoverflow.com/a/2636022
tagged with: datetime
upvote count: 1
linked to: http://stackoverflow.com/q/2599102
tagged with: c++
tagged with: java
answer count: 1
has title: Java vs c++ types
accepted answer: http://stackoverflow.com/a/2636022
has comment: http://stackoverflow.com/comment/2650012
has body: I've recently had a question about coledatetime java implementation, and Chris said, that the problem might lay in type conversions: cpp-float vs java-float (Or maybe cpp-date vs java-date. Not types, but..). Now I have several questions on this: Is there a table of comparison for java vs c++ types? If type conversions is the problem, in my situation (I have a db with OLEDate records, already created with some c++ program. I need to read and write to that db, so that the OLEDate field compatibility remained: my java code reads proper dates, and c++ program is not affected with what the java program wrote to the db.), what would you do: Use COleDateTime to retrieve the date with JNI? Create your own implementation at all costs (using broader types, or anything else)? Is there anything, I'm missing here?
tagged with: coledatetime

http://stackoverflow.com/a/54560135
answers question: http://stackoverflow.com/q/2624763
score: 0
type: Answer
has body: You can also use a "resource resolver" to allow "xml authors" to specify their own schema file, at least to some extent, ex: https://stackoverflow.com/a/41225329/32453 at the end of the day, you want a fully compliant xml file that can be validatable with normal tools, anyway :)

http://stackoverflow.com/q/2681732
type: AnsweredQuestion
score: 1
upvote count: 1
type: Question
has body: my xml file has a tag with an attribute "containsValue" which contains the "special" characters you can see in the subject: &lt;original_msg_body id="msgBodySpecialCharsRule" containsValue=";ìè+òàù-&lt;^èç°§_&gt;!£$%&amp;/()=?~`'#;" /&gt; in my xml schema the attribute has xs:string: &lt;xs:attribute name="containsValue" type="xs:string" /&gt; I use this value inside a Java software which check if this value is contained inside another String. but I always obtain this Exception: javax.xml.bind.UnmarshalException - with linked exception: [org.xml.sax.SAXParseException: The value of attribute "containsValue" associated with an element type "original_msg_body" must not contain the '&lt;' character.] How can I solve it? I've tried changing the attribute type to xs:NMTOKEN, ut I get the same exception. Is there any other type? I think I could change the characters encoding, for example using the HTML representation, like &lt;, but than could be tricky for the string comparison...
has answer: http://stackoverflow.com/a/2681740
accepted answer: http://stackoverflow.com/a/2681760
tagged with: schema
tagged with: java
tagged with: special-characters
possible better answer: http://stackoverflow.com/a/2681740
tagged with: unmarshalling
answer count: 2
has title: Java, UnmarshallingException caused by XML attribute with special chars: ;ìè+òàù-<^èç°§_>!£$%&/()=?~`'#;
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2681760
tagged with: http://stackoverflow.com/tag/xml

http://stackoverflow.com/a/2696136
score: 9
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2693020
answers question: http://stackoverflow.com/q/2693020
has body: I've run into issues like this before where the system set PATH is not what the java process is seeing. As a way to debug this you can print out what the java process sees as the path env variable by using: EnvironmentUtils.getProcEnvironment(); Which will give you a map and you can look to see if Java can see the path variable. If it is not there then the next step would be to figure out why you can't see it. If it is there I would try running your excutor.execute command as follows: int exitValue = executor.execute(commandLine, EnvironmentUtils.getProcEnvironment());
type: Answer
upvote count: 9

http://stackoverflow.com/comment/30901038
type: Comment
comment on: http://stackoverflow.com/a/8929557
score: 3
type: AnswerComment
has text: Difference between the subsequent fires will not be same always.

http://stackoverflow.com/q/2705091
tagged with: java
has answer: http://stackoverflow.com/a/2705186
has comment: http://stackoverflow.com/comment/3079681
has comment: http://stackoverflow.com/comment/2728813
type: Question
has comment: http://stackoverflow.com/comment/3075774
has title: How do I cast from int to generic type Integer?
has body: I'm relatively new to Java and am used to generics in C# so have struggled a bit with this code. Basically I want a generic method for getting a stored Android preference by key and this code, albeit ugly, works for a Boolean but not an Integer, when it blows up with a ClassCastException. Can anyone tell me why this is wrong and maybe help me improve the whole routine (using wildcards?)? public static &lt;T&gt; T getPreference(Class&lt;T&gt; argType, String prefKey, T defaultValue, SharedPreferences sharedPreferences) { ... try { if (argType == Boolean.class) { Boolean def = (Boolean) defaultValue; return argType.cast(sharedPreferences.getBoolean(prefKey, def)); } else if (argType == Integer.class) { Integer def = (Integer) defaultValue; return argType.cast(new Integer(sharedPreferences.getInt(prefKey, def))); } else { AppGlobal.logWarning("getPreference: Unknown type '%s' for preference '%s'. Returning default value.", argType.getName(), prefKey); return defaultValue; } } catch (ClassCastException e) { AppGlobal.logError("Cast exception when reading pref %s. Using default value.", prefKey); return defaultValue; } } My calling code is: mAccuracy = GlobalPreferences.getPreference(Integer.class, prefKey, mAccuracy, sharedPreferences); Here is the Android code for getInt(): public int getInt(String key, int defValue) { synchronized (this) { Integer v = (Integer)mMap.get(key); return v != null ? v : defValue; } } I've tried various ways - using the native int, casting to an Integer, but nothing works.
accepted answer: http://stackoverflow.com/a/2705271
score: 0
answer count: 3
has answer: http://stackoverflow.com/a/2705111
tagged with: generics
possible better answer: http://stackoverflow.com/a/2705111
tagged with: android
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2705271

http://stackoverflow.com/comment/6466654
type: Comment
comment on: http://stackoverflow.com/a/5169339
score: 1
type: AnswerComment
has text: Hehe, sorry for the misunderstanding : I assumed the common convention of `TEST_EXPORTS` being defined as `__declspec(dllimport)` or `__declspec(dllexport)`, as is done automatically from MSVC++'s "new C++ project" wizard. I'm of course talking about C++ libraries that could be linked to by a thirdparty C++ program (the problem is the same for a linker and for BridJ).

http://stackoverflow.com/a/42344215
has body: Recommending date streams In Java 9, you can use following new method, LocalDate::datesUntil: LocalDate start = LocalDate.of(2017, 2, 1); LocalDate end = LocalDate.of(2017, 2, 28); Stream&lt;LocalDate&gt; dates = start.datesUntil(end.plusDays(1)); List&lt;LocalDate&gt; list = dates.collect(Collectors.toList()); The new method datesUntil(...) works with an exclusive end date, hence the shown hack to add a day. Once you have obtained a stream you can exploit all the features offered by java.util.stream- or java.util.function-packages. Working with streams has become so simple compared with earlier approaches based on customized for- or while-loops. Or if you look for a stream-based solution which operates on inclusive dates by default but can also be configured otherwise then you might find the class DateInterval in my library Time4J interesting because it offers a lot of special features around date streams including a performant spliterator which is faster than in Java-9: PlainDate start = PlainDate.of(2017, 2, 1); PlainDate end = start.with(PlainDate.DAY_OF_MONTH.maximized()); Stream&lt;PlainDate&gt; stream = DateInterval.streamDaily(start, end); Or even simpler in case of full months: Stream&lt;PlainDate&gt; februaryDates = CalendarMonth.of(2017, 2).streamDaily(); List&lt;LocalDate&gt; list = februaryDates.map(PlainDate::toTemporalAccessor).collect(Collectors.toList());
type: Answer
upvote count: 15
downvote count: 0
score: 15
answers question: http://stackoverflow.com/q/2689379

http://stackoverflow.com/comment/55581661
has text: I am using this same technique as you provided. But there is still a problem; this method prepares a different statement for each insert as it can be shown in sql profiler. To increase the performance it needs to compile or prepare statement once then call that compiled statement for the rest of the inserts.
score: 1
comment on: http://stackoverflow.com/a/26620528
type: AnswerComment
type: Comment

http://stackoverflow.com/q/2612426
has body: How do I start to develop a plugin for Eclipse? I need a tool which isn't out there yet for my further development... so my main concerns are: How to add a perspective? How to add menu items? How to add a view into the "Show Views" menu? How to add to the preference pane? How do I get information, like: Where is the workspace? Which files are open in the editor? Which projects are collapsed / expanded in the left projects view? ..... Which conventions (naming...) should I consider? How to set up update site/deployment? Can you give me some hints, links, tutorials, etc? Don't get me wrong. I am using Eclipse RCP for developing standalone apps for quite some time, so I am familiar with the techniques, but I never started to develop a plugin for Eclipse itself. Thanks.
score: 4
tagged with: eclipse-rcp
answer count: 1
downvote count: 0
accepted answer: http://stackoverflow.com/a/2612466
favorite count: 0
upvote count: 4
has answer: http://stackoverflow.com/a/2612466
type: AnsweredQuestion
tagged with: java
tagged with: rcp
tagged with: eclipse
has title: Eclipse plugin development for Eclipse
type: Question
linked to: http://stackoverflow.com/q/6845190

http://stackoverflow.com/a/2716502
has comment: http://stackoverflow.com/comment/6099168
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/2714034
score: 1
has comment: http://stackoverflow.com/comment/6117271
has body: I've never faced this situation but I think that you'll need to implement a custom UserCollectionType (see chapter 5.2.3. Custom value types in Hibernate Core documentation), the UserCollectionType being an extension point which may be used to support any damn collection and collection semantics you like. I'm not sure how well they are supported by annotations though (according to HHH-4417, you may have to use a hack). Using hbm.xml for this would be a good idea here IMO. Some more pointers/discussions: https://forum.hibernate.org/viewtopic.php?f=9&amp;t=938522&amp;start=0 http://www.javalobby.org/java/forums/m91832311.html (different case but may give you an idea of how to start)
downvote count: 0

http://stackoverflow.com/q/2779499
score: 3
tagged with: java
has body: I have created 2 plugins, implementing an ODA driver plugin and its UI plugin for the BIRT extension to Eclipse. My plugins both work as expected when eclipse starts up another eclipse application where I can then test the plugins I am developing. However, when I install my plugins into an Eclipse application and then start it from a Windows shortcut, the plugins work but and language keys specified in the plugin.xml files are not found. For example, in my plugin.xml file for the ODA Driver plugin I set the attributes 'id' to '%oda.data.source.id' and the data source 'defaultDisplayName' to '%data.source.name'. I then, in a file 'language.properties', have defined the values for both of these keys (where the keys don't have the preceeding % character). When running the plugins that have been installed into the dropins/plugins directory of an Eclipse application, the wizard for creating my ODA data source names is as '%data.source.name' and saves the data source in the rptdesign (XML) file with an ID of '%oda.data.source.id'. Since 'language' is not the default name for the properties file I went into the manifest for both plugins and changed the 'Bundle-Localization' attribute to 'language'. The language file is located in the root directory of both of my plugins. The properties file is definitely found, since I use the two language files to store other strings used by the plugins, looked up using a java ResourceBundle. The strings are always found whether the plugins are run from Eclipse application loading another, or when properly installed in the dropins/plugins directory of an Eclipse application. Why are the installed plugins not finding language keys reference in the plugin.xml files? There are not errors in the logs and the language.properties files are clearly accessible... Thanks in advance.
answer count: 2
downvote count: 0
tagged with: eclipse-plugin
favorite count: 0
type: UnansweredQuestion
tagged with: internationalization
has title: Internationalized strings in Eclipse plugin.xml file are not found when installed in Eclipse application
upvote count: 3
tagged with: plugin.xml
has answer: http://stackoverflow.com/a/4728679
has answer: http://stackoverflow.com/a/2852510
tagged with: eclipse-pde
type: Question

http://stackoverflow.com/q/2681029
downvote count: 0
score: 7
tagged with: multiple-constructors
answer count: 3
accepted answer: http://stackoverflow.com/a/2681118
has answer: http://stackoverflow.com/a/2681057
favorite count: 0
has body: Given a finite number of items which differ in kind, is it better to represent them with stacked enums and enum constructors, or to subclass them? Or is there a better approach altogether? To give you some context, in my small RPG program (which ironically is supposed to be simple), a character has different kinds of items in his or her inventory. Items differ based on their type and use and effect. For example, one item of inventory is a spell scroll called Gremlin that adjusts the Utility attribute. Another item might be a sword called Mort that is used in combat and inflicts damage. In my RPG code, I now have tried two ways of representing inventory items. One way was subclassing (for example, InventoryItem -> Spell -> AdjustingAttributes; InventoryItem -> Weapon -> Sword) and instantiating each subclass when needed, and assigning values such as names like Gremlin and Mort. The other way was by stacking enums and enum constructors. For example, I created enums for itemCategory and itemSpellTypes and itemWeaponTypes, and the InventoryItem enum was like this: public enum InventoryItem { GREMLIN(itemType.SPELL, itemSpellTypes.ATTRIBUTE, Attribute.UTILITY), MORT(itemType.WEAPON, itemWeaponTypes.SWORD, 30); InventoryItem(itemType typeOfItem, itemSpellTypes spellType, Attribute attAdjusted) { // snip, enum logic here } InventoryItem(itemType typeOfItem, itemWeaponTypes weaponType, int dmg) { // snip, enum logic here } // and so on, for all the permutations of items. } Is there a better Java programming practice than these two approaches? Or if these are the only ways, which of the two is better? Thanks in advance for your suggestions.
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2681067
possible better answer: http://stackoverflow.com/a/2681057
upvote count: 7
type: Question
tagged with: enums
tagged with: java
has answer: http://stackoverflow.com/a/2681118
tagged with: subclassing
has title: Which is better Java programming practice: stacking enums and enum constructors, or subclassing?

http://stackoverflow.com/comment/2634811
type: Comment
comment on: http://stackoverflow.com/q/2622355
type: QuestionComment
has text: If Aaron Digulla's suggestion doesn't help, please show some code.
score: 0

http://stackoverflow.com/comment/2792620
type: Comment
comment on: http://stackoverflow.com/a/2759905
type: AnswerComment
has text: @camickr: Thank you for pointing it out. I should use `requestFocusInWindow()` instead.
score: 0

http://stackoverflow.com/comment/50184374
comment on: http://stackoverflow.com/a/21409975
type: AnswerComment
has text: The *"Invoking Object.wait outside synchronized context"* is a NetBeans specific message and not something that is mandated by JLS. As for my remarks, you're welcome. Helping others improves my knoledge too. As I learn new stuff I try to update my posts. I recommend you to do so too. If you learn that your answer is incorrect but don't have time to update it, plase consider deleting it to avoid spreading the confusion. Finally, no one kicked you out, but if you can't stand the heat, get out of the kitchen ;-)
type: Comment
score: 1

concurrency
tag name: concurrency
tags question: http://stackoverflow.com/q/2779484
tags question: http://stackoverflow.com/q/2758966
tags question: http://stackoverflow.com/q/2667264
tags question: http://stackoverflow.com/q/2676295
tags question: http://stackoverflow.com/q/2653431
tags question: http://stackoverflow.com/q/2708376
tags question: http://stackoverflow.com/q/2695426
tags question: http://stackoverflow.com/q/2664172
tags question: http://stackoverflow.com/q/2755969
tags question: http://stackoverflow.com/q/2715983
tags question: http://stackoverflow.com/q/2644611
tags question: http://stackoverflow.com/q/2745839
tags question: http://stackoverflow.com/q/2691041
tags question: http://stackoverflow.com/q/2640135
tags question: http://stackoverflow.com/q/2624638
tags question: http://stackoverflow.com/q/2610295
tags question: http://stackoverflow.com/q/2694439
tags question: http://stackoverflow.com/q/2674174
tags question: http://stackoverflow.com/q/2601094
tags question: http://stackoverflow.com/q/2758448
tags question: http://stackoverflow.com/q/2712316
tags question: http://stackoverflow.com/q/2778476
tags question: http://stackoverflow.com/q/2719107
tags question: http://stackoverflow.com/q/2698217
tags question: http://stackoverflow.com/q/2728311
tags question: http://stackoverflow.com/q/2769646
tags question: http://stackoverflow.com/q/2770965
tags question: http://stackoverflow.com/q/2624665
type: Tag
tags question: http://stackoverflow.com/q/2761481
tags question: http://stackoverflow.com/q/2704198
tags question: http://stackoverflow.com/q/2771373
tags question: http://stackoverflow.com/q/2712197
tags question: http://stackoverflow.com/q/2640212
tags question: http://stackoverflow.com/q/2762922
tags question: http://stackoverflow.com/q/2780255
tags question: http://stackoverflow.com/q/2771214
tags question: http://stackoverflow.com/q/2612054
tags question: http://stackoverflow.com/q/2786132
tags question: http://stackoverflow.com/q/2758612
tags question: http://stackoverflow.com/q/2614066
tags question: http://stackoverflow.com/q/2774252
tags question: http://stackoverflow.com/q/2681816

http://stackoverflow.com/a/38832243
downvote count: 0
answers question: http://stackoverflow.com/q/2660961
type: Answer
has body: I just had this problem and it was TGitCache.exe locking the bin folder. If you use TortoiseGit, just kill the TGitCache.exe process and you should be all set.
upvote count: 2
score: 2

http://stackoverflow.com/a/2600393
upvote count: 15
answers question: http://stackoverflow.com/q/2597271
type: Answer
has comment: http://stackoverflow.com/comment/76034685
has body: I know you said you didn't want to read the file in by hand, but this is pretty easy public class FooTest { private BufferedReader in = null; @Before public void setup() throws IOException { in = new BufferedReader( new InputStreamReader(getClass().getResourceAsStream("/data.txt"))); } @After public void teardown() throws IOException { if (in != null) { in.close(); } in = null; } @Test public void testFoo() throws IOException { String line = in.readLine(); assertThat(line, notNullValue()); } } All you have to do is ensure the file in question is in the classpath. If you're using Maven, just put the file in src/test/resources and Maven will include it in the classpath when running your tests. If you need to do this sort of thing a lot, you could put the code that opens the file in a superclass and have your tests inherit from that.
downvote count: 1
score: 14

http://stackoverflow.com/a/2608438
score: 0
type: Answer
has body: Check out http://www.metawidget.org/
answers question: http://stackoverflow.com/q/2608296

http://stackoverflow.com/comment/103421398
type: Comment
has text: In web applications, where exiting for any reason is the biggest NO NO, assertions are still useful. First of all, any of today's web frameworks will catch the AssertionError and return a 500-InternalServerError result, then will continue servicing requests. Second, you should leave them off in production anyway, so they can't get triggered. I find assertions very useful in web development. I turn them on when I'm testing my changes and running my unit tests. I'm very finicky, so I even run my unit tests again with Assertions turned off before I check my code in, but that may be overkill.
comment on: http://stackoverflow.com/q/2758224
score: 0
type: QuestionComment

http://stackoverflow.com/comment/11431573
type: Comment
comment on: http://stackoverflow.com/q/2642696
score: 0
type: QuestionComment
has text: @AaronLS Here come the NarWARs!

http://stackoverflow.com/q/2689014
tagged with: algorithm
tagged with: java
tagged with: image-processing
tagged with: http://stackoverflow.com/tag/c
type: Question
upvote count: 4
answer count: 2
downvote count: 0
accepted answer: http://stackoverflow.com/a/2689074
possible better answer: http://stackoverflow.com/a/2693459
has answer: http://stackoverflow.com/a/2693459
has body: Please consider following use case, I have one bigger image, lets called is master image. Now from some where else, I am getting one small image. I want to check whether this small image is subset of master image or not. important points are, smaller image might have different file format, smaller image might captured from comparatively different view. smaller image may have different light intensity. At this stage of algorithm/computation advancement, which level of accuracy I could expect? Any algorithm/open source implementation that would have such implementation? Thanks, Rajnikant
favorite count: 0
score: 4
has title: algorithm for image comparison
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2689074

http://stackoverflow.com/comment/115019303
type: Comment
has text: would it not be blocking if we call future.get().
comment on: http://stackoverflow.com/a/38710673
type: AnswerComment
score: 0

http://stackoverflow.com/a/2728695
has body: Simple answer: no, that's not possible.
accepted answer of: http://stackoverflow.com/q/2728233
type: AcceptedAnswer
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2728233
score: 2
upvote count: 2

http://stackoverflow.com/a/2622833
downvote count: 2
has body: The value 20646520 is in ASCII @A. ObjectInput/OutputStreams use a "magic" value at the beginning of the stream, to indicate it complies to the special serialization of the objects. (I think this was 0xCAFEBABE, but I'm not sure) This means in your situation that something has already read the stream before the ObjectInputStream has the chance to read the magic, or that the stream it reads is not producted by an ObjectOutputStream; You assign the variable by to wig (or append), which is a byte array which is not generated by an ObjectOutputStream, as far as I can tell, since it uses mensajeRecipido.fileContent. I presume mensajeRecipido.fileContent is the content of an actual file. In this running instance is not of the same format as an ObjectOutputStream, and that's why you get the stream header exception.
upvote count: 10
score: 8
type: Answer
has comment: http://stackoverflow.com/comment/2635268
has comment: http://stackoverflow.com/comment/2642281
answers question: http://stackoverflow.com/q/2622716
has comment: http://stackoverflow.com/comment/96241375

http://stackoverflow.com/q/2783555
possible better answer: http://stackoverflow.com/a/2783861
has body: Recently I did a Java programming exercise successfully which was sent by a recruiting firm, The problem statement goes like this 'There are two text files FI(records abt files and directory information) and FS(containing blocks of data) which represent a file Index and file System respectively and I was supposed to write a static read method in a class which will read the file from the FS depending upon the path string provided using FI' My question is where can I get these kind of exercises to solve, the complexity should be above average to tough.
has title: where can I get these kind of exercises to solve?
has answer: http://stackoverflow.com/a/2783588
type: Question
has answer: http://stackoverflow.com/a/2783573
type: AnsweredQuestion
tagged with: java
score: 10
upvote count: 10
has answer: http://stackoverflow.com/a/2783861
has answer: http://stackoverflow.com/a/2784018
answer count: 4
favorite count: 0
accepted answer: http://stackoverflow.com/a/2783573
downvote count: 0

http://stackoverflow.com/comment/2606850
type: AnswerComment
comment on: http://stackoverflow.com/a/2598254
score: 0
has text: You're right it would be best, but I'm using my own iterator over something that's not a real Collection (it's a DOM NodeList). Otherwise, your answer makes sense, thanks.
type: Comment

http://stackoverflow.com/comment/2731362
type: Comment
score: 1
has text: @polygenelubricants: A `Class<?>` object is not a class. It's metadata about a *type*.
comment on: http://stackoverflow.com/a/2706085
type: AnswerComment

http://stackoverflow.com/comment/3036223
type: AnswerComment
type: Comment
has text: My application uses a query that may need to change in the future, I don't want it stored in the application code AT ALL, I don't want the SQL in a string, I don't want it in a text file, I don't want it stored in any way that is not managed by the database. I'm not saying I want to store it in a table in the database, I want it stored in a function/view/stored procedure that way the code references it by name and I can change it on the fly later in the DB
comment on: http://stackoverflow.com/a/2816017
score: 0

http://stackoverflow.com/comment/2703771
score: 0
type: Comment
has text: @jens Are you sure you want to use dynamic-query ??? Each Time you *dynamic-update* your instance, Hibernate needs to create a new update query *instead of use a cached update query*. Be aware of performance issues.
comment on: http://stackoverflow.com/a/2675629
type: AnswerComment

http://stackoverflow.com/comment/2803524
score: 0
has text: BlockingQueue is a threadsafe way to pass stuff around. Is your list changing mid iteration? If not, then you don't need to worry about the thread saftey of how you distribute the work. Thread saftey of which threads are running, yes.
type: AnswerComment
comment on: http://stackoverflow.com/a/2769655
type: Comment

http://stackoverflow.com/comment/2760122
has text: yes, you would expect it. And will know which setting to change in 99% of the cases. Others will not expect it :) That said - in what case actually it makes sense to have the bundled library loaded, instead of the one in the application?
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2730432

http://stackoverflow.com/q/2650691
favorite count: 0
has comment: http://stackoverflow.com/comment/2667149
answer count: 0
type: UnansweredQuestion
upvote count: 1
has comment: http://stackoverflow.com/comment/10833594
has title: Junit 4 custom test class description
type: Question
linked to: http://stackoverflow.com/q/650894
tagged with: junit4
score: 1
tagged with: java
tagged with: junit
downvote count: 0
has body: I am using the @Parameterized annotation to run a test class over and over again against different test files. The problem is that in my IDE/build server the tests show up as "MapSimulationTest" 0-x. How can I have a method that provides JUnit 4 with a custom name for each instance of my MapSimulationTest class? In this case it would be the filename the test is being run against.

http://stackoverflow.com/a/2681637
has comment: http://stackoverflow.com/comment/2704383
has body: I would say that neither design makes sense in practice, regardless of the performance. I would argue that both mechanisms are overly complicated and, more importantly, don't take into account actual usage. Actual Usage If a user looks up a value in a map and it isn't there, most likely the user wants one of the following: To insert some value with that key into the map To get back some default value To be informed that the value isn't there Thus I would argue that a better, null-free API would be: has(key) which indicates if the key is present (if one only wishes to check for the key's existence). get(key) which reports the value if the key is present; otherwise, throws NoSuchElementException. get(key,defaultval) which reports the value for the key, or defaultval if the key isn't present. setdefault(key,defaultval) which inserts (key,defaultval) if key isn't present, and returns the value associated with key (which is defaultval if there is no previous mapping, otherwise prev mapping). The only way to get back null is if you explicity ask for it as in get(key,null). This API is incredibly simple, and yet is able to handle the most common map-related tasks (in most use cases that I have encountered). I should also add that in Java, has() would be called containsKey() while setdefault() would be called putIfAbsent(). Because get() signals an object's absence via a NoSuchElementException, it is then possible to associate a key with null and treat it as a legitimate association.... if get() returns null, it means the key has been associated with the value null, not that the key is absent (although you can define your API to disallow a value of null if you so choose, in which case you would throw an IllegalArgumentException from the functions that are used to add associations if the value given is null). Another advantage to this API, is that setdefault() only needs to perform the lookup procedure once instead of twice, which would be the case if you used if( ! dict.has…
downvote count: 0
has comment: http://stackoverflow.com/comment/2706592
has comment: http://stackoverflow.com/comment/2710012
has comment: http://stackoverflow.com/comment/2710011
upvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/2721451
score: 2
has comment: http://stackoverflow.com/comment/2710030
has comment: http://stackoverflow.com/comment/2713336
answers question: http://stackoverflow.com/q/2681415

http://stackoverflow.com/q/2779035
tagged with: swing
has answer: http://stackoverflow.com/a/4988248
has comment: http://stackoverflow.com/comment/2814140
has body: As discussed here, when resizing a Swing application in Vista (and Windows 7, which is what I'm using) you get a black background in the right/bottom corner while Swing's repaint catches up to the changes. Playing with other applications (Windows Explorer (Native), Firefox (C++?), and Eclipse (Java)) I notice that they all have this same problem - contrary to what the folks in the link above say - but they minimize the problem by having a grey fill color, which is far less visually jarring than the black that appears in Swing. I'm wondering if there's some way to change this so that Swing behaves like these other applications? I tried setting the background color of the JFrame, but to no avail. Additional Info Jonas discovered (see their informative answer below) that this is an issue with JFrames, but not AWT Frames - maybe that will help someone figure this out.
type: UnansweredQuestion
has title: Changing The Underlying Background Color Of A Swing Window
score: 13
downvote count: 0
linked to: http://stackoverflow.com/q/2780780
favorite count: 0
has comment: http://stackoverflow.com/comment/2814102
has answer: http://stackoverflow.com/a/2779448
type: Question
tagged with: jframe
tagged with: windows
has comment: http://stackoverflow.com/comment/2814107
upvote count: 13
tagged with: paint
tagged with: java
answer count: 3
has answer: http://stackoverflow.com/a/2779280

http://stackoverflow.com/a/4415097
has body: There's a product called Rampart that lets you make a trial version for your Java app. It only takes a couple of minutes and it works pretty well. You can find it at http://Rampartlicensing.com
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2769384
type: Answer
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/62756782
accepted answer of: http://stackoverflow.com/q/2769384
has comment: http://stackoverflow.com/comment/60884699
has comment: http://stackoverflow.com/comment/62538433

http://stackoverflow.com/a/2642045
type: Answer
score: 3
has body: According to benchmark tests in While loop, For loop and Iterator Performance Test – Java and the JavaRanch question "is using ArrayList.iterator() is faster than looping ArrayList in for loop?" the iterator is actually a bit slower. I'd still favor readability unless I'd benchmarked my entire application and found that loop to be my bottleneck, though.
downvote count: 1
answers question: http://stackoverflow.com/q/2642004
upvote count: 4
has comment: http://stackoverflow.com/comment/2657167
has comment: http://stackoverflow.com/comment/2656951

http://stackoverflow.com/comment/2813456
has text: @WizardOfOdds-- really? A student who calculates the answers to a timed problem in advance, and then refers to a table for the answer is in the spirit of the competition? As @Lucero points out, that's lame, because it's 'dumb but quick', and as a teacher, yes, I would disqualify that. Maybe your teaching style is why I have such a hard time finding trained, competent people who can write decent code, but a really easy time finding parrots who can't think on their feet.
type: AnswerComment
type: Comment
score: 1
comment on: http://stackoverflow.com/a/2777526

http://stackoverflow.com/comment/2726334
type: Comment
has text: Why haven't you accepted some answers?
type: QuestionComment
score: 2
comment on: http://stackoverflow.com/q/2703009

http://stackoverflow.com/comment/2619301
type: Comment
has text: Interesting. I've never seen this used before. Similarly, would converting from hex be done with radix 16? Or have I interpreted the use incorrectly?
type: AnswerComment
comment on: http://stackoverflow.com/a/2608919
score: 0

http://stackoverflow.com/a/2688349
has body: I am not sure but I think JUnit and EasyMock instead of being exclusive to each other are supposed to work in tandem together. JUnit idea is to test a given method and therefore you want to inject dummy instances of other classes into it, to ensure the JUnit test is not dependent on other class methods at all. This purpose of providing mock objects in JUnit is served by EasyMock and other similar mock object creators. Similar idea is used when using spring to inject dummy implementations into JUnit. EasyMock seems to be promising, but you should evaluate if Spring or some other proxy object generators fit your scenario.
score: 0
type: Answer
answers question: http://stackoverflow.com/q/2688304

http://stackoverflow.com/a/5805132
downvote count: 0
has comment: http://stackoverflow.com/comment/33434665
answers question: http://stackoverflow.com/q/2737420
upvote count: 31
has comment: http://stackoverflow.com/comment/43296172
has body: In order to avoid hardcoding schema in JPA Entity Java Classes we used orm.xml mapping file in Java EE application deployed in OracleApplicationServer10 (OC4J,Orion). It lays in model.jar/META-INF/ as well as persistence.xml. Mapping file orm.xml is referenced from peresistence.xml with tag ... <persistence-unit name="MySchemaPU" transaction-type="JTA"> ... META-INF/orm.xml ... File orm.xml content is cited below: <?xml version="1.0" encoding="UTF-8"?> <persistence-unit-metadata> <persistence-unit-defaults> myschema </persistence-unit-defaults> </persistence-unit-metadata>
type: Answer
score: 31

http://stackoverflow.com/comment/99039331
has text: The solution is to use select for update when fetching the record to lock the row, so nothing else can delete it before you do.
comment on: http://stackoverflow.com/a/13309318
type: AnswerComment
type: Comment
score: 1

http://stackoverflow.com/comment/2645383
type: QuestionComment
has text: Your question is a little vague. Do you want to use an ArrayList as a key in a Java HashMap? Maybe a few more sentences to clarify your question would be good.
score: 0
comment on: http://stackoverflow.com/q/2632003
type: Comment

http://stackoverflow.com/q/2749296
downvote count: 1
has body: I try to be as minimalist as possible. Repetition is a problem. I hate it. When is it really a problem? what is static-overuse? what is field-method overuse? what is class-overuse? are there more types of overuse? Problem A: when it is too much to use of static? private static class Data { private static String fileContent; private static SizeSequence lineMap; private static File fileThing; private static char type; private static boolean binary; private static String name; private static String path; } private static class Print { //&lt;1st LINE, LEFT_SIDE, 2nd LINE, RIGHT_SIDE&gt; private Integer[] printPositions=new Integer[4]; private static String fingerPrint; private static String formatPrint; } Problem B: when it is too much to get field data with private methods? public Stack&lt;Integer&gt; getPositions(){return positions;} public Integer[] getPrintPositions(){return printPositions;} private Stack&lt;String&gt; getPrintViews(){return printViews;} private Stack&lt;String&gt; getPrintViewsPerFile(){return printViewsPerFile;} public String getPrintView(){return printView;} public String getFingerPrint(){return fingerPrint;} public String getFormatPrint(){return formatPrint;} public String getFileContent(){return fileContent;} public SizeSequence getLineMap(){return lineMap;} public File getFile(){return fileThing;} public boolean getBinary(){return binary;} public char getType(){return type;} public String getPath(){return path;} public FileObject getData(){return fObj;} public String getSearchTerm(){return searchTerm;} Related interface overuse overuse of static in a Game
has comment: http://stackoverflow.com/comment/2780107
type: Question
score: 3
has title: Java: repetition, overuse -- problem?
possible better answer: http://stackoverflow.com/a/2749434
linked to: http://stackoverflow.com/q/1561299
tagged with: java
answer count: 2
favorite count: 0
tagged with: overuse
has answer: http://stackoverflow.com/a/2749434
tagged with: repeat
upvote count: 4
tagged with: coding-style
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2749310
accepted answer: http://stackoverflow.com/a/2749310

http://stackoverflow.com/q/2761618
type: Question
answer count: 2
possible better answer: http://stackoverflow.com/a/41741857
downvote count: 0
has answer: http://stackoverflow.com/a/41741857
tagged with: tomcat
has answer: http://stackoverflow.com/a/2761676
favorite count: 0
has body: My server.xml looks like the following: &lt;!--The connectors can use a shared executor, you can define one or more named thread pools--&gt; &lt;Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="200" minSpareThreads="4"/&gt; &lt;Connector executor="tomcatThreadPool" port="8080" protocol="HTTP/1.1" connectionTimeout="10000" maxKeepAliveRequests="1" redirectPort="8443" /&gt; &lt;Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /&gt; However, in the Tomcat manager (http://localhost/manager/status) it shows to following http-8080: Max threads: -1 Current thread count: -1 Current thread busy: -1 jk-8009: Max threads: 200 Current thread count: 4 Current thread busy: 1 For some reason it looks like http-8080 isn't using the executor even though it is directed too and jk-8009 is using the executor even though it isn't instructed to. Is the manager just misreporting or have I not setup the thread pool correctly?
has title: Why is my Tomcat 6 executor thread pool not being used by the connector?
upvote count: 2
accepted answer: http://stackoverflow.com/a/2761676
score: 2
type: AnsweredQuestion
tagged with: java
tagged with: server.xml
tagged with: tomcat6

http://stackoverflow.com/a/3630209
has body: You could try writing a custom XMLAdaptor that converts your integer to a String (or other object), then converts it back as you see fit. During the unmarshalling, I imagine a quick case-insensitive check for 'null' would be all that you'd need. Start here: http://download.oracle.com/javase/6/docs/api/javax/xml/bind/annotation/adapters/XmlAdapter.html Attach the adaptor to your int field and write the body. Your converter would start as follows: public class MyIntConverter extends XmlAdapter&lt;String,Integer&gt; { @Override public String marshal(Integer value) throws Exception { if ( value.intValue() == 0 ) return null; // Or, "null" depending on what you'd like return value.toString(); } @Override public Integer unmarshal(String storedValue) throws Exception { if ( storedValue.equalsIgnoreCase("null") ) return 0; return Integer.valueOf(storedValue); } } Then, you could put it to use: @XmlJavaTypeAdapter(MyIntConverter.class) int someNumber; The code is untested, but I think it should solve the issue.
answers question: http://stackoverflow.com/q/2775514
type: Answer
downvote count: 0
score: 1
upvote count: 1

http://stackoverflow.com/comment/2817343
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2782303
type: AnswerComment
has text: I think the OP knows about this since 1, he writes "I know how to minimize or make a frame invisible", 2, the question is tagged with "robot". Furthermore "I want it to look something like the magnifier in Windows Vista/7" really indicates that his app can't be minimized when taking the screenshot.

http://stackoverflow.com/a/30320044
has comment: http://stackoverflow.com/comment/76419494
answers question: http://stackoverflow.com/q/2615712
downvote count: 3
upvote count: 0
has body: This is my answer in C , O(N) complexity time. Pass the array only once, only three variables. The solution is very intuitive and easy to understand. #include &lt;stdio.h&gt; int second(int arr[],int size) { int i, max , secondmax; if (arr[0] &gt; arr[1]){ max = arr[0]; secondmax = arr[1]; } else { max = arr[1]; secondmax = arr[0]; } for (i = 2; i &lt; size; i++) { if ((arr[i] &lt; max) &amp;&amp; (arr[i] &lt; secondmax)) { continue; } if ((arr[i] &lt; max) &amp;&amp; (arr[i] &gt; secondmax)) { secondmax = arr[i]; continue; } if ((arr[i] &gt; max)) { secondmax = max; max = arr[i]; continue; } } return secondmax; } void main() { int arr[] = { 1,10,5,7}; int size = sizeof(arr) / sizeof(arr[0]); int secondmax = second(arr,size); printf("%d \n\n", secondmax); }
score: -3
type: Answer

http://stackoverflow.com/q/2652295
favorite count: 0
has answer: http://stackoverflow.com/a/2652327
has answer: http://stackoverflow.com/a/2652306
possible better answer: http://stackoverflow.com/a/2652306
has answer: http://stackoverflow.com/a/2652334
has answer: http://stackoverflow.com/a/2652325
has answer: http://stackoverflow.com/a/2652347
accepted answer: http://stackoverflow.com/a/2652325
has body: In some sample codes there are methods and classes declared WITHIN other methods and/or classes. I've never heard/read about this. What effect does this kind of programming have? Wouldn't it be better to write down classes in a seperate file and methods side by side and not within each other (like every book tells you)? What are the advantages and disadvantages of this kind of programming? Here's an example of what I mean: Handler mHandler = new Handler() { public void handleMessage(android.os.Message msg) { TextView textView = (TextView) findViewById(R.id.description); textView.setText(mRoad.mName + " " + mRoad.mDescription); MapOverlay mapOverlay = new MapOverlay(mRoad, mapView); List&lt;Overlay&gt; listOfOverlays = mapView.getOverlays(); listOfOverlays.clear(); listOfOverlays.add(mapOverlay); mapView.invalidate(); } };
tagged with: conventions
has answer: http://stackoverflow.com/a/2652318
type: AnsweredQuestion
tagged with: oop
has answer: http://stackoverflow.com/a/2652413
tagged with: java
tagged with: class
type: Question
score: 0
has title: Strange Java code: Class in a Class
upvote count: 1
downvote count: 1
answer count: 7

http://stackoverflow.com/a/2696332
downvote count: 0
answers question: http://stackoverflow.com/q/2696285
has comment: http://stackoverflow.com/comment/2720602
upvote count: 3
has body: This is exactly the way painting works. Swing has to search for the first component that has a non-opaque background. Then it paints that component and the children to make sure all the painting is done correctly. Even if you have a moving compnent, SWing would still need to "clear" the last position of the compnent, which means it has to at least repaint that area of the background panel, before repaint the component that moved. To make the painting more efficient the child panel should be opaque. I don't know why you changed the default setting.
type: Answer
score: 3

http://stackoverflow.com/comment/2751166
type: AnswerComment
type: Comment
has text: where should I specify username and password?
comment on: http://stackoverflow.com/a/2724523
score: 0

http://stackoverflow.com/a/2639935
score: 13
accepted answer of: http://stackoverflow.com/q/2638073
downvote count: 1
has comment: http://stackoverflow.com/comment/2684467
has comment: http://stackoverflow.com/comment/11664226
has comment: http://stackoverflow.com/comment/2684441
has comment: http://stackoverflow.com/comment/2683725
answers question: http://stackoverflow.com/q/2638073
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2692674
has body: I'm serving a "few hundred users" from a single EC2 High-CPU Medium instance. No load balancing, no dedicated DB servers, nothing fancy at all. Simply a single box. Additionally I'm using some services: Elastic Block Store for MySQL data, MySQL binlogs and Lucene indexes S3 for resource and backup storage, obviously different baskets for each SimpleDB Metadata for resources CloudFront for resources - mainly because we can :) Simple Queue Service for messaging (used to queue some background tasks) As I said, nothing fancy - at least in Amazon's cloud environment. And everything for less than 200$/month. Regarding pricing, you should take care though. Amazon did a good job at obfuscating main costs. For example, looking at CloudFront Pricing, you might look at 0,15$ per GB but ignore 0,01$ per 10,000 - it's a ridiculously small price for a lot of requests, isn't it? Big surprise: 2/3 of our CloudFront cost is for requests (about 3 KB per request). I/O requests for EBS is a similar story. As it would be extremely easy to scale (use a bigger instance, move DB on Relational Database Service) I'd suggest you start with the same setup. As you said, throwing more boxes in is pretty simple (assuming your setup supports adding/removing nodes on the fly). This makes choosing the appropriate setup by trial and error easily feasible - some thorough load testing should do the job. Choose something that works for your expected load (plus some extra power) and grow/shrink as soon as you have production data. As a conclusion: yes, it's certainly possible to host Java EE apps on EC2 :) Edit: as a side note: comparing pricing of EC2 with traditional hosting is comparing apples and oranges - at least as long as you don't get an SLA for your network, nearly unlimited scalability, no hardware issues, nearly unlimited and redundant storage, different availability zones and a bunch of extra services with it. If somebody tells you that traditional hosting is cheaper, he might be a sysadmin …
type: Answer
has comment: http://stackoverflow.com/comment/11666156
upvote count: 14

http://stackoverflow.com/q/2599536
accepted answer: http://stackoverflow.com/a/8102421
has body: I have started teaching myself about the Android NDK and I have followed this example here - http://marakana.com/forums/android/android_examples/49.html I have followed the steps perfectly but when I run the application I get the following error: Trying to load lib /data/data/com.cnetworks.ndk/lib/libndk_demo.so 0x435c2d20 Added shared lib /data/data/com.cnetworks.ndk/lib/libndk_demo.so 0x435c2d20 No JNI_OnLoad found in /data/data/com.cnetworks.ndk/lib/libndk_demo.so 0x435c2d20 +++ not scanning '/system/lib/libwebcore.so' for 'hello' (wrong CL) +++ not scanning '/system/lib/libmedia_jni.so' for 'hello' (wrong CL) WARN/dalvikvm(5191): No implementation found for native Lcom/cnetworks/ndk/NativeLib;.hello ()Ljava/lang/String; Here is the java code, nativeLib.hello() is causing the problem. public class NDKdemo2 extends Activity { NativeLib nativeLib; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); nativeLib = new NativeLib(); String helloText = nativeLib.hello(); // Update the UI TextView outText = (TextView) findViewById(R.id.textOut); outText.setText(helloText); } } Has anyone had the same problem before and able to tell me whats wrong?
tagged with: java
has comment: http://stackoverflow.com/comment/10533020
has comment: http://stackoverflow.com/comment/4909496
tagged with: android-ndk
type: Question
has answer: http://stackoverflow.com/a/8102421
has comment: http://stackoverflow.com/comment/10547071
tagged with: java-native-interface
score: 0
has comment: http://stackoverflow.com/comment/2616364
answer count: 1
has comment: http://stackoverflow.com/comment/2611719
has title: Android NDK jni problem
has comment: http://stackoverflow.com/comment/6376394
tagged with: android
type: AnsweredQuestion

http://stackoverflow.com/comment/2705425
type: Comment
comment on: http://stackoverflow.com/a/2685313
type: AnswerComment
has text: Well, you could loop through the elements of the array and print them then.
score: 0

http://stackoverflow.com/a/2686655
type: Answer
downvote count: 0
has body: There is no platform-independent mechanism which accomplishes this in Java. However, you can use JNI to do it. For example, Windows allows you to poll (or be notified of) network interface states using the Network Location Awareness (NLA) API.
answers question: http://stackoverflow.com/q/2686511
has comment: http://stackoverflow.com/comment/2762300
score: 2
has comment: http://stackoverflow.com/comment/2762270
upvote count: 2
has comment: http://stackoverflow.com/comment/12589096

http://stackoverflow.com/comment/2656001
has text: It's when the value of an integer becomes too large for the type to hold. For an `int` (a signed 32-bit integer), it's about two thousand million.
type: Comment
comment on: http://stackoverflow.com/a/2641268
score: 1
type: AnswerComment

http://stackoverflow.com/a/2736889
has comment: http://stackoverflow.com/comment/2772325
score: 2
accepted answer of: http://stackoverflow.com/q/2736830
has comment: http://stackoverflow.com/comment/2765336
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2736830
has body: You have to pass the Date in the format: "yyyy-MM-dd"
upvote count: 2
type: Answer

http://stackoverflow.com/comment/2633653
comment on: http://stackoverflow.com/a/2621117
type: AnswerComment
type: Comment
has text: As I understand things, not running the code is OK, as long as you prove it correct.
score: 2

http://stackoverflow.com/comment/65494730
type: QuestionComment
has text: That is 5 questions, not 1,
comment on: http://stackoverflow.com/q/2702870
score: 0
type: Comment

http://stackoverflow.com/q/2781347
has answer: http://stackoverflow.com/a/2781394
has body: So I have been trying to use the example from Tutorial and change it so it fits my program. The getColumnValue method returns the object that holds the information that is supposed to be displayed. Is this the way to go or should it rather return the actual String to be displayed. I guess not because that way I would mix the presentation with the data, which I was trying to avoid. public class IssueTableFormat implements TableFormat&lt;Appointment&gt; { public int getColumnCount() { return 6; } public String getColumnName(int column) { if(column == 0) return "Datum"; else if(column == 1) return "Uhrzeit"; else if(column == 2) return "Nummer"; else if(column == 3) return "Name"; else if(column == 4) return "letzte Aktion"; else if(column == 5) return "Kommentar"; throw new IllegalStateException(); } public Object getColumnValue(Appointment issue, int column) { if(column == 0) return issue.getDate(); else if(column == 1) return issue.getDate(); else if(column == 2) return issue.getSample(); else if(column == 3) return issue.getSample(); else if(column == 4) return issue.getHistory(); else if(column == 5) return issue.getComment(); throw new IllegalStateException(); } } The column 0 and 1 contain a GregorianCalendar object, but I want column 0 to show the date and 1 to show the time. So I know using cellRenderers can help here. This is what I tried. public class DateRenderer extends DefaultTableCellRenderer { public DateRenderer() { super(); } public void setValue(Object value) { GregorianCalendar g =(GregorianCalendar) value; value=g.get(GregorianCalendar.HOUR); } } But the cell doesnt show anything, what is wrong here?
type: UnansweredQuestion
tagged with: jtable
has answer: http://stackoverflow.com/a/2781702
type: Question
score: 0
tagged with: java
answer count: 3
has title: How to use CellRenderer for GregorianCalendar?
has answer: http://stackoverflow.com/a/2781377
tagged with: swing

http://stackoverflow.com/a/2621332
score: 10
type: AcceptedAnswer
downvote count: 0
has body: This is called a "malicious cast" and you can prevent it by having a wrapper that implements only the narrow interface you want to expose (by delegating to a private reference to the object that you would have otherwise directly passed to the evil client). However, if the client is not only evil, but powerful as well, he might be able to use reflection to get to the hidden reference anyway.
type: Answer
answers question: http://stackoverflow.com/q/2621314
has comment: http://stackoverflow.com/comment/2635861
upvote count: 10
accepted answer of: http://stackoverflow.com/q/2621314

http://stackoverflow.com/q/2734981
has body: Is there any difference between Arithmetic + and bitwise OR. In what way this is differing. uint a = 10; uint b = 20; uint arithmeticresult = a + b; uint bitwiseOR = a | b; Both the results are 30. Edit : Small changes to hide my stupidity.
downvote count: 1
answer count: 7
favorite count: 0
has answer: http://stackoverflow.com/a/2735015
has answer: http://stackoverflow.com/a/2735017
has answer: http://stackoverflow.com/a/2734995
has answer: http://stackoverflow.com/a/33824142
has answer: http://stackoverflow.com/a/2735002
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2763034
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/2734996
accepted answer: http://stackoverflow.com/a/2734996
type: Question
tagged with: c#
possible better answer: http://stackoverflow.com/a/2734992
upvote count: 2
has title: Arithmetic + and Bitwise OR
has answer: http://stackoverflow.com/a/2734992

http://stackoverflow.com/a/9172317
upvote count: 25
has body: Either make it static or if you are trying to avoid any static fields in your class - make the class itself a singleton and then you can safely use the an instance level ThreadLocal as long as you have that singleton available globally.
answers question: http://stackoverflow.com/q/2784009
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/137245768
score: 25

http://stackoverflow.com/a/2647203
upvote count: 9
type: Answer
has comment: http://stackoverflow.com/comment/2662746
accepted answer of: http://stackoverflow.com/q/2647139
answers question: http://stackoverflow.com/q/2647139
score: 9
has comment: http://stackoverflow.com/comment/2662777
has comment: http://stackoverflow.com/comment/2662807
type: AcceptedAnswer
downvote count: 0
has body: As mentioned on the mailing list, anywhere you can inject ClassWithManyDependencies you can simply inject Provider&lt;ClassWithManyDependencies&gt; instead, no need to write anything special yourself. Guice does this for you.

http://stackoverflow.com/a/2632809
has comment: http://stackoverflow.com/comment/2646405
has comment: http://stackoverflow.com/comment/135542962
type: Answer
has comment: http://stackoverflow.com/comment/41881607
has comment: http://stackoverflow.com/comment/10380474
answers question: http://stackoverflow.com/q/2632419
upvote count: 258
downvote count: 1
has comment: http://stackoverflow.com/comment/77060464
has comment: http://stackoverflow.com/comment/61516454
has comment: http://stackoverflow.com/comment/93294293
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/44944150
accepted answer of: http://stackoverflow.com/q/2632419
score: 257
has comment: http://stackoverflow.com/comment/73029592
has body: One option is to filter derived resources. In the upper right corner of the 'Open Resource' dialog there is an arrow you can click to bring up a dropdown menu for filtering. Uncheck the 'Show Derived Resources' option, if it is checked. If you still see '.class' files, they probably aren't being marked as derived. If they're by themselves in their own folder hierarchy you can fix this by right-clicking the root folder to edit folder properties, and check the 'Derived' checkbox. If they're mixed with your '.java' files...tough luck, you'll need to set the derived property on each '.class' file by hand. As far as I can tell there's no way to mark class files as derived resources globally for the workspace, but I believe when you create a new Java project the 'bin' folder is marked as derived by default (if you use the default wizard settings) Here are some screenshots from Eclipse Kepler. The first shows how to filter derived resources by unchecking 'Show Derived Resources' in the Open Resource dialog. The second shows how to set the 'Derived' property on a resource.

http://stackoverflow.com/comment/2687252
comment on: http://stackoverflow.com/a/2668793
has text: Actually, I stand corrected on part of that last comment. He is creating an extra `BigInteger` each time he adds 2 in the while loop. But that's still outside the for loop, where most of the time should be spent.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/2638767
type: AnswerComment
score: 0
has text: I don't really understand how to do that. Don't I have to have a [servlet-name]-servlet.xml in my WEB-INF/ for each servlet? How can I make all of them use the same beans?
type: Comment
comment on: http://stackoverflow.com/a/2612341

http://stackoverflow.com/a/2702054
type: Answer
has comment: http://stackoverflow.com/comment/2741476
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/2701817
has body: If you're trying to do a tree of checkboxes (which is a common reason to need a tri state checkbox), check out Jide Commons.
upvote count: 2
has comment: http://stackoverflow.com/comment/2725272
has comment: http://stackoverflow.com/comment/2725158

http://stackoverflow.com/a/2600486
has body: You've got a couple of issues here. First and foremost, Always initialize your JFrame from the Swing EDT as such: public static void main(String[] a) { SwingUtilities.invokeLater(new Runnable() { public void run() { Trial trial = new Trial(); trial.setSize(300, 300); trial.setDefaultCloseOperation(Trial.EXIT_ON_CLOSE); trial.create(); } }); } Failure to do so will lead to subtle errors. Second: JTables like to exist within JScrollPanes. That's why you don't see the column headers: JScrollPane pane = new JScrollPane(); pane.setViewportView(table); jp.add(pane); With the above done, I see your tiny little columns, each 20 pixels wide.
score: 3
upvote count: 3
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2600360

http://stackoverflow.com/comment/58296193
comment on: http://stackoverflow.com/a/2683299
type: AnswerComment
has text: Also doesn't work with Postgres or DB2.
type: Comment
score: 4

http://stackoverflow.com/a/15198125
upvote count: 1
accepted answer of: http://stackoverflow.com/q/2641775
answers question: http://stackoverflow.com/q/2641775
score: 1
has body: You can try DoctypeChanger which modifies the raw stream as you suggested: DoctypeChanger is a Java class that lets you add, modify or remove a DOCTYPE declaration from a byte stream as it is fed into an XML parser. InputStream in = ... // get your XML InputStream DOCTYPEChangerStream changer = new DOCTYPEChangerStream(in); changer.setGenerator( new DoctypeGenerator() { public Doctype generate(Doctype old) { return new DoctypeImpl("rootElement", "pubId", "sysId", "internalSubset"); } } ); // .. and pass it on to the parser.
type: AcceptedAnswer
downvote count: 0
type: Answer

http://stackoverflow.com/comment/13376974
has text: The longest solution so far. Would you mind explaining what the difference is to other solution, why you think your solution, 2 years later, is that important?
comment on: http://stackoverflow.com/a/10373712
score: 1
type: AnswerComment
type: Comment

http://stackoverflow.com/a/2777552
has body: You can easily subclass JLabel and override the whole public void paint(Graphics g) with something like: public void paint(Graphics g) { Graphics2D g2 = (Graphics2D)g; // antialiasing, just because it's nicer g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.drawRect(..); // or instead g2.drawImage(..); // if you really want a border as an image g2.drawImage(..); // to draw the symbol in the middle } Otherwise you can set a border to the JLabel with the BorderFactory (mind about spacings between grid cells) and set just the image in the middle. To layout elements use a GridLayout, they'll arrange them in a grid, forcing same sizes.
score: 0
answers question: http://stackoverflow.com/q/2777477
has comment: http://stackoverflow.com/comment/2812247
type: Answer

grouplayout
type: Tag
tags question: http://stackoverflow.com/q/2670360
tag name: grouplayout

http://stackoverflow.com/comment/2730068
comment on: http://stackoverflow.com/a/2706073
type: AnswerComment
has text: +1 for the creative, though slow solution :-).
type: Comment
score: 1

http://stackoverflow.com/a/2770805
type: AcceptedAnswer
downvote count: 0
upvote count: 2
type: Answer
has body: I'm not aware of any ready to use open source libraries that implement the sort of clustering on demand of named entities provided by Google Sets. However, there are a few academic papers that describe in detail how to build similar systems, e.g.: Language-Independent Set Expansion of Named Entities using the Web Wang and Cohen, in EMNLP 2009 Online Demo Bayesian Sets Ghahramani and Heller, in NIPS, 2005 Below is a brief summary of Wang and Cohen's method. If you do end up implementing something like this yourself, it might be good to start with their method. I suspect most people will find it more intuitive than Ghahramani and Heller's formulation. Wang and Cohen 2009 Wang and Cohen start by describing a method for automatically constructing extraction patterns that allow them to find lists of named entities in any sort of structured document. The method looks at the prefixes and suffixes bracketing known occurrences of named entities. These prefix and suffixes are then used to identify other named entities within the same document. To complete a clusters of entities, they build a graph consisting of the interconnections between named entities, the extraction patterns associated with them, and the documents. Using this graph and starting at the nodes for the cluster's seed entities (i.e., the initial set of entities in the set to be completed), they perform numerous random walks on the graph up to 10 steps in length. They count how many times they reach the nodes corresponding to non-seed entities. Non-seed entities with high counts can then be used to complete the cluster.
score: 2
accepted answer of: http://stackoverflow.com/q/2761678
answers question: http://stackoverflow.com/q/2761678
has comment: http://stackoverflow.com/comment/2812701

http://stackoverflow.com/a/2656667
downvote count: 0
type: Answer
has body: An useful table to work out with various graphs implementations: OPERATION EDGE LIST ADJ LIST ADJ MATRIX degree(v) O(m) O(d(v)) O(n) incidentEdges(v) O(m) O(d(v)) O(n) areAdjacent(v1,v2) O(m) O(min(d(v1),d(v2)) O(1) addVertex(v) O(1) O(1) O(n²) addEdge(v) O(1) O(1) O(1) removeVertex(v) O(m) O(m) O(n²) removeEdge(e) O(m) O(d(v1)+d(v2)) O(1) memory O(m+n) O(m+n) O(n²) where m is the number of edges, n is the number of vertices and d(vertex) is the number of elements in the vertex adjacency list.. adj matrix implementation has an O(n²) to add and remove vertices because you have to reallocate the matrix.. Just prepared this for an article, that why I have it ready :) This is not directly related to benchmarking, since usually you study which operations you will mostly need and choose the right implementation for your needs, so it's a sort of "theoretical" benchmark that you do by studying what you are going to implement. Otherwise you can just measure time that your code needs to do the whole work with both implementations and compare it. EDIT: since you use a sparse matrix implementation the complexity of operations could slightly change (mostly getting a little worse, since you are trading memory for speed). EDIT2: ok, now that I know that this is Java it will be fair simple: long before = System.nanoTime(); /* execution of your algorithm */ long elapsed = System.nanoTime() - before; Answer is in nanoseconds and accuracy is not guaranteed, so use this thing carefully. Doing an average of many runs (and checking that variance is low, discarding the result that are more distant from the average) will give coherence to your results.
has comment: http://stackoverflow.com/comment/2673523
has comment: http://stackoverflow.com/comment/2692538
upvote count: 10
accepted answer of: http://stackoverflow.com/q/2656641
answers question: http://stackoverflow.com/q/2656641
score: 10
type: AcceptedAnswer

http://stackoverflow.com/q/2780442
tagged with: windows
has comment: http://stackoverflow.com/comment/2815264
has body: I am running my java application. It shows up in the process tab of the task manager. I dont want users to kill that process? And if possible i dont want my process to be in the process list also. My application is a LAN administrator. I need to log client machines. If its possible for the user to kill my process there is no use in creating such an application.
has comment: http://stackoverflow.com/comment/2815262
has comment: http://stackoverflow.com/comment/2815303
tagged with: java
tagged with: process
answer count: 3
upvote count: 1
has comment: http://stackoverflow.com/comment/2815388
accepted answer: http://stackoverflow.com/a/2780468
score: -7
has answer: http://stackoverflow.com/a/2780448
has comment: http://stackoverflow.com/comment/2815310
has title: How to create a process that cannot be killed?
has comment: http://stackoverflow.com/comment/2816022
has comment: http://stackoverflow.com/comment/2815405
has comment: http://stackoverflow.com/comment/2815499
has comment: http://stackoverflow.com/comment/2815289
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2780526
favorite count: 0
has answer: http://stackoverflow.com/a/2780526
has answer: http://stackoverflow.com/a/2780468
type: Question
downvote count: 8

http://stackoverflow.com/a/2740196
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/2768887
has comment: http://stackoverflow.com/comment/2768921
has body: Yo can use the split method to separate the names into a String array, considering that they are separed by a space. For example, lets consider a name: String name = "Mario Freitas"; String[] array = name.split(" "); // the parameter is the string separator. In this case, is the space for(String s : array){ System.out.println(s); } this code will print each name in a different line (as the String was separated) Then you can compare the first and last name separated, using the equals method. Let's suppose you have 2 array of Strings, obtained by split method and each one with one different Person name. public void compare names(String name1, String name2){ String array1[] = name1.split(" "); String array2[] = name2.split(" "); if(array1[0].equals(array2[0])){ System.out.println("First names are equal"); } if(array1[1].equals(array2[1])){ System.out.println("Second names are equal"); } }
downvote count: 0
answers question: http://stackoverflow.com/q/2740136
type: Answer

http://stackoverflow.com/comment/2729911
has text: Learning the answer to this question could fill an entire semester.
comment on: http://stackoverflow.com/q/2706256
type: Comment
type: QuestionComment
score: 2

http://stackoverflow.com/comment/2665405
has text: where did you get a 140 000 x 125 000 jpg from? What software/system created that? That is 17.5 **billions** pixels. At 32 bits / pixel that beast would need 69 GB of memory uncompressed. What is that picture's size once compressed to JPG? How did you *transfer* it? Can ImageMagick simply, say, *convert* it? Anyway, if you plan to manipulate such a gigantic amount of data from a Java applet you're in for a world of hurt.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2649048
score: 1

http://stackoverflow.com/comment/2716712
comment on: http://stackoverflow.com/q/2694529
score: 1
type: Comment
type: QuestionComment
has text: You start with "I work for a company who has openly adopted agile practices for development in recent years" and then follow with "The business haven't fully bought in these tools and aren't particularly keen on maintaining the scripts all the time". Maybe you want to reconsider why you need automated acceptance tests.

http://stackoverflow.com/comment/2813769
type: Comment
comment on: http://stackoverflow.com/a/2778757
has text: Thanks .. it worked. I had to create a new inner class implementing the Runnable interface and passed the JComboBox instance to the constructor of the inner class because the box object in the run() would be out of scope within the fetchItems() function.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/13553598
type: Comment
comment on: http://stackoverflow.com/a/2698383
has text: Since all it appears that the 'JSONParam' does is wrap the 'DataTransferObject' and use a String based constructor... would it be possible to just add a String based constructor to the 'DataTransferObject'?
score: 5
type: AnswerComment

http://stackoverflow.com/comment/18724097
score: 0
type: Comment
has text: I have a better solution @Ridduel do you want to try that too?
comment on: http://stackoverflow.com/a/2651695
type: AnswerComment

http://stackoverflow.com/comment/2739533
type: AnswerComment
type: Comment
has text: @BalusC - I have been pouring over JSF info and I am still not understanding how the model object is null on form submit. From what I understand, the JSF Lifecycle should automatically update model values during the update model values portion of the lifecycle. I shouldn't have to do any manual plumbing... When I click the submit button it should automatically load the data in the form into my model entity...
comment on: http://stackoverflow.com/a/2699600
score: 0

http://stackoverflow.com/a/65425971
score: 7
has comment: http://stackoverflow.com/comment/117568764
upvote count: 7
has comment: http://stackoverflow.com/comment/117568163
has body: to open maps app which is in HUAWEI devices which contains HMS: const val GOOGLE_MAPS_APP = "com.google.android.apps.maps" const val HUAWEI_MAPS_APP = "com.huawei.maps.app" fun openMap(lat:Double,lon:Double) { val packName = if (isHmsOnly(context)) { HUAWEI_MAPS_APP } else { GOOGLE_MAPS_APP } val uri = Uri.parse("geo:$lat,$lon?q=$lat,$lon") val intent = Intent(Intent.ACTION_VIEW, uri) intent.setPackage(packName); if (intent.resolveActivity(context.packageManager) != null) { context.startActivity(intent) } else { openMapOptions(lat, lon) } } private fun openMapOptions(lat: Double, lon: Double) { val intent = Intent( Intent.ACTION_VIEW, Uri.parse("geo:$lat,$lon?q=$lat,$lon") ) context.startActivity(intent) } HMS checks: private fun isHmsAvailable(context: Context?): Boolean { var isAvailable = false if (null != context) { val result = HuaweiApiAvailability.getInstance().isHuaweiMobileServicesAvailable(context) isAvailable = ConnectionResult.SUCCESS == result } return isAvailable} private fun isGmsAvailable(context: Context?): Boolean { var isAvailable = false if (null != context) { val result: Int = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context) isAvailable = com.google.android.gms.common.ConnectionResult.SUCCESS == result } return isAvailable } fun isHmsOnly(context: Context?) = isHmsAvailable(context) && !isGmsAvailable(context)
downvote count: 0
answers question: http://stackoverflow.com/q/2662531
type: Answer

http://stackoverflow.com/comment/2814398
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2778045
has text: Use ProgressBar instead of ProgessMonitor.

http://stackoverflow.com/a/2700665
accepted answer of: http://stackoverflow.com/q/2698444
answers question: http://stackoverflow.com/q/2698444
type: Answer
score: 1
upvote count: 1
has body: The list of standard contact field and attributes you can use can be found at Forum Nokia (since you're using a Symbian phone). The JSR-75 specification doesn't really prevent handset manufacturers from adding more fields and attributes but you may need to write code to discover what is possible with your handset. I would suggest filling a contact with as much information as you can using the handset embedded native Contact application first. The useful methods for field and attribute discovery are: PIMList.getArrayElementLabel() PIMList.getAttributeLabel() PIMList.getFieldLabel() PIMList.getSupportedArrayElements() PIMList.getSupportedAttributes() PIMList.getArrayElementLabel() PIMList.getArrayElementLabel() PIMList.getSupportedFields()
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/90512008
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/24363584
score: 0
has text: `Can you access a private constructor of a class and instantiate it?` Yes, using reflection. End of useless question that didn’t add any value.

persistence
tags question: http://stackoverflow.com/q/2606937
tags question: http://stackoverflow.com/q/2776942
tags question: http://stackoverflow.com/q/2598380
tags question: http://stackoverflow.com/q/2682194
tags question: http://stackoverflow.com/q/2603883
tags question: http://stackoverflow.com/q/2779857
tag name: persistence
tags question: http://stackoverflow.com/q/2701565
tags question: http://stackoverflow.com/q/2774757
type: Tag
tags question: http://stackoverflow.com/q/2598588
tags question: http://stackoverflow.com/q/2649298
tags question: http://stackoverflow.com/q/2773302
tags question: http://stackoverflow.com/q/2678423
tags question: http://stackoverflow.com/q/2687121
tags question: http://stackoverflow.com/q/2689811
tags question: http://stackoverflow.com/q/2681619
tags question: http://stackoverflow.com/q/2686863

http://stackoverflow.com/q/2756993
tagged with: java
has title: Java - Thread - Problem in one of the Sun's tutorial
type: Question
answer count: 2
score: 2
downvote count: 0
has answer: http://stackoverflow.com/a/21573291
has comment: http://stackoverflow.com/comment/2788678
has comment: http://stackoverflow.com/comment/2788464
has answer: http://stackoverflow.com/a/2757068
possible better answer: http://stackoverflow.com/a/21573291
favorite count: 0
upvote count: 2
has body: I was reading this Sun's tutorial on Thread. I found a block of code there which I think can be replaced by a code of fewer lines. I wonder why Sun's expert programmers followed that long way when the task can be accomplished with a code of fewer lines. I am asking this question so as to know that if I am missing something that the tutorial wants to convey. The block of code is as follows: t.start(); threadMessage("Waiting for MessageLoop thread to finish"); //loop until MessageLoop thread exits while (t.isAlive()) { threadMessage("Still waiting..."); //Wait maximum of 1 second for MessageLoop thread to //finish. t.join(1000); if (((System.currentTimeMillis() - startTime) &gt; patience) &amp;&amp; t.isAlive()) { threadMessage("Tired of waiting!"); t.interrupt(); //Shouldn't be long now -- wait indefinitely t.join(); } } threadMessage("Finally!"); I think that the above code can be replaced by the following: t.start(); t.join(patience); // InterruptedException is thrown by the main method so no need to handle it if(t.isAlive()) { // t's thread couldn't finish in the patience time threadMessage("Tired of waiting!"); t.interrupt(); t.join(); } threadMessage("Finally!");
tagged with: multithreading
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2757068
has comment: http://stackoverflow.com/comment/2788479
tagged with: join

http://stackoverflow.com/comment/37797121
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/23565452
type: Comment
has text: agree it has space overhead; it's another approach to solve this problem. The obvious approach is tortoise and harse algorithm.

http://stackoverflow.com/comment/60884699
comment on: http://stackoverflow.com/a/4415097
type: Comment
has text: The link is broken. Can someone fix it?
score: 0
type: AnswerComment

http://stackoverflow.com/q/2753769
tagged with: java
has comment: http://stackoverflow.com/comment/2784753
type: Question
score: 0
has comment: http://stackoverflow.com/comment/2784649
has answer: http://stackoverflow.com/a/2753822
accepted answer: http://stackoverflow.com/a/2753822
tagged with: .net
tagged with: amazon-ec2
answer count: 1
has title: Amazon EC2 Development Stack
has comment: http://stackoverflow.com/comment/2784841
tagged with: c#
type: AnsweredQuestion
has body: I want to use EC2 for some reasons and EC2 provides both windows and linux deployments, but linux is much cheaper (linux reserved instances are approx. %63-%85 price of windows ones and spot instances are %50 cheaper for linux). I need a type safe lang and mainstream platform and I prefer to use .net/c# stack (but not mono for some reasons), but in this situation java seems a better fit for the future (when ec2 instance counts begin to increase). So, is it worth to use .net ? best regards,

http://stackoverflow.com/a/2699806
type: Answer
answers question: http://stackoverflow.com/q/2699788
has body: If obj is a subclass of Event then it is an instanceof. obj is an instanceof every class/interface that it derives from. So at the very least all objects are instances of Object.
score: 0

http://stackoverflow.com/q/2752174
tagged with: imagej
has answer: http://stackoverflow.com/a/3118419
upvote count: 3
answer count: 1
tagged with: image-manipulation
favorite count: 0
tagged with: clojure
type: AnsweredQuestion
downvote count: 0
tagged with: java
has body: I want to use ImageJ to do some processing of several thousand images. Is there a way to take any general imageJ plugin and apply it to hundreds of images automatically? For example, say I want to take my thousand images and apply a polar transformation to each--- A polar transformation plugin for ImageJ can be found here: http://rsbweb.nih.gov/ij/plugins/polar-transformer.html Great! Let's use it. From: http://albert.rierol.net/imagej_programming_tutorials.html#How%20to%20automate%20an%20ImageJ%20dialog I find that I can apply a plugin using the following: (defn x-polar [imageP] (let [thread (Thread/currentThread) options ""] (.setName thread "Run$_polar-transform") (Macro/setOptions thread options) (IJ/runPlugIn imageP "Polar_Transformer" ""))) This is good because it suppresses the dialog which would otherwise pop up for every image. But running this always brings up a window containing the transformed image, when what I want is to simply return the transformed image. The stupidest way to do what I want is to just close the window that comes up and return the image which it was displaying. Does what I want but is absolutely retarded: (defn x-polar [imageP] (let [thread (Thread/currentThread) options ""] (.setName thread "Run$_polar-transform") (Macro/setOptions thread options) (IJ/runPlugIn imageP "Polar_Transformer" "") (let [return-image (IJ/getImage)] (.hide return-image) return-image))) I'm obviously missing something about how to use imageJ plugins in a programming context. Does anyone know the right way to do this? Thanks, --Robert McIntyre
tagged with: image-processing
has title: How can I do batch image processing with ImageJ in Java or clojure?
accepted answer: http://stackoverflow.com/a/3118419
type: Question
score: 3

http://stackoverflow.com/a/2722023
answers question: http://stackoverflow.com/q/2721998
has comment: http://stackoverflow.com/comment/2748244
downvote count: 4
has comment: http://stackoverflow.com/comment/2748940
has comment: http://stackoverflow.com/comment/2748348
has comment: http://stackoverflow.com/comment/2748442
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2748229
has comment: http://stackoverflow.com/comment/2748289
has comment: http://stackoverflow.com/comment/2748928
has body: No. It's not the same using StringBuilder than doing "a" + "b". In Java, String instances are immutable. So, if you do: String c = "a" + "b"; You are creating new Strings every time you concatenate. On the other hand, StringBuilder is like a buffer that can grow as it needs when appending new Strings. StringBuilder c = new StringBuilder(); c.append("a"); c.append("b"); // c is only created once and appended "a" and "b". Rule of the thumb is (changed thanks to the comments I got): If you are going to concatenate a lot (i.e., concatenate inside a loop, or generating a big XML formed by several string concatenated variables), do use StringBuilder. Otherwise, simple concatenation (using + operator) will be just fine. Compiler optimizations also play a huge role when compiling this kind of code. Here'sfurther explanation on the topic. And more StackOVerflow questions on the issue: Is it better to reuse a StringBuilder in a loop? What&#39;s the best way to build a string of delimited items in Java? StringBuilder vs String concatenation in toString() in Java
has comment: http://stackoverflow.com/comment/2748300
upvote count: 18
type: Answer
has comment: http://stackoverflow.com/comment/2748326
score: 14
accepted answer of: http://stackoverflow.com/q/2721998

file
type: Tag
tags question: http://stackoverflow.com/q/2743741
tags question: http://stackoverflow.com/q/2765782
tags question: http://stackoverflow.com/q/2785467
tags question: http://stackoverflow.com/q/2662958
tags question: http://stackoverflow.com/q/2704151
tag name: file
tags question: http://stackoverflow.com/q/2744962
tags question: http://stackoverflow.com/q/2610033
tags question: http://stackoverflow.com/q/2680993
tags question: http://stackoverflow.com/q/2709316
tags question: http://stackoverflow.com/q/2633115
tags question: http://stackoverflow.com/q/2659525
tags question: http://stackoverflow.com/q/2623882
tags question: http://stackoverflow.com/q/2715068
tags question: http://stackoverflow.com/q/2782638
tags question: http://stackoverflow.com/q/2744704
tags question: http://stackoverflow.com/q/2774963
tags question: http://stackoverflow.com/q/2690614
tags question: http://stackoverflow.com/q/2761188
tags question: http://stackoverflow.com/q/2717667
tags question: http://stackoverflow.com/q/2729038
tags question: http://stackoverflow.com/q/2622206
tags question: http://stackoverflow.com/q/2633830
tags question: http://stackoverflow.com/q/2677786
tags question: http://stackoverflow.com/q/2712011
tags question: http://stackoverflow.com/q/2701208
tags question: http://stackoverflow.com/q/2698532
tags question: http://stackoverflow.com/q/2725080
tags question: http://stackoverflow.com/q/2674853
tags question: http://stackoverflow.com/q/2696450
tags question: http://stackoverflow.com/q/2766083
tags question: http://stackoverflow.com/q/2725897
tags question: http://stackoverflow.com/q/2618252
tags question: http://stackoverflow.com/q/2682194
tags question: http://stackoverflow.com/q/2692516
tags question: http://stackoverflow.com/q/2777314
tags question: http://stackoverflow.com/q/2702272
tags question: http://stackoverflow.com/q/2730796
tags question: http://stackoverflow.com/q/2613542
tags question: http://stackoverflow.com/q/2701272
tags question: http://stackoverflow.com/q/2597710
tags question: http://stackoverflow.com/q/2622062
tags question: http://stackoverflow.com/q/2778152

http://stackoverflow.com/comment/2624502
type: Comment
has text: Hi Thorbjørn, I'm just curious, but what exactly is the difference between MIT license and Apache license?
type: AnswerComment
comment on: http://stackoverflow.com/a/2613477
score: 0

http://stackoverflow.com/a/2712678
has comment: http://stackoverflow.com/comment/101254213
answers question: http://stackoverflow.com/q/2712618
score: 0
has comment: http://stackoverflow.com/comment/2737792
has body: For Oracle: jdbc:oracle:&lt;drivertype&gt;:&lt;username/password&gt;@&lt;database&gt; The &lt;drivertype&gt; is one of thin oci kprb The &lt;database&gt; description somewhat depends on the driver type. If the driver type is kprb, then the &lt;database&gt; description is empty. If the driver type is oci and you wish to use a bequeath connection, then the &lt;database&gt; is empty. Otherwise (thin or oci driver and not bequeath) the database description is one of the following: //&lt;host&gt;:&lt;port&gt;/&lt;service&gt; &lt;host&gt;:&lt;port&gt;:&lt;SID&gt; &lt;TNSName&gt; Example: jdbc:oracle:oci:@myhost:1521:inst1 See Oracle JDBC FAQ for more details.
type: Answer

http://stackoverflow.com/q/2714588
favorite count: 0
tagged with: xjc
has comment: http://stackoverflow.com/comment/2742605
has comment: http://stackoverflow.com/comment/2742231
has body: I am currently trying to compile with JAXB (IBM build 2.1.3) a pair of schema files into the same package. Each will compile on it's own, but when trying to compile them together i get a element naming conflict due to includes. My question is; is there a way to specify with an external binding a resolution to the naming collision. Example files follow. In the example the offending element is called "Common", which is defined in both incA and incB: incA.xsd <?xml version="1.0" encoding="UTF-8"?> incB.xsd <?xml version="1.0" encoding="UTF-8"?> A.xsd <?xml version="1.0" encoding="UTF-8"?> B.xsd <?xml version="1.0" encoding="UTF-8"?> Compiler error when both are compiled from one evocation of xjb: [ERROR] 'Common' is already defined line 9 of file:/C:/temp/incB.xsd [ERROR] (related to above error) the first definition appears here line 9 of file:/C:/temp/incA.xsd (For reference, this is a generalization to resolve an issue with compiling the OAGIS8 SP3 package)
type: AnsweredQuestion
downvote count: 0
type: Question
score: 3
tagged with: java
tagged with: jaxb
has answer: http://stackoverflow.com/a/2774979
accepted answer: http://stackoverflow.com/a/2774979
upvote count: 3
answer count: 1
has title: Resolve naming conflict in included XSDs for JAXB compilation

http://stackoverflow.com/q/2683592
has title: RegEx Advanced : Positive lookbehind
score: 5
answer count: 3
downvote count: 0
favorite count: 0
has body: This is my test-string: &lt;img rel="{objectid:498,newobject:1,fileid:338}" width="80" height="60" align="left" src="../../../../files/jpg1/Desert1.jpg" alt="" /&gt; I want to get each of the JSON formed Elements inbetween the rel attribute. It's working for the first element (objectid). Here is my ReqEx, which works fine: (?&lt;=(rel="\{objectid:))\d+(?=[,|\}]) But i want to do somthing like this, which doesn't work: (?&lt;=(rel="\{.*objectid:))\d+(?=[,|\}]) So i can parse every element of the search string. I'm using Java-ReqEx
tagged with: regex
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2683616
upvote count: 5
tagged with: java
tagged with: lookbehind
has answer: http://stackoverflow.com/a/2684073
type: Question
has answer: http://stackoverflow.com/a/2683625

http://stackoverflow.com/a/2761386
has body: Use log4j. This will allow you to do something like: if (log.isLoggingEnabled()) { log.debug("this will be printed at runtime with debugging enabled"); } You can then configure your application not to print debug statements after you submit your code (this is generally done in either a .properties file or an XML file). using a logger is a very common practice on websites running with Java and there is quite a bit of documentation on log4j in particular out there. In fact, submitting code with System.out lines for debugging is considered bad form in most circles. Think of the person reading the logfiles! There is a TINY hit to performance to the extra method invocation using the logger, but doing this will make maintainability much more practical. You'd probably impress your instructor too :)
downvote count: 0
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/2761068
type: Answer

http://stackoverflow.com/a/2636347
downvote count: 0
has body: Thirler has explained why this doesn't work. However, you can use Arrays.fill to help you initialize the arrays: char[][] array = new char[10][10]; for (char[] row : array) Arrays.fill(row, '~');
type: Answer
upvote count: 13
answers question: http://stackoverflow.com/q/2636222
score: 13

http://stackoverflow.com/q/2641644
has body: I'm creating an editor for Eclipse. Right now the editor fires up with the user creates a new file with the appropriate extension. My question is, how can I get a reference to the project in which the file resides? For example, say I have a workspace with 2 projects, P1 and P2. I right click P2 and create a new file, can I get a reference to P2 from this somehow? Ultimately I need to reference the AST or Java Model of the project but even a String identifying the project would work.
upvote count: 3
accepted answer: http://stackoverflow.com/a/2642958
has title: How do I get a reference to the current project in an Eclipse plugin?
type: Question
linked to: http://stackoverflow.com/q/1206095
type: AnsweredQuestion
score: 3
has comment: http://stackoverflow.com/comment/2657620
tagged with: java
tagged with: eclipse
answer count: 1
downvote count: 0
tagged with: eclipse-plugin
favorite count: 0
has answer: http://stackoverflow.com/a/2642958

http://stackoverflow.com/q/2601201
score: 0
answer count: 1
has comment: http://stackoverflow.com/comment/2610388
type: UnansweredQuestion
tagged with: annotations
tagged with: java
tagged with: vaadin
type: Question
has answer: http://stackoverflow.com/a/2605409
tagged with: jar
has title: java annotations - problem with calling a locator class from a Vaadin Project
has body: I'm not sure how to explain this without writing several pages so I hope the actual code is more expressive. I've made a jar containing multiple annotation declaration similar to the following: @Target(ElementType.PACKAGE) @Retention(RetentionPolicy.RUNTIME) public @interface MarkedPackage { } then I have made a test jar containing several classes in several packages and marked just one package with the above annotation (with package-info.java) like below: @myPackage.MarkedPackage package package.test.jar; this jar had in its build path the jar containing the annotations. then I made a static class that has a method (LoadPlugins) that retrieves a list with all the jars of a directory. Then it searches through the jars for the 'package-info' class and checks if that classes package contains the MarkedPackage annotation. by calling this: if (checkPackageAnnotation(thisClass.getPackage())) where thisClass is the package-info class retrieved via a classloader. and: public static boolean checkPackageAnnotation(AnnotatedElement elem) { System.out.println(elem.getAnnotations().length); if (elem == null || !elem.isAnnotationPresent(MarkedPackage.class)) return false; return true; } the elem.getAnnotatios().length is there for debug purposes. And the problem appears when I call the method from the static class: if I call it from a main function: public class MyMain { public static void main(String[] args){ PluginUtils.LoadPlugins(); } } everything works perfectly it displays '1' from that System.out.println(elem.getAnnotations().length); But if I call it from a button from my Vaadin project: header.addComponent(new Button("CallThat", new Button.ClickListener() { public void buttonClick(ClickEvent event) { PluginUtils.LoadPlugins(); } })); It displays '0' from that System.out.println(elem.getAnnotations().length); Also I should mention that I created the main inside my Vaadin project so it would have the exact same build path and resources. Is there a problem with web applica…

http://stackoverflow.com/comment/2790818
comment on: http://stackoverflow.com/a/2759040
score: 0
type: AnswerComment
type: Comment
has text: Understandable, however, if you have the task at 5 hours then your thread will park for (5, TimeUnit.HOURS). Since its parked there would be no switching until it is unparked and the interruption will occur then.

http://stackoverflow.com/a/2631577
has body: I suggest rereading the stream from the start with a new InputStreamReader. Perhaps assume that InputStream.mark is supported.
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/2631507
score: 1
upvote count: 1

http://stackoverflow.com/a/73599648
has body: Here is my way of reversing a file, without using memory. import java.io.*; import java.nio.charset.StandardCharsets; public static void createReverseFile(String filePathToBeReversed) { String fileName = filePathToBeReversed.split("/")[filePathToBeReversed.split("/").length - 1]; try { File reversedFile = new File(filePathToBeReversed.substring(0, filePathToBeReversed.lastIndexOf("/") + 1) + "reverse" + fileName.substring(0, 1).toUpperCase() + fileName.substring(1)); reversedFile.delete(); reversedFile.createNewFile(); RandomAccessFile raf = new RandomAccessFile(reversedFile, "rw"); long rafPointer = new File(filePathToBeReversed).length(); BufferedReader br = new BufferedReader(new FileReader(filePathToBeReversed)); int lineCount = 0; for (String line;(line = br.readLine()) != null;) { System.out.println("Reversing line " + lineCount++); line += "\r\n"; raf.seek(rafPointer -= line.length()); System.out.println(rafPointer); raf.write(line.getBytes(StandardCharsets.UTF_8), 0, line.length()); } raf.close(); br.close(); } catch (IOException e) { throw new RuntimeException(e); } }
downvote count: 0
answers question: http://stackoverflow.com/q/2725897
score: 1
type: Answer
upvote count: 1

http://stackoverflow.com/comment/2626603
has text: @Finbarr: I think your confusing initialization with instantiation
type: AnswerComment
score: 2
comment on: http://stackoverflow.com/a/2614080
type: Comment

http://stackoverflow.com/comment/5527606
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2940939
has text: I should've clarified that blocking is not an option in my case. When there's no more data available for reading (at present invocation) the parser should treat it like normal situation and provide me with whatever it parsed from the partial data.

http://stackoverflow.com/comment/2737771
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2712897
has text: Yes, a loop as you provided in your answer is a better solution. My answer basically answers the question.

http://stackoverflow.com/a/2633542
upvote count: 10
type: AcceptedAnswer
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/2647357
has body: Yes. The actual instance of the object is still the returned LinkedHashMap, therefore it will have its iterating order. However, I wouldn't depend on this for anything. Why are you using HashMaps if iterating order is important? This might be a code smell.
accepted answer of: http://stackoverflow.com/q/2633524
score: 10
answers question: http://stackoverflow.com/q/2633524

http://stackoverflow.com/a/2673509
score: 1
upvote count: 1
downvote count: 0
answers question: http://stackoverflow.com/q/2673398
has body: The array size is never reduced automatically. It's very rare to actually have a list that is first filled with a large number of elements, then have it emptied but still kept around. And keep in mind that there must have been enough memory to hold the list (which consists only of references) and its elements - unlikely then that the memory consumed by the empty list would be a problem. If you really encounter an algorithm bizarre enough that this becomes a problem, you can still free the memory by calling trimToSize() manually.
type: Answer

http://stackoverflow.com/comment/2622843
type: AnswerComment
score: 0
type: Comment
has text: Then add a line which displays the message and waits until the user clicks OK or so. How to do this exactly depends on the UI technology you're using. I bet that it's Swing. If true, then put `JOptionPane.showMessageDialog(null, "Some message");` in `catch` block.
comment on: http://stackoverflow.com/a/2612094

http://stackoverflow.com/a/2762584
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2797585
type: Answer
downvote count: 0
score: 1
accepted answer of: http://stackoverflow.com/q/2761928
answers question: http://stackoverflow.com/q/2761928
has body: It's difficult to say more without seeing some code and/or examples of how your SWF files are being "corrupted". To answer your question directly, I can't think of any difference in principle between the zip library on the two platforms. But some things to think about: things that could be different include the default character encoding (are you somewhere converting a string to bytes, which under Linux accidentally puts illegal characters into the file) -- though I admit that off the top of my head, I can't just think where this would be in your particular scenario what other libraries are you relying on? get some logging into your servlet and see what the actual file data looks like at the various stages through the process... in a similar vein, can you elaborate on the way in which the file is "corrupted"-- what error messages do you get, if any? when you compare a "good" file and a "corrupted" file in your hex editor, what difference is there?
upvote count: 1

http://stackoverflow.com/q/2608944
answer count: 2
has comment: http://stackoverflow.com/comment/2619354
tagged with: neural-network
favorite count: 0
has answer: http://stackoverflow.com/a/2609010
possible better answer: http://stackoverflow.com/a/18163851
has comment: http://stackoverflow.com/comment/2619322
has answer: http://stackoverflow.com/a/18163851
has comment: http://stackoverflow.com/comment/2685911
tagged with: artificial-intelligence
type: AnsweredQuestion
has title: Simple explanation on artificial neural networks?
has body: I've Googled, StackOverflowed, everything, and I cannot seem to find a tutorial I can understand. I understand the concept of genetic algorithms, and how to implement them, (Though I haven't tried) but I cannot grasp the concept of neural networks. I know vaguely how they work... And that's about it. Could someone give an explanation that can help someone who has not even graduated middle school yet?
has comment: http://stackoverflow.com/comment/2619572
accepted answer: http://stackoverflow.com/a/2609010
downvote count: 1
type: Question
upvote count: 5
tagged with: java
score: 4

http://stackoverflow.com/comment/2786248
has text: No, I'm sorry, I'm not following you at all.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2754065

http://stackoverflow.com/q/2635082
downvote count: 0
linked to: http://stackoverflow.com/q/4304928
favorite count: 0
accepted answer: http://stackoverflow.com/a/2635094
has comment: http://stackoverflow.com/comment/2651113
has body: I have a large text file I am reading from and I need to find out how many times some words come up. For example, the word the. I'm doing this line by line each line is a string. I need to make sure that I only count legit the's--the the in other would not count. This means I know I need to use regular expressions in some way. What I was trying so far is this: numSpace += line.split("[^a-z]the[^a-z]").length; I realize the regular expression may not be correct at the moment but I tried without that and just tried to find occurrences of the word the and I get wrong numbers too. I was under the impression this would split the string up into an array and how many times that array was split up was how many times the word is in the string. Any ideas I would be grateful. Update: Given some ideas, I've come up with this: numThe += line.split("[^a-zA-Z][Tt]he[^a-zA-Z]", -1).length - 1; Though still getting some strange numbers. I was able to get an accurate general count (without the regular expression), now my issue is with the regexp.
tagged with: regex
has comment: http://stackoverflow.com/comment/13376961
has title: Java Counting # of occurrences of a word in a string
has answer: http://stackoverflow.com/a/10373712
has answer: http://stackoverflow.com/a/2635090
has answer: http://stackoverflow.com/a/2635241
has answer: http://stackoverflow.com/a/2636026
type: Question
answer count: 8
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2635092
has answer: http://stackoverflow.com/a/2635094
upvote count: 5
tagged with: java
possible better answer: http://stackoverflow.com/a/21955863
has answer: http://stackoverflow.com/a/21955863
has answer: http://stackoverflow.com/a/2635096
score: 5

http://stackoverflow.com/a/2696765
answers question: http://stackoverflow.com/q/2603778
downvote count: 0
upvote count: 13
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2603778
type: Answer
has comment: http://stackoverflow.com/comment/11104631
score: 13
has body: Regarding ekeren's solution above, it's not a good idea to use PipedOutputStream/PipedInputStream in a single thread, lest you overflow the buffer and cause a deadlock. ByteArrayOutputStream/ByteArrayInputStream works, but if your JAXB classes generate multiple schemas (in different namespaces) you need multiple StreamSources. I ended up with this: JAXBContext jc = JAXBContext.newInstance(Something.class); final List&lt;ByteArrayOutputStream&gt; outs = new ArrayList&lt;ByteArrayOutputStream&gt;(); jc.generateSchema(new SchemaOutputResolver(){ @Override public Result createOutput(String namespaceUri, String suggestedFileName) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); outs.add(out); StreamResult streamResult = new StreamResult(out); streamResult.setSystemId(""); return streamResult; }}); StreamSource[] sources = new StreamSource[outs.size()]; for (int i=0; i&lt;outs.size(); i++) { ByteArrayOutputStream out = outs.get(i); // to examine schema: System.out.append(new String(out.toByteArray())); sources[i] = new StreamSource(new ByteArrayInputStream(out.toByteArray()),""); } SchemaFactory sf = SchemaFactory.newInstance( XMLConstants.W3C_XML_SCHEMA_NS_URI ); m.setSchema(sf.newSchema(sources)); m.marshal(docs, new DefaultHandler()); // performs the schema validation
has comment: http://stackoverflow.com/comment/2719166

http://stackoverflow.com/comment/2782885
has text: @Naski: you are right, I was not honest how I use Vim -- most of the time and similarly to you.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2748232
score: 0

http://stackoverflow.com/a/2664372
upvote count: 6
type: Answer
has body: You'll surely want to look at How to Make Dialogs and review the JDialog API. Here's a short example to get started. You might compare it with what you're doing now. import java.awt.EventQueue; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.ButtonGroup; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; public class DialogTest extends JDialog implements ActionListener { private static final String TITLE = "Season Test"; private enum Season { WINTER("Winter"), SPRING("Spring"), SUMMER("Summer"), FALL("Fall"); private JRadioButton button; private Season(String title) { this.button = new JRadioButton(title); } } private DialogTest(JFrame frame, String title) { super(frame, title); JPanel radioPanel = new JPanel(); radioPanel.setLayout(new GridLayout(0, 1, 8, 8)); ButtonGroup group = new ButtonGroup(); for (Season s : Season.values()) { group.add(s.button); radioPanel.add(s.button); s.button.addActionListener(this); } Season.SPRING.button.setSelected(true); this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); this.add(radioPanel); this.pack(); this.setLocationRelativeTo(frame); this.setVisible(true); } @Override public void actionPerformed(ActionEvent e) { JRadioButton b = (JRadioButton) e.getSource(); JOptionPane.showMessageDialog(null, "You chose: " + b.getText()); } public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { @Override public void run() { new DialogTest(null, TITLE); } }); } }
downvote count: 0
score: 6
answers question: http://stackoverflow.com/q/2663199

apache
tags question: http://stackoverflow.com/q/2630437
tag name: apache
tags question: http://stackoverflow.com/q/2735524
tags question: http://stackoverflow.com/q/2738257
tags question: http://stackoverflow.com/q/2616650
type: Tag
tags question: http://stackoverflow.com/q/2785719

http://stackoverflow.com/q/2644011
has title: how to achieve xxx.domainname.com URL pattern?
tagged with: web-applications
possible better answer: http://stackoverflow.com/a/2645251
tagged with: jakarta-ee
type: AnsweredQuestion
score: 2
has answer: http://stackoverflow.com/a/2644180
has answer: http://stackoverflow.com/a/2645251
tagged with: java
has body: Consider the case of blogspot.com the domain is the one blogspot.com only but suppose i register in it with xxx then i will have xxx.blogspot.com like wise here it won't be the subdomain (i can smell) , but its some thing different ... how to achieve this ?? in j2ee web application..
has comment: http://stackoverflow.com/comment/2692047
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/2660169
tagged with: url
upvote count: 3
has comment: http://stackoverflow.com/comment/2659155
downvote count: 1
has comment: http://stackoverflow.com/comment/2658972
favorite count: 0
accepted answer: http://stackoverflow.com/a/2644180

http://stackoverflow.com/comment/2702939
score: 3
type: AnswerComment
has text: I think that this is too risky
type: Comment
comment on: http://stackoverflow.com/a/2683258

http://stackoverflow.com/comment/92576581
comment on: http://stackoverflow.com/q/2726300
score: 0
type: Comment
type: QuestionComment
has text: I found these two related questions are interesting: https://stackoverflow.com/questions/4525186/cannot-be-cast-to-java-io-serializable, https://stackoverflow.com/questions/2020904/when-and-why-jpa-entities-should-implement-serializable-interface

http://stackoverflow.com/a/2670085
has body: Since .apk is a .jar file by another name (in other words it is a zip file with some specific definitions of where configuration files are stored inside the directory) then look at ZipInputStream to read the file and walk through the contents and write them out as files.
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2670011
downvote count: 0
type: Answer
score: 1
upvote count: 1
accepted answer of: http://stackoverflow.com/q/2670011

http://stackoverflow.com/a/2746755
has comment: http://stackoverflow.com/comment/76113532
downvote count: 6
answers question: http://stackoverflow.com/q/2746598
score: 50
accepted answer of: http://stackoverflow.com/q/2746598
type: Answer
has body: In the standard Jakarta EE API, the only alternative to JSP is Facelets. So far now Jakarta Faces is the only MVC framework which natively supports Facelets. Spring MVC supports out of the box only JSP, but it has a configurable view resolver which allows you to use Facelets anyway. Other candiates are 3rd party templating frameworks such as Thymeleaf and Freemarker, which can be configured as a view technology for Spring MVC. Spring documentation enlists integration examples for Thymeleaf and FreeMarker.
has comment: http://stackoverflow.com/comment/76117123
upvote count: 56
type: AcceptedAnswer

http://stackoverflow.com/a/2773351
answers question: http://stackoverflow.com/q/2773245
upvote count: 1
score: 1
has body: Assuming you aren't willing to move it to an interface or factory its kind of ugly but you could keep a delegeate copy of B in A and rewrite your methods ot invoke the delegate: public class A{ B delegate; public A(){ if([condition]){ delegate = new B() return; } ...//normal init } public void foo(){ if(delegate != null){ delegate.foo(); return; } ...//normal A.foo() } public boolean bar(Object wuzzle){ if(delegate != null){ return delegate.bar(wuzzle); } ...//normal A.bar() } ...//other methods in A }
downvote count: 0
has comment: http://stackoverflow.com/comment/2807244
type: Answer

http://stackoverflow.com/q/2753711
tagged with: java
has title: Process-to-port mapping with SNMP and/or wmi/wmic in java
tagged with: wmi
downvote count: 0
answer count: 1
favorite count: 0
has body: I'm trying to use SNMP to map outgoing ports on my host computer with the application running on the computer that is responsible for that communication. When running "netstat -ano" I get access to Protocol, Local Address (with port), Foreign Address (with port), State and PID. But I want to do this entirely without having to execute "cmd" from Java. By using SNMP OID: .1.3.6.1.2.1.25.4 (.iso.org.dod.internet.mgmt.mib-2.host.hrSWRun) I get access to PID (ex. 1704), Name (ex. cmd.exe), Path (ex. C:\Windows\system32) among others. There is an SNMP OID: .1.3.6.1.2.1.6.13 (.iso.org.dod.internet.mgmt.mib-2.tcp.tcpConnTable) that give you access to TCP connection state, local address, local port, remote address, remote port. But NO PID. So to sum up. My question again: Is there a way to "map" these tables together? Either directly in SNMP with other OID's or in conjunction with WMI / WMIC? UPDATE: What I want is access to tcpConnectionProcess in TcpConnectionEntry (tcpConnectionTable). This is from RFC 4022. tcpConnectionProcess has OID: .1.3.6.1.2.1.6.19.1.8 (.iso.org.dod.internet.mgmt.mib-2.tcp.tcpConnectionTable.tcpConnectionEntry.tcpConnectionProcess) The strange thing is that I get values from OID: .1.3.6.1.2.1.6.19.1.7 (.iso.org.dod.internet.mgmt.mib-2.tcp.tcpConnectionTable.tcpConnectionEntry.tcpConnectionState) The main problem here is that in Windows, this table is empty. Probably my lack of knowledge with regards to installation on Windows, but any help would be a great help.
tagged with: snmp
has answer: http://stackoverflow.com/a/17227035
upvote count: 3
type: UnansweredQuestion
type: Question
score: 3

http://stackoverflow.com/comment/123375993
type: Comment
comment on: http://stackoverflow.com/a/2624541
type: AnswerComment
has text: The clearest way is without a cast as it is the simplest case of numeric promotion.
score: 0

http://stackoverflow.com/a/2617631
downvote count: 0
score: 1
type: Answer
upvote count: 1
has body: Global variables are not the same as global constants. The reason global variables are bad is because they can be changed anywhere in the code and it is very hard to track down errors that result from a global variable not being in the expected state. Global constants will always be in their expected state because they can never be changed inadvertently.
answers question: http://stackoverflow.com/q/2617606

http://stackoverflow.com/a/67535452
answers question: http://stackoverflow.com/q/2624610
score: 0
has body: Solution using, java.time the modern API An Instant represents an instantaneous point on the timeline. It is independent of a timezone. In order to represent it in a timezone, you can use Instant#atZone or ZonedDateTime#ofInstant as shown below: import java.time.Instant; import java.time.ZoneId; import java.time.ZonedDateTime; public class Main { public static void main(String[] args) { // A sample timestamp long millis = 1620999618896L; Instant instant = Instant.ofEpochMilli(millis); System.out.println(instant); ZonedDateTime zdtET = instant.atZone(ZoneId.of("America/New_York")); System.out.println(zdtET); // Alternatively zdtET = ZonedDateTime.ofInstant(instant, ZoneId.of("America/New_York")); System.out.println(zdtET); } } Output: 2021-05-14T13:40:18.896Z 2021-05-14T09:40:18.896-04:00[America/New_York] 2021-05-14T09:40:18.896-04:00[America/New_York] The Z in the output is the timezone designator for zero-timezone offset. It stands for Zulu and specifies the Etc/UTC timezone (which has the timezone offset of +00:00 hours). Note: For any reason, if you need to convert this object of Instant to an object of java.util.Date, you can do so as follows: Date date = Date.from(instant); Learn more about the modern date-time API* from Trail: Date Time. * For any reason, if you have to stick to Java 6 or Java 7, you can use ThreeTen-Backport which backports most of the java.time functionality to Java 6 & 7. If you are working for an Android project and your Android API level is still not compliant with Java-8, check Java 8+ APIs available through desugaring and How to use ThreeTenABP in Android Project.
type: Answer

http://stackoverflow.com/comment/2644967
has text: The dollar can be escaped, but only at the point of declaring `a`, and I don't control that at this point. I also tried using another `propertyregex` operation to edit `a` and give an `a.escaped` property, but that didn't seem to work either. I tried variants on this: `<propertyregex property="a.escaped" input="${a}" regexp="\$$" replace="$$$$" global="true" />`
type: Comment
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/2631082

http://stackoverflow.com/comment/2728099
type: AnswerComment
has text: yep! Although `formatDurationHMS` doesn't quite fit the requirements as it's `H:m:s` and not `HH:mm:ss`, but I just wanted to point it out as a possibility.
type: Comment
score: 2
comment on: http://stackoverflow.com/a/2704494

http://stackoverflow.com/a/2777741
answers question: http://stackoverflow.com/q/2777701
score: 0
type: Answer
has body: If you're looking for byte code generation, have a look at cglib, it is the one used in Hibernate. But maybe some annotations can also fulfill your requirement, just like Google Guice's dependency injection.

http://stackoverflow.com/a/2773309
score: 3
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2772943
type: Answer
upvote count: 3
has body: This is very short what you can do: public class ButtonFrame extends JFrame implements ActionListener { private TextFieldFrame frame; public ButtonFrame(TextFieldFrame frame) { this.frame = frame; // init your components and add this as actionlistener to the button .... } public void actionPerformed(ActionEvent evt) { frame.notifyButtonPressed(); } } The other class: public class TextFieldFrame extends JFrame { private JTextField field = ...; // init in your constructor public void notifyButtonPressed() { field.setText("Yes man!! The button is pressed by the user!"); } } Again, this is very short what you have to do. You can also work with a Singleton pattern, but this is a better way.
accepted answer of: http://stackoverflow.com/q/2772943

bytecode
tags question: http://stackoverflow.com/q/2784696
type: Tag
tags question: http://stackoverflow.com/q/2737285
tag name: bytecode
tags question: http://stackoverflow.com/q/2637879
tags question: http://stackoverflow.com/q/2697657
tags question: http://stackoverflow.com/q/2609227
tags question: http://stackoverflow.com/q/2744817
tags question: http://stackoverflow.com/q/2604737

http://stackoverflow.com/comment/2768822
comment on: http://stackoverflow.com/a/2739864
has text: Pretty cool, how do you pass the modified dataset to the activity?
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/2608352
downvote count: 0
has body: This may be a silly question, but right now I have a rather large class that I want to use as a library. Where somebody can simply add this jar file to their classpath. And then simply do an import statement at the top, then he or she can start using this class. Is there anything special I need to do or can I simply just use the jar file built?
favorite count: 0
answer count: 4
type: AnsweredQuestion
score: 3
upvote count: 3
has answer: http://stackoverflow.com/a/2608407
has comment: http://stackoverflow.com/comment/2618620
tagged with: java
has answer: http://stackoverflow.com/a/2608370
has answer: http://stackoverflow.com/a/2608367
type: Question
has comment: http://stackoverflow.com/comment/2618718
has comment: http://stackoverflow.com/comment/2618588
has title: Creating a java library
possible better answer: http://stackoverflow.com/a/2608367
has answer: http://stackoverflow.com/a/2608396
accepted answer: http://stackoverflow.com/a/2608407

http://stackoverflow.com/a/2699241
type: Answer
answers question: http://stackoverflow.com/q/2699209
score: 2
downvote count: 0
has body: One trick I sometimes use is to define a method called closeQuietly(Closeable) that tests to see if its argument is null then closes it, ignoring any exceptions. But you need to be a careful closing OutputStreams and Writers that way because they may actually throw an exception that matters; e.g. if the final flush fails. Things are likely to improve with Java 7. Reports are that it will have a new construct that provides a more concise way of handling managed resources; e.g. streams that need to be closed when they are finished with. Finally, you should be aware that your example has a bug. If the method call to open the second stream, the first stream will not be closed. The second open needs to be done inside the try block.
upvote count: 2

http://stackoverflow.com/comment/3858759
type: Comment
comment on: http://stackoverflow.com/a/2777526
score: 0
type: AnswerComment
has text: @ get the square root of a number and then loop till square root eliminate even numbers and see if it is not divisble

http://stackoverflow.com/a/2617036
has body: Maven Cargo Plugin to start and stop your Web Container. You can also use it to deploy your web app to a running container. We use it for integration and functional test for our web applications.
type: Answer
score: 4
answers question: http://stackoverflow.com/q/2616397
upvote count: 4
downvote count: 0

jsf-2
tags question: http://stackoverflow.com/q/2720457
tags question: http://stackoverflow.com/q/2673716
type: Tag
tags question: http://stackoverflow.com/q/2740892
tags question: http://stackoverflow.com/q/2731964
tags question: http://stackoverflow.com/q/2689245
tag name: jsf-2
tags question: http://stackoverflow.com/q/2777852
tags question: http://stackoverflow.com/q/2735098

http://stackoverflow.com/a/2599292
has body: new FileOutputStream(f,true); You have already set the append flag to true(the second argument), so do the same as what you did with the previous result set. See: http://java.sun.com/javase/6/docs/api/java/io/FileOutputStream.html
type: Answer
accepted answer of: http://stackoverflow.com/q/2599219
upvote count: 2
has comment: http://stackoverflow.com/comment/2609206
has comment: http://stackoverflow.com/comment/2609155
has comment: http://stackoverflow.com/comment/2607999
score: 2
has comment: http://stackoverflow.com/comment/2609128
has comment: http://stackoverflow.com/comment/2608009
has comment: http://stackoverflow.com/comment/2609099
has comment: http://stackoverflow.com/comment/2608631
has comment: http://stackoverflow.com/comment/2608325
answers question: http://stackoverflow.com/q/2599219
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/2746467
type: AnswerComment
type: Comment
score: 1
comment on: http://stackoverflow.com/a/2719282
has text: I see. ServerSocket implies TCP. I didn't think of that. you're right. Thanks. However, I don't believe there is a *theoretical* guarantee that data received is identical to the data that was sent. The hardware could, somewhere along the transmit, misinterpret bits. Most bit-errors would be covered by parity-checks, but some errors could of course go through unnoticed. I know I'm being overly formal (it's a bad habit due to three years of formal method graduate studies).

http://stackoverflow.com/comment/45324473
type: AnswerComment
comment on: http://stackoverflow.com/a/2647000
type: Comment
has text: Would love to see whats on the other end of that link!
score: 0

http://stackoverflow.com/comment/2683054
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2659503
has text: Actually, there are _plenty_ of scenarios in which it will compile. See my answer for details.

http://stackoverflow.com/a/2723922
type: Answer
answers question: http://stackoverflow.com/q/2649048
upvote count: 4
downvote count: 0
score: 4
has body: For the large images sizes like you have, you will be best served with lossless editing of the JPEG files. Not only is this faster, since the image doesn't need to be rendered, but it also preserves quality, since the image is not recompressed. Lossless editing works on blocks, typically 16px square. While restrictive for some applications, this seems a good fit for mapping. You could implement tiling at different zoom levels by first losslessly cropping the image to sized pieces. (This is quick an efficient since the image is not rendered.) This gives you tiles for full-zoom. To create lower-levels of zoom, combine 2x2 tiles and scale these down to the size of 1 tile. The next level uses 4x4 tiles, and 8x8 and so on, each time scaling down to one tile. At some point when the number of tiles beecomes too large, you can choose to use zoomed tiles as the base resource. For example, at zoom level 8, that would require 256x256 tiles. This might be too much to handle, so you could use 16x16 tiles from zoom level 4. Wikipedia has more on lossless editing, and links to some implementing libraries.

http://stackoverflow.com/a/2703233
has comment: http://stackoverflow.com/comment/49282607
has comment: http://stackoverflow.com/comment/125415476
has comment: http://stackoverflow.com/comment/74863446
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2728057
upvote count: 100
has comment: http://stackoverflow.com/comment/19586532
downvote count: 2
has body: You need to create a SSLContext with your own TrustManager and create HTTPS scheme using this context. Here is the code, SSLContext sslContext = SSLContext.getInstance("SSL"); // set up a TrustManager that trusts everything sslContext.init(null, new TrustManager[] { new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { System.out.println("getAcceptedIssuers ============="); return null; } public void checkClientTrusted(X509Certificate[] certs, String authType) { System.out.println("checkClientTrusted ============="); } public void checkServerTrusted(X509Certificate[] certs, String authType) { System.out.println("checkServerTrusted ============="); } } }, new SecureRandom()); SSLSocketFactory sf = new SSLSocketFactory(sslContext); Scheme httpsScheme = new Scheme("https", 443, sf); SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(httpsScheme); // apache HttpClient version &gt;4.2 should use BasicClientConnectionManager ClientConnectionManager cm = new SingleClientConnManager(schemeRegistry); HttpClient httpClient = new DefaultHttpClient(cm);
type: Answer
score: 98
has comment: http://stackoverflow.com/comment/32890525
has comment: http://stackoverflow.com/comment/24986759
has comment: http://stackoverflow.com/comment/30867298
accepted answer of: http://stackoverflow.com/q/2703161
has comment: http://stackoverflow.com/comment/12830319
answers question: http://stackoverflow.com/q/2703161
has comment: http://stackoverflow.com/comment/2727644
has comment: http://stackoverflow.com/comment/57058947
has comment: http://stackoverflow.com/comment/19976971

http://stackoverflow.com/a/2673278
has comment: http://stackoverflow.com/comment/7928097
has comment: http://stackoverflow.com/comment/7926795
type: Answer
has comment: http://stackoverflow.com/comment/2692780
has comment: http://stackoverflow.com/comment/2692441
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/2692353
answers question: http://stackoverflow.com/q/2673251
has body: Well as you alaready said you can either use the Criteria API or create a HQL query: // Criteria List&lt;User&gt; users = HibernateUtil.getSession().createCriteria(User.class); crit.add(Restrictions.eq("regionName", regionName)).list(); // HQL String query = "SELECT FROM User WHERE regionName = :region"; List&lt;User&gt; users = HibernateUtil.getSession().createQuery(query).setString("region", regionName).list();
downvote count: 0

http://stackoverflow.com/a/2700023
downvote count: 1
score: 26
has body: You should use an ArrayList which provides all the logic to automatically extend the array. List rowValues = new ArrayList(); while (namesList.next()) { rowValues.add(namesList.getString(1)); } // You can then put this back into an array if necessary contactListNames = (String[]) rowValues.toArray(new String[rowValues.size()]);
accepted answer of: http://stackoverflow.com/q/2699963
has comment: http://stackoverflow.com/comment/2722670
upvote count: 27
answers question: http://stackoverflow.com/q/2699963
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2722665
has comment: http://stackoverflow.com/comment/2722638
type: Answer

http://stackoverflow.com/a/2762186
answers question: http://stackoverflow.com/q/2762171
type: Answer
has body: bunch of bloated, seemingly unnecessary classes. Hmm either the data belong together, which is why you have decided to return them from a single method, or they don't. If they do, isn't a new class is appropriate? As a last ditch you could return a Vector. edit or if you always had a finite number of return items you could use something like Pair&lt;T1,T2&gt; (or define some such generic tuple type)
score: 0
has comment: http://stackoverflow.com/comment/2794371

http://stackoverflow.com/a/18168690
answers question: http://stackoverflow.com/q/2598129
score: -1
downvote count: 1
has body: public class RemoveCharsFromString { static String testcase1 = "No, I am going to Noida"; static String testcase2 = "goings"; public static void main(String args[])throws StringIndexOutOfBoundsException{ RemoveCharsFromString testInstance= new RemoveCharsFromString(); String result = testInstance.remove(testcase1,testcase2); System.out.println(result); } //write your code here public String remove(String str, String str1)throws StringIndexOutOfBoundsException { String result=null; if (str == null) return ""; try { for (int i = 0; i &lt; str1.length (); i++) { char ch1=str1.charAt(i); for(int j=0;j&lt;str.length();j++) { char ch = str.charAt (j); if (ch == ch1) { String s4=String.valueOf(ch); String s5= str.replaceAll(s4, ""); str=s5; } } } } catch(Exception e) { } result=str; return result; } }
type: Answer
upvote count: 0

http://stackoverflow.com/q/2598712
favorite count: 0
has answer: http://stackoverflow.com/a/16463403
has answer: http://stackoverflow.com/a/2602676
tagged with: spring
possible better answer: http://stackoverflow.com/a/16463403
has body: When using the Spring 3.0 capability to annotate a scheduled task, I would like to set the fixedDelay as parameter from my configuration file, instead of hard-wiring it into my task class, like currently... @Scheduled(fixedDelay = 5000) public void readLog() { ... } Unfortunately it seems that with the means of the Spring Expression Language (SpEL) @Value returns a String object which in turn is not able to be auto-boxed to a long value as required by the fixedDelay parameter.
tagged with: annotations
score: 156
has answer: http://stackoverflow.com/a/77892925
has answer: http://stackoverflow.com/a/2598732
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2602676
has answer: http://stackoverflow.com/a/57574290
tagged with: configuration
tagged with: java
answer count: 6
type: Question
tagged with: scheduling
has title: How to parameterize @Scheduled(fixedDelay) with Spring 3.0 expression language?
upvote count: 156
downvote count: 0
has answer: http://stackoverflow.com/a/8926837

http://stackoverflow.com/comment/2727938
score: 0
type: AnswerComment
has text: 1) Yeah, I found this bug out the hard way, when my ordered lists were correct, but the costToThis values were obviously wrong as they were being overwritten. The Path class idea was one I had, but hadn't yet implemented, though it obviously makes a lot of sense, so thanks. 2) I forgot to mention that any path previously travelled can be travelled again. In the case I provided this isn't beneficial for any path, but that is using example data, and may not always be true. My search needs to travel all nodes at least once and then end up back on the starting node.
type: Comment
comment on: http://stackoverflow.com/a/2704133

http://stackoverflow.com/comment/2790732
type: AnswerComment
has text: Within your private constructor, you could throw a new AssertionError with the message "don't instantiate" to make your wishes even more explicit.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2752248

http://stackoverflow.com/a/2627063
accepted answer of: http://stackoverflow.com/q/2627018
answers question: http://stackoverflow.com/q/2627018
has body: You just have to shuffle the temp list before you add it to pic2. Here's the fixed code (note that I turned the pic2 variable into a field of the ListGenerator class and renamed it to result) String[] pictureFile = {"a.jpg","b.jpg","c.jpg","d.jpg","e.jpg","f.jpg","g.jpg"}; List &lt;String&gt; pic1= Arrays.asList(pictureFile); ... ListGenerator pic2= new ListGenerator(pic1); public class ListGenerator { ArrayList&lt;ArrayList&lt;Integer&gt;&gt; result = new ArrayList&lt;ArrayList&lt;Integer&gt;&gt;(); public ListGenerator(List&lt;String&gt; pic1) { int size = pic1.size(); // create a list of all possible combinations for(int i = 0 ; i &lt; size ; i++) { for(int j = (i+1) ; j &lt; size ; j++) { ArrayList&lt;Integer&gt; temp = new ArrayList&lt;Integer&gt;(); temp.add(i); temp.add(j); Collections.shuffle(temp); result.add(temp); } } Collections.shuffle(result); } //This method return the shuffled list public ArrayList&lt;ArrayList&lt;Integer&gt;&gt; getList() { return result; } } However this is just the first step towards a solution. Currently, each pair will contain integers in the range [0..size-1] so your pairs look like this: &lt;0,3&gt;, &lt;1,2&gt;, etc. What you probably want is to get a pairs that are two-letter String such as: "ab", "dc", etc. In this version I renamed getList() to getPairs() which convey its meaning better. Also, I made the constructor of ListGenerator accept an array of characters so you just need to call it with your desired characters, as follows: List&lt;String&gt; pairs = new ListGenerator('a', 'b', 'c', 'd', 'e', 'f', 'g').getPairs(); And here is ListGenerator it self: public class ListGenerator { ArrayList&lt;String&gt; result = new ArrayList&lt;String&gt;(); public ListGenerator(char... letters) { int size = letters.length; // create a list of all possible combinations for(int i = 0 ; i &lt; size ; i++) { for(int j = (i+1) ; j &lt; size ; j++) { ArrayList&lt;Character&gt; temp = new ArrayList&lt;Character&gt;(); temp.add(letters[i]); …
upvote count: 1
score: 1
type: AcceptedAnswer
downvote count: 0
type: Answer

http://stackoverflow.com/a/2639789
answers question: http://stackoverflow.com/q/2639758
has body: If you were doing it in combination with another external StringBuilder. StringBuilder sbAll = new StringBuilder(); for (int i=0; i&lt;cnt; i++) { .... { StringBuilder sb = new StringBuilder(); sb.append(","); sbAll.append(sb.toString()); } } The question is what are you doing inside the loop that's cute enough to need a separate StringBuilder? I guess it is possible.
score: 0
type: Answer

http://stackoverflow.com/comment/114637763
score: 0
comment on: http://stackoverflow.com/a/36300018
type: Comment
has text: I used solution to get my own mac address from https://stackoverflow.com/questions/33103798/how-to-get-wi-fi-mac-address-in-android-marshmallow on physical mobiles with Android 6, 7 and 8 and it works
type: AnswerComment

http://stackoverflow.com/comment/2770118
score: 0
type: AnswerComment
has text: This is one of those times where I go "why couldn't it just be like Python"... a defaultdict would work so perfectly here. :)
type: Comment
comment on: http://stackoverflow.com/a/2741236

http://stackoverflow.com/a/2773001
downvote count: 0
type: Answer
has body: Maven is another alternative, but I don't know that I'd call it "best". Ant has the virtue of simplicity if used properly. I find Maven to be heavier and less penetrable.
score: 3
upvote count: 3
answers question: http://stackoverflow.com/q/2772966

netbeans
tags question: http://stackoverflow.com/q/2664129
tags question: http://stackoverflow.com/q/2627692
tags question: http://stackoverflow.com/q/2702185
tags question: http://stackoverflow.com/q/2701912
tags question: http://stackoverflow.com/q/2784477
tags question: http://stackoverflow.com/q/2606249
tags question: http://stackoverflow.com/q/2663199
tags question: http://stackoverflow.com/q/2665975
tags question: http://stackoverflow.com/q/2755289
tags question: http://stackoverflow.com/q/2739147
tags question: http://stackoverflow.com/q/2631130
tags question: http://stackoverflow.com/q/2673371
tags question: http://stackoverflow.com/q/2702647
tags question: http://stackoverflow.com/q/2619644
type: Tag
tags question: http://stackoverflow.com/q/2744923
tags question: http://stackoverflow.com/q/2732961
tags question: http://stackoverflow.com/q/2713132
tags question: http://stackoverflow.com/q/2654892
tags question: http://stackoverflow.com/q/2781057
tags question: http://stackoverflow.com/q/2613875
tags question: http://stackoverflow.com/q/2647296
tags question: http://stackoverflow.com/q/2717889
tags question: http://stackoverflow.com/q/2669414
tags question: http://stackoverflow.com/q/2627653
tags question: http://stackoverflow.com/q/2754452
tags question: http://stackoverflow.com/q/2785007
tags question: http://stackoverflow.com/q/2633582
tags question: http://stackoverflow.com/q/2727382
tags question: http://stackoverflow.com/q/2618833
tags question: http://stackoverflow.com/q/2778295
tags question: http://stackoverflow.com/q/2733690
tags question: http://stackoverflow.com/q/2625506
tags question: http://stackoverflow.com/q/2728129
tags question: http://stackoverflow.com/q/2701048
tags question: http://stackoverflow.com/q/2685399
tags question: http://stackoverflow.com/q/2756891
tag name: netbeans
tags question: http://stackoverflow.com/q/2684998
tags question: http://stackoverflow.com/q/2658439
tags question: http://stackoverflow.com/q/2704050
tags question: http://stackoverflow.com/q/2641760
tags question: http://stackoverflow.com/q/2767224

http://stackoverflow.com/a/15427060
type: Answer
answers question: http://stackoverflow.com/q/2711817
score: 0
has body: Keep few things in mind to avoid concurrent access issues : First of all the method (startAnalysis) is an instance method. So synchronization will be specific to its instance. So you need to make sure that all the threads trying to access this method must use the same instance to avoid concurrent access issues. If every thread is referring to a different instance, then all the threads will be allowed to execute the method and eventually may lead to concurrency issues. Secondly, one should always prefer to use Iterator rather the for:each loop to iterate over collections, to avoid concurrent access/modification issues. Also you can use concurrent collection api classes to avoid concurrency issues. These classes are heavily used in such requirements to avoid concurrent modification issues. Hope this helps.

http://stackoverflow.com/a/16010258
downvote count: 0
upvote count: 8
type: Answer
has body: Please not that there is a shortcut method for that: String paramValue = getQueryValue("userId"); Hope it helps you.
score: 8
answers question: http://stackoverflow.com/q/2773626

http://stackoverflow.com/a/2778212
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/2812820
answers question: http://stackoverflow.com/q/2778179
has comment: http://stackoverflow.com/comment/2812793
has body: You should use rounded double type. DecimalFormat p= new DecimalFormat( "#0.00" ); double price = 123.00001; price = new Double(p.format(price)).doubleValue();

http://stackoverflow.com/comment/2694825
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2675974
type: AnswerComment
has text: For clarity, I'm not looking for a change to the ArrayList. I'm looking for something like the interface, not a change to the original implementation.

http://stackoverflow.com/a/2710502
answers question: http://stackoverflow.com/q/2703480
score: 5
type: AcceptedAnswer
downvote count: 0
has body: I use assert to check the preconditions of nonpublic methods, that's all (I do not claim doing design-by-contract). Just in case, let me remind what Programming With Assertions writes about Preconditions, Postconditions, and Class Invariants: While the assert construct is not a full-blown design-by-contract facility, it can help support an informal design-by-contract style of programming. For full-blown support in Java, maybe consider using a third-party library (from Wikipedia): iContract2, Contract4J, jContractor, Jcontract, C4J, CodePro Analytix, STclass, Jass preprocessor, OVal with AspectJ, Java Modeling Language (JML), SpringContracts for the Spring framework, or Modern Jass, Custos using AspectJ,JavaDbC using AspectJ, JavaTESK using extension of Java.
type: Answer
upvote count: 5
accepted answer of: http://stackoverflow.com/q/2703480

http://stackoverflow.com/a/26574908
score: -1
answers question: http://stackoverflow.com/q/2598129
downvote count: 1
type: Answer
upvote count: 0
has body: This is my solution public static String removeDup(String inputString){ if (inputString.length()&lt;2) return inputString; if (inputString==null) return null; char[] inputBuffer=inputString.toCharArray(); for (int i=0;i&lt;inputBuffer.length;i++){ for (int j=i+1;j&lt;inputBuffer.length;j++){ if (inputBuffer[i]==inputBuffer[j]){ inputBuffer[j]=0; } } } String result=new String(inputBuffer); return result; }

http://stackoverflow.com/q/2684049
has comment: http://stackoverflow.com/comment/2703854
answer count: 4
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2684167
downvote count: 0
tagged with: java
accepted answer: http://stackoverflow.com/a/2684322
tagged with: swing
has answer: http://stackoverflow.com/a/47142849
has comment: http://stackoverflow.com/comment/2703844
type: Question
has answer: http://stackoverflow.com/a/2684423
has title: Check if thread is EDT is necessary?
has answer: http://stackoverflow.com/a/2684322
score: 4
has comment: http://stackoverflow.com/comment/2703896
has answer: http://stackoverflow.com/a/2684167
has body: I have an UI implemented with Swing. One component does some work that may take some time, so I use SwingUtilities.invokeLater. However, I was reading some old code and found this in an ActionListener: if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(new Runnable() { public void run() { // code X } }); } else { // code X } I thought that it made sense since it separates code X from the EDT. However, I found it error-prone since I have used it a couple of times and both times I forgot the else part. The question is: is the SwingUtilities.isEventDispatchThread() checking necessary? Or could I assume that I am not in the EDT and always use invokeLater? Thanks a lot.
favorite count: 0
tagged with: event-dispatch-thread
tagged with: events
upvote count: 4

http://stackoverflow.com/q/2768086
tagged with: groovy
answer count: 3
downvote count: 0
possible better answer: http://stackoverflow.com/a/3277364
tagged with: maven-2
favorite count: 0
has answer: http://stackoverflow.com/a/2770302
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2771013
accepted answer: http://stackoverflow.com/a/2771013
upvote count: 3
has answer: http://stackoverflow.com/a/3277364
type: Question
has title: Setting groovysh classpath from a pom
score: 3
tagged with: java
has body: I have a java project (not using groovy) but I'd like to interactively play with my java classes within groovysh. Is there an easy way to use the pom from my project to set the classpath of groovysh?

http://stackoverflow.com/q/2598416
has title: Need to validate a scientific spreadsheet written in Java
tagged with: java
type: UnansweredQuestion
has body: I need a validation framework, for an app written in Java, Eclipse RCP. The UI is a simple spreadsheet with many input fields and many output fields. The user input needs to be validated, for example: Thresholds for numerical fields Required fields for certain operations Context-sensitive help based on the validation results Multi-field validation, e.g a field is valid depending upon the values in other fields Wondering if there is anything out there?
tagged with: validation
has answer: http://stackoverflow.com/a/2599283
tagged with: eclipse-rcp
type: Question
score: 0
tagged with: swt
answer count: 1
has comment: http://stackoverflow.com/comment/2607100

http://stackoverflow.com/a/74023207
has body: This code is for those who don't want to use loop The Easiest way to find the highest number in the array is int a[] = {1,2,3,9,5,7,6,4,8}; Arrays.sort(a); System.out.println(a[1-1]); The Easiest way to find the second-highest number in the array is int a[] = {1,2,3,9,5,7,6,4,8}; Arrays.sort(a); System.out.println(a[2-1]); The Easiest way to find the third-highest number in the array is int a[] = {1,2,3,9,5,7,6,4,8}; Arrays.sort(a); System.out.println(a[3-1]); The Easiest way to find the fourth-highest number in the array is int a[] = {1,2,3,9,5,7,6,4,8}; Arrays.sort(a); System.out.println(a[4-1]);
score: 0
type: Answer
answers question: http://stackoverflow.com/q/2615712

http://stackoverflow.com/comment/2809584
has text: I would love to use prepared/callable statements, but I've found these problems: 1) They are a huge pain to deploy -- this is for an internal dashboard and we are using continuous deployment. In a related issue, they are a big to pain to edit. 2) They use prepared SQL, and it's not as flexible -- I need to be able to for example generate to a table with a new name (e.g, INSERT INTO TableForExperiment_${DATE}). 3) Callable statements are not much easier to comment or make readable (for example, I have no way to put a subquery in a separate string).
type: Comment
comment on: http://stackoverflow.com/a/2775157
score: 0
type: AnswerComment

http://stackoverflow.com/comment/2803013
type: AnswerComment
has text: Hmmm... the syntax seems to all be fine, but the `apply` method is never being run. Still figuring this thing out...
type: Comment
comment on: http://stackoverflow.com/a/2769554
score: 0

http://stackoverflow.com/comment/13019430
type: Comment
score: 1
has text: Welcome to stackoverflow. That is very similar to previous suggestions. Given the age of this thread, it is best not to resurrect it unless the response contributes something significantly different than previous answers.
type: AnswerComment
comment on: http://stackoverflow.com/a/10139947

http://stackoverflow.com/a/2703107
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/11847120
accepted answer of: http://stackoverflow.com/q/2699646
upvote count: 28
has comment: http://stackoverflow.com/comment/10606359
has body: Constituents It sounds like you want to identify the sentence's constituents, which are groups of words that operate as a single unit according to the grammar of a language. In fact, when linguistics are trying to discover a language's grammar, they do it in part by looking at movement. As in your example, this is where a group of words can be moved to a different position in a sentence while still preserving the meaning of the sentence. Constituents can be individual words, phrases, or even larger groups such as whole clauses. Within a sentence, they have a nested hierarchical structure. For instance, the first example sentence you gave could be analyzed as: (S (PP (IN On) (NP (NNP March) (CD 1))) (NP (PRP he)) (VP (VBD was) (VP (VBN born)))) The whole sentence is made up of a prepositional phrase, followed by a noun phrase, and then a verb phrase. The prepositional phrase can be further decomposed into a unit consisting of the single word 'On' followed by a noun phrase. Phrase Structure Parsers To find constituents automatically, you will probably want to use a phrase structure parser. There are many such parses to choose from that are available as open source, including: Stanford Parser (Java) Berkeley Parser (Java) BLLIP (Charniak-Johnson) Parser (C++) Bikel Parser (this is a reimplemented and improved version of the Collins parser write in Java) Collins Parser (C++) OpenNLP Parser (Java) SharpNLP Parser (C#) The Stanford and Berkeley parsers are probably the easiest to install and use. As seen in Cer et al. 2010, the most accurate parsers are Berkeley and Charniak. The Bikel parser is slower and less accurate than the others. Online Demo There's an online demo for the Stanford parser here. I used the demo to produce the parse given above of your example sentence. A Note About Deletion Within each constituent, there will be a head word. For example, take the noun phrase: (NP (DT The) (JJ big) (JJ blue) (NN ball)) The head word here is the noun ball, and it is mo…
score: 28
has comment: http://stackoverflow.com/comment/10641105
has comment: http://stackoverflow.com/comment/26146746
type: Answer
has comment: http://stackoverflow.com/comment/11865703
has comment: http://stackoverflow.com/comment/10581335
answers question: http://stackoverflow.com/q/2699646

http://stackoverflow.com/a/2636224
has comment: http://stackoverflow.com/comment/94202280
type: Answer
has body: Keep in mind that the location on windows has changed. It was different in java 6 (compared to java 5).
upvote count: 1
downvote count: 1
score: 0
answers question: http://stackoverflow.com/q/2635443

http://stackoverflow.com/comment/66155368
comment on: http://stackoverflow.com/a/2724009
type: AnswerComment
type: Comment
score: 8
has text: use `readAttributes(file.toPath(), BasicFileAttributes.class)` else you get: `no suitable method found for readAttributes(File,Class<BasicFileAttributes>) method Files.readAttributes(Path,Class,LinkOption...) is not applicable (cannot infer type-variable(s) A (argument mismatch; File cannot be converted to Path))`

http://stackoverflow.com/q/2767220
score: 6
favorite count: 0
accepted answer: http://stackoverflow.com/a/2767271
type: Question
has body: In Windows, there is ( was a ) src.jar file that contains the java source files of the Java platform. Is there something similar for Java 1.6 in OSX? I would like to specify this to my IDE so I can navigate to that source.
has answer: http://stackoverflow.com/a/2767261
tagged with: windows
upvote count: 6
tagged with: macos
has title: Is there a src.jar in OSX?
possible better answer: http://stackoverflow.com/a/4197279
has answer: http://stackoverflow.com/a/4197279
has answer: http://stackoverflow.com/a/7582547
has answer: http://stackoverflow.com/a/2767271
tagged with: java
answer count: 5
has comment: http://stackoverflow.com/comment/21892248
has answer: http://stackoverflow.com/a/2767268
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/21894307
downvote count: 0

http://stackoverflow.com/comment/8088799
type: Comment
has text: this answer should probably note that trusting all certificates is horribly insecure and nullifies the entire purpose of ssl...
score: 158
comment on: http://stackoverflow.com/a/4837230
type: AnswerComment

http://stackoverflow.com/q/2652287
has title: Help in debugging the string concatenation code
accepted answer: http://stackoverflow.com/a/2652407
has body: I have a code to concatenate strings. However, for some reason, the final string is not a combination of the required strings. Consider the following code : //cusEmail is of type String[] String toList = ""; for(i=0; i &lt; cusEmail.length - 1; i++) { toList.concat(cusEmail[i]); toList.concat("; "); System.out.println(cusEmail[i]); } toList.concat(cusEmail[i]); System.out.println(toList); The first sout statement displays the strings in cusEmail[i] correctly. However, once concatenated, the second sout displays a blank / empty. Any reason for this? Am i concatenating it correctly?
answer count: 2
tagged with: concatenation
score: 2
downvote count: 0
favorite count: 0
possible better answer: http://stackoverflow.com/a/2652408
has answer: http://stackoverflow.com/a/2652407
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2652408
upvote count: 2
type: Question
tagged with: debugging
tagged with: java

http://stackoverflow.com/comment/2729125
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2704955
has text: It was suggested on this site that if you have a lot of named queries that you place them in a constants file separately. The pojo then just makes a reference to them. This way with constants, no chance of misspelling and I think it is cleaner.

http://stackoverflow.com/comment/2777708
comment on: http://stackoverflow.com/a/2746430
score: 0
type: AnswerComment
has text: It's been part of the language since JDK 1.2
type: Comment

http://stackoverflow.com/a/2751735
has comment: http://stackoverflow.com/comment/2782255
score: 4
type: Answer
accepted answer of: http://stackoverflow.com/q/2751714
has body: You can use Java's reflection API to achieve the same effect, albeit much less elegantly. See here for a tutorial.
upvote count: 4
has comment: http://stackoverflow.com/comment/2782403
answers question: http://stackoverflow.com/q/2751714
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/2765855
has body: From the Java 6 source code: * @author Josh Bloch * @version 1.67, 04/21/06 * @see List * @see ArrayList * @see Vector * @since 1.2 * @param &lt;E&gt; the type of elements held in this collection */ public class LinkedList&lt;E&gt; extends AbstractSequentialList&lt;E&gt; implements List&lt;E&gt;, Deque&lt;E&gt;, Cloneable, java.io.Serializable { private transient Entry&lt;E&gt; header = new Entry&lt;E&gt;(null, null, null); private transient int size = 0; /** * Constructs an empty list. */ public LinkedList() { header.next = header.previous = header; } ... /** * Returns the first element in this list. * * @return the first element in this list * @throws NoSuchElementException if this list is empty */ public E getFirst() { if (size==0) throw new NoSuchElementException(); return header.next.element; } /** * Returns the last element in this list. * * @return the last element in this list * @throws NoSuchElementException if this list is empty */ public E getLast() { if (size==0) throw new NoSuchElementException(); return header.previous.element; } ... } so that's O(1) for both getFirst() &amp; getLast()
score: 2
upvote count: 2
downvote count: 0
answers question: http://stackoverflow.com/q/2765750
type: Answer

http://stackoverflow.com/a/2624568
upvote count: 3
has comment: http://stackoverflow.com/comment/2637318
answers question: http://stackoverflow.com/q/2624503
downvote count: 0
score: 3
type: Answer
has body: Either synchronize on obj, or call wait and notify on this. The calling thread must hold the monitor of the same object on which these methods are called. For example, synchronized void flag() { System.out.println("Before Wait"); try { wait(); } catch (InterruptedException e) { System.out.println("Thread interrupted"); } System.out.println("After Being Notified"); } In this example, the lock is held on this (when the modifier synchronized is used on a instance method, the monitor of the instance is acquired). So, the wait() method may be invoked on the implied instance this. In order to coordinate the two threads, they need to share the same lock. The original version had a static obj that could be used as a lock, but it wasn't used in the synchronized blocks. Here is a better example: class SimpleWaitNotify implements Runnable { private final Object lock; private final boolean wait; SimpleWaitNotify(Object lock, boolean wait) { this.lock = lock; this.wait = wait; } public void flag() { synchronized (lock) { System.out.println("Before Wait"); try { lock.wait(); System.out.println("After Being Notified"); } catch (InterruptedException ex) { System.out.println("Thread interrupted"); } } } public void unflag() { synchronized(lock) { System.out.println("Before Notify All"); lock.notifyAll(); System.out.println("After Notify All Method Call"); } } public void run() { if (wait) { flag(); } else { unflag(); } } public static void main(String[] argv) throws Exception { ExecutorService pool = Executors.newFixedThreadPool(4); Object shared = new Object(); SimpleWaitNotify sWait = new SimpleWaitNotify(shared, true); pool.execute(sWait); SimpleWaitNotify sNotify = new SimpleWaitNotify(shared, false); pool.execute(sNotify); pool.shutdown(); } }

http://stackoverflow.com/a/2631699
has comment: http://stackoverflow.com/comment/2645634
downvote count: 2
upvote count: 1
score: -1
has body: I don't know about blackberry, but generally, exceptions have a stacktrace, where line numbers are shown: java.lang.NullPointerException at your.packege.ClassName.methodName(ClassName.java:169) So obtain the stacktrace and see. The stacktrace is obtained either by try {..} catch (Exception ex) {..} or by letting it bubble up to a place where it is printed to the standard output. Also, each exception has getStackTrace() method, which returns each line of the stack-trace as a StackTraceElement
answers question: http://stackoverflow.com/q/2631684
type: Answer

http://stackoverflow.com/q/2760416
favorite count: 0
upvote count: 2
tagged with: swt
score: 2
type: AnsweredQuestion
tagged with: java
type: Question
accepted answer: http://stackoverflow.com/a/2760870
downvote count: 0
has answer: http://stackoverflow.com/a/2760870
has title: SWT: cleaning up before application exit
answer count: 1
has body: What is the best way for an SWT application to clean up resources before application exit? I see two options: 1) Add a DisposeListener to main window (or better, to the Display). Will it get run if an uncaught exception happens? 2) Use a shutdown hook. Any problems to be aware of there which aren't mentioned in Design of the Shutdown Hooks API?

sorting
tags question: http://stackoverflow.com/q/2661065
tags question: http://stackoverflow.com/q/2660295
tags question: http://stackoverflow.com/q/2741846
tags question: http://stackoverflow.com/q/2748829
tags question: http://stackoverflow.com/q/2624313
tags question: http://stackoverflow.com/q/2776011
tags question: http://stackoverflow.com/q/2784514
tags question: http://stackoverflow.com/q/2699029
tags question: http://stackoverflow.com/q/2625229
tags question: http://stackoverflow.com/q/2778179
tags question: http://stackoverflow.com/q/2689455
type: Tag
tags question: http://stackoverflow.com/q/2786379
tags question: http://stackoverflow.com/q/2598383
tag name: sorting
tags question: http://stackoverflow.com/q/2704882
tags question: http://stackoverflow.com/q/2693860

http://stackoverflow.com/a/2653807
answers question: http://stackoverflow.com/q/2652403
type: Answer
has comment: http://stackoverflow.com/comment/2670409
score: 0
has body: As others have mentioned you can poll a reliable host, another option is to use the java.net.NetworkInterface class and its method isUp(). A quick demonstration: Enumeration&lt;NetworkInterface&gt; ifcs = NetworkInterface.getNetworkInterfaces(); while(ifcs.hasMoreElements()){ NetworkInterface ifc = ifcs.nextElement(); System.out.println(ifc.getDisplayName()+ " "+ifc.isUp()); } If the interface is disconnected then isUp should return false. Note that this will provide you with all interfaces so you should also check isLoopback() so you can ignore the loopback interface, which should always be up. This method should be more reliable than polling hosts, especially if your connection is slow, as well as being a more "courteous" method. At the very least you can use this as an initial test and if the interface does report itself as being up, then you can try to connect to a host.

http://stackoverflow.com/a/2750096
downvote count: 0
has comment: http://stackoverflow.com/comment/61154620
answers question: http://stackoverflow.com/q/2750073
has body: Use the notion of paragraph in in the StyledDocument with JTextPane.getStyledDocument. With the position of cursor, you know the current paragraph with StyledDocument.getParagraph(pos). Then you iterate throw the paragraphs from StyledDocument.getRootElements and children, to search the number of current paragraph, so the number of current line. Sorry for my english.
type: Answer
score: 2
has comment: http://stackoverflow.com/comment/2780257
upvote count: 2

http://stackoverflow.com/q/2676295
has answer: http://stackoverflow.com/a/2676939
has answer: http://stackoverflow.com/a/27933526
score: 45
answer count: 7
accepted answer: http://stackoverflow.com/a/2676939
has answer: http://stackoverflow.com/a/5801514
has answer: http://stackoverflow.com/a/15896875
favorite count: 0
has body: This should be really easy. I'm using Quartz running under Apache Tomcat 6.0.18, and I have a jobs.xml file which sets up my scheduled job that runs every minute. What I would like to do, is if the job is still running when the next trigger time rolls around, I don't want to start a new job, so I can let the old instance complete. Is there a way to specify this in jobs.xml (prevent concurrent instances)? If not, is there a way I can share access to an in-memory singleton within my application's Job implementation (is this through the JobExecutionContext?) so I can handle the concurrency myself? (and detect if a previous instance is running) update: After floundering around in the docs, here's a couple of approaches I am considering, but either don't know how to get them to work, or there are problems. Use StatefulJob. This prevents concurrent access... but I'm not sure what other side-effects would occur if I use it, also I want to avoid the following situation: Suppose trigger times would be every minute, i.e. trigger#0 = at time 0, trigger #1 = 60000msec, #2 = 120000, #3 = 180000, etc. and the trigger#0 at time 0 fires my job which takes 130000msec. With a plain Job, this would execute triggers #1 and #2 while job trigger #0 is still running. With a StatefulJob, this would execute triggers #1 and #2 in order, immediately after #0 finishes at 130000. I don't want that, I want #1 and #2 not to run and the next trigger that runs a job should take place at #3 (180000msec). So I still have to do something else with StatefulJob to get it to work the way I want, so I don't see much of an advantage to using it. Use a TriggerListener to return true from vetoJobExecution(). Although implementing the interface seems straightforward, I have to figure out how to setup one instance of a TriggerListener declaratively. Can't find the docs for the xml file. Use a static shared thread-safe object (e.g. a semaphore or whatever) owned by my class that implements Job. I don't like the…
has answer: http://stackoverflow.com/a/6338482
has answer: http://stackoverflow.com/a/3980108
has comment: http://stackoverflow.com/comment/7350656
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/6338482
has answer: http://stackoverflow.com/a/2676600
tagged with: java
tagged with: quartz-scheduler
tagged with: concurrency
type: Question
has title: quartz: preventing concurrent instances of a job in jobs.xml
linked to: http://stackoverflow.com/q/2676514
upvote count: 45
downvote count: 0

http://stackoverflow.com/q/2698253
has answer: http://stackoverflow.com/a/2731856
upvote count: 3
tagged with: java
tagged with: eclipse
tagged with: classpath
type: Question
has answer: http://stackoverflow.com/a/2730090
downvote count: 0
tagged with: eclipse-wtp
favorite count: 0
has answer: http://stackoverflow.com/a/2727610
answer count: 5
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2736264
has answer: http://stackoverflow.com/a/2736999
has title: StandardServletContainer for Runtime Target in Eclipse
score: 3
has body: For a generic project its possible to add a JRE_CONTAINER to classpath, is something like this possible for the Web Container Server Runtime? &lt;classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/&gt;

http://stackoverflow.com/comment/2722449
comment on: http://stackoverflow.com/a/2699190
type: AnswerComment
score: 0
has text: `continue` wouldn't jump back to the beginning in that case, it would test the condition (`false`) and end the loop. You would have to do `while(true) {}` and break out at the end. But yes, it would be horrible
type: Comment

http://stackoverflow.com/a/2726008
score: 114
has comment: http://stackoverflow.com/comment/85452852
has comment: http://stackoverflow.com/comment/22485388
has comment: http://stackoverflow.com/comment/51254883
has comment: http://stackoverflow.com/comment/38499837
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/85999483
has comment: http://stackoverflow.com/comment/10491316
accepted answer of: http://stackoverflow.com/q/2724871
has comment: http://stackoverflow.com/comment/68148753
has comment: http://stackoverflow.com/comment/66923858
answers question: http://stackoverflow.com/q/2724871
type: Answer
has comment: http://stackoverflow.com/comment/64843553
has comment: http://stackoverflow.com/comment/64818876
has comment: http://stackoverflow.com/comment/70351108
has comment: http://stackoverflow.com/comment/58857638
upvote count: 114
has comment: http://stackoverflow.com/comment/11487612
has body: Just copy/pasting some code from one of my apps that does what you are looking for. This is in an onClick handler of a button labeled "set ringtone" or something similar: Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select Tone"); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null); this.startActivityForResult(intent, 5); And this code captures the choice made by the user: @Override protected void onActivityResult(final int requestCode, final int resultCode, final Intent intent) { if (resultCode == Activity.RESULT_OK && requestCode == 5) { Uri uri = intent.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); if (uri != null) { this.chosenRingtone = uri.toString(); } else { this.chosenRingtone = null; } } } Also, I advise my users to install the "Rings Extended" app from the Android Market. Then whenever this dialog is opened on their device, such as from my app or from the phone's settings menu, the user will have the additional choice of picking any of the mp3s stored on their device, not just the built in ringtones.
has comment: http://stackoverflow.com/comment/9549270

http://stackoverflow.com/a/3858354
has comment: http://stackoverflow.com/comment/4112787
type: Answer
answers question: http://stackoverflow.com/q/2671858
has comment: http://stackoverflow.com/comment/4102326
score: 18
upvote count: 18
has body: Now there are more options. Though this question is "old", I got here, so I think it might be useful to leave the options I know of (so far): You could try Hazelcast. In it's 1.9 release it includes a Distributed implementation of java.util.concurrent.AtomicLong You can also use Zookeeper. It provides methods for creating sequence nodes (appended to znode names, though I prefer using version numbers of the nodes). Be careful with this one though: if you don't want missed numbers in your sequence, it may not be what you want. Cheers
downvote count: 0

http://stackoverflow.com/comment/42849319
has text: How can I replace only pair start/end quotes and leave single quote?
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/2608682
type: Comment

http://stackoverflow.com/comment/69601484
comment on: http://stackoverflow.com/a/5313383
type: Comment
has text: @Mohd this answer is exactly what I am looking for. I faced a lot of problems using static methods in multithreading. Can you please elaborate points 2, 3 more (with example 100 thumbs up for you)
score: 2
type: AnswerComment

http://stackoverflow.com/a/3513672
accepted answer of: http://stackoverflow.com/q/2720030
type: AcceptedAnswer
type: Answer
answers question: http://stackoverflow.com/q/2720030
score: 0
has body: It's been done: https://issues.apache.org/jira/browse/MATH-375

http://stackoverflow.com/comment/74341769
comment on: http://stackoverflow.com/a/2772510
type: AnswerComment
type: Comment
has text: Is this sort of thing needed for an existing database with constraints already in place?
score: 1

http://stackoverflow.com/a/20083960
has body: instead of env-&gt;CallVoidMethod(obj,aMethodId, &amp;rawAudioCopy); try env-&gt;CallVoidMethod(obj,aMethodId, rawAudioCopy, 0 , 10);
answers question: http://stackoverflow.com/q/2648877
downvote count: 0
type: Answer
upvote count: 1
score: 1

http://stackoverflow.com/q/2687333
has title: How could I embed a html/css/js view in a webstart application
tagged with: java
has comment: http://stackoverflow.com/comment/3056741
score: -1
type: Question
upvote count: 0
answer count: 1
tagged with: java-web-start
favorite count: 0
has body: I would like to use a html/css/js view in my webstart project without requesting all permissions. I figured out that I could use the java HTTPServer to process the requests but I need a way to avoid using real sockets, so that the HTTPServer instantiation doesn't ask for some permission. Do you know any projects that achieve that ? and if not, what should I do to get an HTTPServer completely working locally (without hitting boundaries...) ? edit: maybe an HTTPServer is too much, I maybe only need a HttpHandler..
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2687896
downvote count: 1
tagged with: http

http://stackoverflow.com/a/19425549
has comment: http://stackoverflow.com/comment/88178250
has comment: http://stackoverflow.com/comment/62695172
has comment: http://stackoverflow.com/comment/38917950
has comment: http://stackoverflow.com/comment/31040766
has comment: http://stackoverflow.com/comment/120983386
downvote count: 4
has comment: http://stackoverflow.com/comment/117336182
has comment: http://stackoverflow.com/comment/31082224
answers question: http://stackoverflow.com/q/2758224
has comment: http://stackoverflow.com/comment/29376167
has comment: http://stackoverflow.com/comment/35218870
has comment: http://stackoverflow.com/comment/62228187
score: 388
has comment: http://stackoverflow.com/comment/62255207
has comment: http://stackoverflow.com/comment/30967614
has comment: http://stackoverflow.com/comment/88209306
type: Answer
has comment: http://stackoverflow.com/comment/30988695
has comment: http://stackoverflow.com/comment/103421656
has comment: http://stackoverflow.com/comment/30952201
has comment: http://stackoverflow.com/comment/35229795
has body: Let's assume that you are supposed to write a program to control a nuclear power-plant. It is pretty obvious that even the most minor mistake could have catastrophic results, therefore your code has to be bug-free (assuming that the JVM is bug-free for the sake of the argument). Java is not a verifiable language, which means: you cannot calculate that the result of your operation will be perfect. The main reason for this are pointers: they can point anywhere or nowhere, therefore they cannot be calculated to be of this exact value, at least not within a reasonable span of code. Given this problem, there is no way to prove that your code is correct at a whole. But what you can do is to prove that you at least find every bug when it happens. This idea is based on the Design-by-Contract (DbC) paradigm: you first define (with mathematical precision) what your method is supposed to do, and then verify this by testing it during actual execution. Example: // Calculates the sum of a (int) + b (int) and returns the result (int). int sum(int a, int b) { return a + b; } While this is pretty obvious to work fine, most programmers will not see the hidden bug inside this one (hint: the Ariane V crashed because of a similar bug). Now DbC defines that you must always check the input and output of a function to verify that it worked correctly. Java can do this through assertions: // Calculates the sum of a (int) + b (int) and returns the result (int). int sum(int a, int b) { assert (Integer.MAX_VALUE - a &gt;= b) : "Value of " + a + " + " + b + " is too large to add."; final int result = a + b; assert (result - a == b) : "Sum of " + a + " + " + b + " returned wrong sum " + result; return result; } Should this function now ever fail, you will notice it. You will know that there is a problem in your code, you know where it is and you know what caused it (similar to Exceptions). And what is even more important: you stop executing right when it happens to prevent any further code to wor…
has comment: http://stackoverflow.com/comment/76427170
upvote count: 392
has comment: http://stackoverflow.com/comment/117456305

http://stackoverflow.com/a/2601341
downvote count: 0
has body: You can solve it by creating yet another TableCellEditor which will delegate to either of its two subcontractors: the instances of your current cell editors. You need to register this uber-celleditor with the column and let it delegate whenever it is used by Swing.
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2601251
answers question: http://stackoverflow.com/q/2601251
upvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/2636079
score: 2

ajax4jsf
tags question: http://stackoverflow.com/q/2667873
tags question: http://stackoverflow.com/q/2773225
type: Tag
tag name: ajax4jsf

http://stackoverflow.com/comment/2770782
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2732731
has text: Thanks for your suggestions. Yea my table design is fairly good, its normalized. Memory is good too, so is disk io as well. What I noticed is - some of columns havent been indexed coz their cardinality is very low. These are flag columns containing value O or 1. And the queries which use these columns in the where clause shoot up the mysql cpu utilization to 60%, meaning they are doing a full table scan. So something like this - select * from table where index_flag=0 and index_read_flag=1 limit 100. Also i have some count(*) with where clause, that might be slowing up the system as well??

http://stackoverflow.com/a/44218712
upvote count: 5
downvote count: 0
has body: This is what worked for me: Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("http://maps.google.co.in/maps?q=" + yourAddress)); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); }
score: 5
answers question: http://stackoverflow.com/q/2662531
type: Answer

http://stackoverflow.com/q/2714233
has answer: http://stackoverflow.com/a/2714873
tagged with: java
type: Question
tagged with: graphics
upvote count: 2
downvote count: 0
answer count: 1
favorite count: 0
has title: Java 2D graphics performance questions
has body: 1) Is their any performance loss when making a new image with bitmask transparency, drawing just a few things on it then drawing it on top of another; versus drawing the same image in the same conditions, but with the background cleared to an opaque color ? 2) What is the importance of the performance loss when drawing multiple images versus drawing one big image that includes them all ? 3) Is it better to draw small bit of images from a big image (a sprite sheet) or from their individual image ? Note I'm speaking about memory images, their representation on disk doesn't matter.
type: UnansweredQuestion
score: 2
tagged with: 2d

http://stackoverflow.com/comment/2755537
score: 2
has text: I stack on "extract/package". What it the meaning of these options? Should I "extract" or "package" libraries?
comment on: http://stackoverflow.com/a/2728293
type: AnswerComment
type: Comment

http://stackoverflow.com/a/17853903
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/33422103
has body: What you can do is have one UrlManager like this: public class UrlManager implements ValueChangeHandler&lt;String&gt; { public UrlManager() { History.addValueChangeHandler(this); } public void onValueChange(ValueChangeEvent&lt;String&gt; event) { String historyToken = event.getValue(); } } Save every history token to a list. If it is a completely new history token then add it to the list. If it is the previous history token, then the back button has been pressed. I suggest using a list to save the tokens and save an iterator that can move up and down the list. So initially it points at the end of the list. If the new token is the previous item on the list, then the back button has been pressed. If you're in the middle of the list (back a few times) and a new entry comes in (new link pressed), remove the rest of the list (can't go forward there anymore) and add the new one- and move iterator to that item. You get the idea.
answers question: http://stackoverflow.com/q/2693527

jakarta-ee
tags question: http://stackoverflow.com/q/2607442
tags question: http://stackoverflow.com/q/2703647
tags question: http://stackoverflow.com/q/2610351
tags question: http://stackoverflow.com/q/2726410
tags question: http://stackoverflow.com/q/2768500
tags question: http://stackoverflow.com/q/2697541
tags question: http://stackoverflow.com/q/2677242
tags question: http://stackoverflow.com/q/2741366
tags question: http://stackoverflow.com/q/2716002
type: Tag
tags question: http://stackoverflow.com/q/2643791
tags question: http://stackoverflow.com/q/2755338
tags question: http://stackoverflow.com/q/2737901
tags question: http://stackoverflow.com/q/2728118
tags question: http://stackoverflow.com/q/2761543
tags question: http://stackoverflow.com/q/2701094
tags question: http://stackoverflow.com/q/2757473
tags question: http://stackoverflow.com/q/2778295
tags question: http://stackoverflow.com/q/2647154
tags question: http://stackoverflow.com/q/2707516
tags question: http://stackoverflow.com/q/2763093
tags question: http://stackoverflow.com/q/2691393
tags question: http://stackoverflow.com/q/2663204
tags question: http://stackoverflow.com/q/2632631
tags question: http://stackoverflow.com/q/2656512
tags question: http://stackoverflow.com/q/2670369
tags question: http://stackoverflow.com/q/2761119
tags question: http://stackoverflow.com/q/2620415
tags question: http://stackoverflow.com/q/2758704
tags question: http://stackoverflow.com/q/2607019
tags question: http://stackoverflow.com/q/2748431
tags question: http://stackoverflow.com/q/2715499
tag name: jakarta-ee
tags question: http://stackoverflow.com/q/2677079
tags question: http://stackoverflow.com/q/2648145
tags question: http://stackoverflow.com/q/2703671
tags question: http://stackoverflow.com/q/2754793
tags question: http://stackoverflow.com/q/2775790
tags question: http://stackoverflow.com/q/2720781
tags question: http://stackoverflow.com/q/2714508
tags question: http://stackoverflow.com/q/2735183
tags question: http://stackoverflow.com/q/2760251
tags question: http://stackoverflow.com/q/2691645
tags question: http://stackoverflow.com/q/2598577
tags question: http://stackoverflow.com/q/2638073
tags question: http://stackoverflow.com/q/2653322
tags question: http://stackoverflow.com/q/2756220
tags question: http://stackoverflow.com/q/2767460
tags question: http://stackoverflow.com/q/2646965
tags question: http://stackoverflow.com/q/2773660
tags question: http://stackoverflow.com/q/2767224
tags question: http://stackoverflow.com/q/2627366
tags question: http://stackoverflow.com/q/2691003
tags question: http://stackoverflow.com/q/2707565
tags question: http://stackoverflow.com/q/2729746
tags question: http://stackoverflow.com/q/2670661
tags question: http://stackoverflow.com/q/2631062
tags question: http://stackoverflow.com/q/2707733
tags question: http://stackoverflow.com/q/2784703
tags question: http://stackoverflow.com/q/2644011
tags question: http://stackoverflow.com/q/2662915

jogl
tag name: jogl
tags question: http://stackoverflow.com/q/2735343
tags question: http://stackoverflow.com/q/2615890
type: Tag
tags question: http://stackoverflow.com/q/2656264

http://stackoverflow.com/a/2709729
answers question: http://stackoverflow.com/q/2708229
has comment: http://stackoverflow.com/comment/2734117
has body: Look into Project Lombok. It has a @Cleanup annotation which is settable on local variables which will auto-generate code at compilation time to clean up the resource. import lombok.Cleanup; import java.io.*; public class CleanupExample { public static void main(String[] args) throws IOException { @Cleanup InputStream in = new FileInputStream(args[0]); @Cleanup OutputStream out = new FileOutputStream(args[1]); byte[] b = new byte[10000]; while (true) { int r = in.read(b); if (r == -1) break; out.write(b, 0, r); } } }
has comment: http://stackoverflow.com/comment/2734129
type: Answer
score: 0

http://stackoverflow.com/comment/2846111
type: Comment
has text: IEEE 754-1985 §5.6: "When the integer … lies outside the range … 10^17 for double, the implementor may, at his option, alter all significant digits after … the seventeenth … to other decimal digits, typically 0." **But** that doesn't stop you from implementing your own perfectly precise decimal printer, presuming string conversion is even relevant to the problem. (Such would come full circle viz. finding powers, though.)
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/2763647

http://stackoverflow.com/comment/2668991
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2652836
score: 0
has text: @Michael By "honor inputs too long and too short", are you honoring the string or the field? What would BAR:4:5 have looked like before BLEH:5:9 was input? What would FO:0:3 look like if there were chars at 2 and 3?

http://stackoverflow.com/comment/3073870
comment on: http://stackoverflow.com/q/2622995
has text: What justifies storing the view rather than model? What do you need it for?
score: 3
type: QuestionComment
type: Comment

http://stackoverflow.com/q/2776011
has title: What is the difference between quicksort and tuned quicksort?
upvote count: 5
possible better answer: http://stackoverflow.com/a/2799175
has answer: http://stackoverflow.com/a/2776112
has body: What is the fundamental difference between quicksort and tuned quicksort? What is the improvement given to quicksort? How does Java decide to use this instead of merge sort?
tagged with: quicksort
type: AnsweredQuestion
downvote count: 0
tagged with: java
type: Question
score: 5
has answer: http://stackoverflow.com/a/2776221
tagged with: algorithm
has answer: http://stackoverflow.com/a/2799175
tagged with: sorting
answer count: 3
accepted answer: http://stackoverflow.com/a/2776112
favorite count: 0

math
tags question: http://stackoverflow.com/q/2777509
tags question: http://stackoverflow.com/q/2685524
tags question: http://stackoverflow.com/q/2717868
tags question: http://stackoverflow.com/q/2697638
type: Tag
tags question: http://stackoverflow.com/q/2632392
tags question: http://stackoverflow.com/q/2734119
tags question: http://stackoverflow.com/q/2647356
tags question: http://stackoverflow.com/q/2717013
tags question: http://stackoverflow.com/q/2686236
tags question: http://stackoverflow.com/q/2720030
tags question: http://stackoverflow.com/q/2685946
tag name: math

http://stackoverflow.com/q/2711143
downvote count: 0
favorite count: 0
tagged with: android
has answer: http://stackoverflow.com/a/2907723
answer count: 4
tagged with: gps
type: AnsweredQuestion
score: 3
upvote count: 3
tagged with: java
has answer: http://stackoverflow.com/a/2713036
tagged with: locationmanager
type: Question
has body: I've singled out my problem to a few lines of code lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER); lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 5.0f, this); lat = location.getLatitude(); lng = location.getLongitude(); //lat = new Double(40.431682); //lng = new Double(-74.2021819); pLocation = new GeoPoint((int)(lat * 1000000), (int)(lng * 1000000)); My onLocationChanged if you were wondering public void onLocationChanged(Location location) { if (location != null) { lat = location.getLatitude(); lng = location.getLongitude(); pLocation = new GeoPoint((int)(lat * 1000000), (int)(lng * 1000000)); } } My application crashes if I try to get the LastKnownLocation But it works fine if I feed it a Location manually I have no idea currently whats wrong
possible better answer: http://stackoverflow.com/a/2717538
has answer: http://stackoverflow.com/a/2717538
has title: Android Location Error
tagged with: location
has answer: http://stackoverflow.com/a/2717915
accepted answer: http://stackoverflow.com/a/2713036

http://stackoverflow.com/q/2756233
answer count: 5
has answer: http://stackoverflow.com/a/2759571
has answer: http://stackoverflow.com/a/2756265
tagged with: c++
possible better answer: http://stackoverflow.com/a/2756272
has answer: http://stackoverflow.com/a/2760062
type: AnsweredQuestion
upvote count: 9
tagged with: stack
tagged with: java
has answer: http://stackoverflow.com/a/2759517
has body: Quick background I'm a Java developer who's been playing around with C++ in my free/bored time. Preface In C++, you often see pop taking an argument by reference: void pop(Item&amp; removed); I understand that it is nice to "fill in" the parameter with what you removed. That totally makes sense to me. This way, the person who asked to remove the top item can have a look at what was removed. However, if I were to do this in Java, I'd do something like this: Item pop() throws StackException; This way, after the pop we return either: NULL as a result, an Item, or an exception would be thrown. My C++ text book shows me the example above, but I see plenty of stack implementations taking no arguments (stl stack for example). The Question How should one implement the pop function in C++? The Bonus Why?
score: 9
type: Question
has title: Why should pop() take an argument?
downvote count: 0
accepted answer: http://stackoverflow.com/a/2756265
has answer: http://stackoverflow.com/a/2756272
favorite count: 0

http://stackoverflow.com/a/2744932
downvote count: 0
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/2774171
answers question: http://stackoverflow.com/q/2744753
type: Answer
has body: What about this: get last line, count what's between spaces... String text = ... String[] lines = text.split("\n"); // or \r\n depending on how you get the string String lastLine = lines[lines.length-1]; StringTokenizer tokenizer = new StringTokenizer(lastLine, " "); // note that strtokenizer will ignore empty tokens, it is, what is between two consecutive spaces int count = 0; while (tokenizer.hasMoreTokens()) { tokenizer.nextToken(); count++; } return count; Edit you could control if you have a final space (lastLine.endsWith(" ")) so you are starting a new word or whatever, it's a basic approach for you to make it up :)
has comment: http://stackoverflow.com/comment/2774154

http://stackoverflow.com/a/28602003
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/2654839
has body: Documentation of Math.round says: Returns the result of rounding the argument to an integer. The result is equivalent to (int) Math.floor(f+0.5). No need to cast to int. Maybe it was changed from the past.
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/47841167

http://stackoverflow.com/q/2604614
has answer: http://stackoverflow.com/a/2604635
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/2614566
score: 0
answer count: 3
has comment: http://stackoverflow.com/comment/2615264
possible better answer: http://stackoverflow.com/a/2604629
has answer: http://stackoverflow.com/a/2604633
favorite count: 0
upvote count: 1
accepted answer: http://stackoverflow.com/a/2604635
has title: Why did i get this error?
has body: here's the code: class Acount { int sum ; String owner ; //these seem to make sense //a constructor or two public Acount () { this.sum = 0 ; this.owner = "John Doe" ; } public Acount (String name) {this.sum = 0 ; this.owner = name ; } public Acount (String name, int sum) {this.sum = sum ; this.owner = name ; } //prints an acount in the format "owner" "sum" public static void printAcount (Acount Acount) {System.out.print (Acount.owner) ; System.out.print (" ") ; System.out.println (Acount.sum) ; } public static void main (String[]arg) { Acount Acount1 = new Acount ("david", 100) ; System.out.println ("heres the first acount as it was created:") ; printAcount (Acount1) ; System.out.println ("now i changed one of its instance varaibles with a static method") ; upOne (Acount1) ; printAcount (Acount1) ; } public static Acount upOne (Acount Acount) { Acount.sum = Acount.sum + 1 ; return Acount ; } } here's the error: Exception in thread "main" java.lang.NoClassDefFoundError: Acount/java What went wrong and why?
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2614569
has answer: http://stackoverflow.com/a/2604629
tagged with: java
has comment: http://stackoverflow.com/comment/2614592

http://stackoverflow.com/comment/108369078
has text: @LiuWenbin_NO. - That part of the answer is misleading. `?` - the "unbounded wildcard" - corresponds with the exact opposite of invariance. Please refer to the following documentation: https://docs.oracle.com/javase/tutorial/java/generics/wildcardGuidelines.html which states: _In the case where the code needs to access the variable as both an "in" and an "out" variable, do not use a wildcard._ (They are using "in" and "out" as synonymous with "get" and "put"). With the exception of `null` you can't add to a Collection parameterized with `?`.
type: Comment
comment on: http://stackoverflow.com/a/31634364
score: 1
type: AnswerComment

http://stackoverflow.com/a/2720765
has comment: http://stackoverflow.com/comment/2746845
upvote count: 1
answers question: http://stackoverflow.com/q/2720738
score: 1
has body: The result of an arithmetic operation on short values is always int. test(7) doesn't work, since you haven't said that 7 is of type short. The compiler should be a bit smarter here.
downvote count: 0
has comment: http://stackoverflow.com/comment/2746830
type: Answer

http://stackoverflow.com/comment/2753180
type: AnswerComment
has text: that's why i hate it when people are mixing java/c# with functional programming. It looks bad. Why would you translate that simple loop into this Java monstrosity?
type: Comment
score: 1
comment on: http://stackoverflow.com/a/2725747

http://stackoverflow.com/q/2701630
tagged with: java
has body: What is the correct type of argument to the addAll(..) method in Java collections? If I do something like this: List&lt;? extends Map&lt;String, Object[]&gt;&gt; currentList = new ArrayList&lt;Map&lt;String, Object[]&gt;&gt;(); Collection&lt;HashMap&lt;String, Object[]&gt;&gt; addAll = new ArrayList&lt;HashMap&lt;String, Object[]&gt;&gt;(); // add some hashmaps to the list.. currentList.addAll(addAll); I understand I need to initialize both variables. However, I get a compilation error (from eclipse): Multiple markers at this line - The method addAll(Collection&lt;? extends capture#1-of ? extends Map&lt;String,Object[]&gt;&gt;) in the type List&lt;capture#1-of ? extends Map&lt;String,Object[]&gt;&gt; is not applicable for the arguments (List&lt;capture#2-of ? extends Map&lt;String,Object[]&gt;&gt;) - The method addAll(Collection&lt;? extends capture#1-of ? extends Map&lt;String,Object[]&gt;&gt;) in the type List&lt;capture#1-of ? extends Map&lt;String,Object[]&gt;&gt; is not applicable for the arguments (Collection&lt;HashMap&lt;String,Object[]&gt;&gt;) what am I doing wrong?
answer count: 5
has comment: http://stackoverflow.com/comment/2724553
has answer: http://stackoverflow.com/a/2701828
score: 11
type: AnsweredQuestion
downvote count: 0
has comment: http://stackoverflow.com/comment/2724657
has answer: http://stackoverflow.com/a/2701900
accepted answer: http://stackoverflow.com/a/2701900
type: Question
has answer: http://stackoverflow.com/a/2701694
has answer: http://stackoverflow.com/a/2701658
tagged with: generics
favorite count: 0
upvote count: 11
possible better answer: http://stackoverflow.com/a/2701700
has answer: http://stackoverflow.com/a/2701700
has title: java generics and the addAll method
tagged with: collections

http://stackoverflow.com/comment/2744068
type: AnswerComment
score: 0
type: Comment
has text: Duh. I just googled "Get IP Address Java". This should work nicely.
comment on: http://stackoverflow.com/a/2717473

http://stackoverflow.com/comment/2896913
score: 0
has text: Describe calling buildSessionFactory(). I'm not trying to be obtuse here. When I override LocalSessionFactory, Eclipse tells me I cannot call buildSessionFactory - it is not VISIBLE.
comment on: http://stackoverflow.com/q/2768511
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2717459
has answer: http://stackoverflow.com/a/67635691
has answer: http://stackoverflow.com/a/2717524
tagged with: service-discovery
tagged with: sockets
has answer: http://stackoverflow.com/a/2717473
downvote count: 1
has body: Suppose I'm running several servers serving basic requests on my local network (say a home network, where all machines generally have an IP in the form K.K.K.x, where x is variable). Is there an easy way to discover all such servers? I would need to find each IP on the network running a particular java server application.
score: 2
possible better answer: http://stackoverflow.com/a/2717511
has answer: http://stackoverflow.com/a/2717511
has answer: http://stackoverflow.com/a/2717507
type: Question
has answer: http://stackoverflow.com/a/2717495
type: AnsweredQuestion
tagged with: java
answer count: 6
accepted answer: http://stackoverflow.com/a/2717473
has title: How to discover web servers on a local network?
favorite count: 0
upvote count: 3

http://stackoverflow.com/comment/2651930
score: 0
has text: For now it is yes, There was a comment on the google groups about support for sending dtmf tones during a voice call in future upgrades from a Google developer
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/2636252

http://stackoverflow.com/comment/2721449
type: Comment
comment on: http://stackoverflow.com/a/2697177
has text: Think more of your code is needed to understand the problem. Checked your not squaring the value and losing the sign?
type: AnswerComment
score: 0

http://stackoverflow.com/q/2758642
favorite count: 0
has answer: http://stackoverflow.com/a/3085648
type: Question
has answer: http://stackoverflow.com/a/28295628
has comment: http://stackoverflow.com/comment/44943556
possible better answer: http://stackoverflow.com/a/28295628
upvote count: 2
answer count: 2
accepted answer: http://stackoverflow.com/a/3085648
tagged with: java
tagged with: rcp
has body: Is it possible, when developing an Eclipse RCP Application, to stack a view with the editor area? Like this? I have multiple lists/tables and I want to create a kind of preview composite. When an Item on a list is selected by single mouse click, I want my preview composite to show the data of the item. If the user double clicks an item, I want to open an editor in the stack behind the preview composite. Is there anyway to achieve this? Thanks.
tagged with: eclipse
type: AnsweredQuestion
score: 2
has title: Eclipse RCP - Stacking a view with the editor area?
linked to: http://stackoverflow.com/q/22921306
downvote count: 0

http://stackoverflow.com/a/2622870
type: Answer
downvote count: 2
score: -2
answers question: http://stackoverflow.com/q/2622690
has body: Most of the time, Apple folks uses preferences list format (or its XML counterpart). As an example, it is the case for iPoho Library file. I have had success parsing this file using commons configuration in the past. Maybe you could try it.
upvote count: 0
has comment: http://stackoverflow.com/comment/20541287
has comment: http://stackoverflow.com/comment/2650452
has comment: http://stackoverflow.com/comment/20539594

http://stackoverflow.com/a/2780964
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/53510016
upvote count: 14
score: 14
has comment: http://stackoverflow.com/comment/2815853
has body: When you create child1, check if child2 has already been instantiated. If it is, it means child1 is on the right, because it has been created later, so you have to do this: child1.moveAbove( child2 ); Hope it helps.
answers question: http://stackoverflow.com/q/2780694
accepted answer of: http://stackoverflow.com/q/2780694
type: AcceptedAnswer

http://stackoverflow.com/comment/2798855
type: Comment
type: QuestionComment
has text: Yeah i agree i thought i was missing something, its basically an exam question which had me a bit stumped. Thats the reason i posted anyway. Thanks for commenting.
score: 0
comment on: http://stackoverflow.com/q/2766293

vb6
type: Tag
tag name: vb6
tags question: http://stackoverflow.com/q/2748018

http://stackoverflow.com/comment/10266948
type: Comment
has text: Compressed object pointers introduced in Hotspot 6u14 help mitigate this. http://wikis.sun.com/display/HotSpotInternals/CompressedOops
score: 1
comment on: http://stackoverflow.com/a/2623551
type: AnswerComment

http://stackoverflow.com/comment/2730865
comment on: http://stackoverflow.com/a/2706784
type: Comment
score: 0
type: AnswerComment
has text: I'm not talking about web technologies only - I'm talking about technologies that you'd generally use to develop web applications. It would be pretty rare for a web application not to have some sort of data access, and in the vast majority of these cases, it's going to be a relational database.

http://stackoverflow.com/comment/2784238
has text: Im trying to launch a Java app i created :)
type: Comment
comment on: http://stackoverflow.com/q/2753371
type: QuestionComment
score: 0

http://stackoverflow.com/comment/64517473
has text: How exactly is this meant?
score: 0
comment on: http://stackoverflow.com/a/24375664
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/8501916
has text: well its still encrypted right? it just could be coming from anyone or being intercepted by anyone...
score: 2
comment on: http://stackoverflow.com/a/4837230
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2804714
type: AnswerComment
has text: Thanks, I guess this can be helpful too. But I will try BULK INSERT first, it seems more promising!
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2766115

http://stackoverflow.com/q/2625466
linked to: http://stackoverflow.com/q/1979785
has comment: http://stackoverflow.com/comment/2638624
has title: Java: Ignoring escapes when parsing XML
possible better answer: http://stackoverflow.com/a/2625555
tagged with: escaping
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/2625554
has comment: http://stackoverflow.com/comment/2638379
tagged with: java
has answer: http://stackoverflow.com/a/2625805
has comment: http://stackoverflow.com/comment/2638365
accepted answer: http://stackoverflow.com/a/2625681
type: Question
score: 4
has answer: http://stackoverflow.com/a/2625681
has body: I'm using a DocumentBuilder to parse XML files. However, the specification for the project requires that within text nodes, strings like &amp;quot; and &amp;lt; be returned literally, and not decoded as characters (" and &lt;). A previous similar question, Read escaped quote as escaped quote from xml, received one answer that seems to be specific to Apache, and another that appears to simply not not do what it says it does. I'd love to be proven wrong on either count, however :) For reference, here is some code: file = new File(fileName); DocBderFac = DocumentBuilderFactory.newInstance(); DocBder = DocBderFac.newDocumentBuilder(); doc = DocBder.parse(file); NodeList textElmntLst = doc.getElementsByTagName(text); Element textElmnt = (Element) textElmntLst.item(0); NodeList txts = textElmnt.getChildNodes(); String txt = ((Node) txts.item(0)).getNodeValue(); System.out.println(txt); I would like that println() to produce things like &amp;quot;3&amp;gt;2&amp;quot; instead of "3&gt;2" which is what currently happens. Thanks!
favorite count: 0
has answer: http://stackoverflow.com/a/2625555
upvote count: 4
answer count: 4
has comment: http://stackoverflow.com/comment/2638292
tagged with: http://stackoverflow.com/tag/xml

http://stackoverflow.com/comment/22675329
comment on: http://stackoverflow.com/a/10473835
score: 2
type: AnswerComment
has text: I really like this solution, very C like. Conceptually a great solution, however, it does not work for normal cases. It will only work from a..z case sensitive. No spaces supported. This would work miracles in a 256bit system to process the entire ASCII range. But it does run in O(N). I still +1 this one.
type: Comment

http://stackoverflow.com/a/2627907
answers question: http://stackoverflow.com/q/2627889
type: Answer
upvote count: 1
score: 1
downvote count: 0
has body: You've got two different objects that happen to contain the same values, because you've called new twice. One approach you might use is to create a "holder" class of your own, and define that class's equals and hash methods.

http://stackoverflow.com/a/44721066
has body: Start another activity from this activity and pass parameters via Bundle Object Intent intent = new Intent(getBaseContext(), YourActivity.class); intent.putExtra("USER_NAME", "xyz@gmail.com"); startActivity(intent); Retrieve data on another activity (YourActivity) String s = getIntent().getStringExtra("USER_NAME"); This is ok for a simple kind of data type. But if u want to pass complex data in between activities. U need to serialize it first. Here we have Employee Model class Employee{ private String empId; private int age; print Double salary; getters... setters... } You can use Gson lib provided by google to serialize the complex data like this String strEmp = new Gson().toJson(emp); Intent intent = new Intent(getBaseContext(), YourActivity.class); intent.putExtra("EMP", strEmp); startActivity(intent); Bundle bundle = getIntent().getExtras(); String empStr = bundle.getString("EMP"); Gson gson = new Gson(); Type type = new TypeToken<Employee>() { }.getType(); Employee selectedEmp = gson.fromJson(empStr, type);
type: Answer
downvote count: 0
score: 6
answers question: http://stackoverflow.com/q/2736389
upvote count: 6

http://stackoverflow.com/comment/2794892
type: QuestionComment
has text: You're moving from server side J2EE to Windows Visual C++ desktop programming? What's next after that? COBOL?
score: 0
comment on: http://stackoverflow.com/q/2762556
type: Comment

http://stackoverflow.com/q/2610384
has body: I am trying to add badges to the icons in my android app. e.g. in the facebook app(for iPhone), in the home page the number of pending requests is shown on the requests icon. Can someone provide any links/ideas on how to do this? Thanks
has comment: http://stackoverflow.com/comment/67077135
favorite count: 0
type: UnansweredQuestion
tagged with: android
has answer: http://stackoverflow.com/a/22633205
has answer: http://stackoverflow.com/a/2610629
linked to: http://stackoverflow.com/q/17565307
has title: Android: add badge to icons internal to my app
score: 24
linked to: http://stackoverflow.com/q/2905542
type: Question
has answer: http://stackoverflow.com/a/2610600
tagged with: java
answer count: 6
tagged with: eclipse
upvote count: 25
has answer: http://stackoverflow.com/a/10810547
has answer: http://stackoverflow.com/a/32862628
has comment: http://stackoverflow.com/comment/66397862
downvote count: 1
has answer: http://stackoverflow.com/a/37560759

http://stackoverflow.com/a/10500258
has comment: http://stackoverflow.com/comment/14764442
upvote count: 1
has body: With OOP, you inherit both interface and implementation. Haskell type-classes allow these to be seperated. Two utterly unrelated types can both expose the same interface. Perhaps more importantly, Haskell allows class implementations to be added "after the fact". That is, I can invent some new type-class of my own, and then go and make all the standard pre-defined types be instances of this class. In an OO language, you [usually] can't easily add a new method to an existing class, no matter how useful that would be.
downvote count: 0
score: 1
type: Answer
has comment: http://stackoverflow.com/comment/14767369
answers question: http://stackoverflow.com/q/2685626

http://stackoverflow.com/q/2705002
downvote count: 0
answer count: 1
favorite count: 0
has title: Is there a tool for generating a DSL parser that does not require a runtime for the resultant parser?
tagged with: compiler-construction
accepted answer: http://stackoverflow.com/a/2705079
tagged with: bnf
upvote count: 2
tagged with: generator
score: 2
type: AnsweredQuestion
tagged with: java
has body: I'm doing a lot of work with a DSLs at the moment and was wondering if anyone knew of a tool that could generate a parser for my bnf specification that does not require a run-time library (pure java source parser)? I'm committed to using XTEXT for a future Eclipse plug-in but I need a nice small version for my library itself and don't want to add another jar dependency. It seems that ANTLR requires a run-time to parse files and I performed a Google search with no avail. Can anyone help out? Thanks, Chris
type: Question
has answer: http://stackoverflow.com/a/2705079

http://stackoverflow.com/comment/2665466
has text: @Chronos - Then you should limit your recursion by passing an integer to the methods, always decreasing it. At first the value should be n, and when it reaches 0 you return from the method without further callings.
comment on: http://stackoverflow.com/q/2649375
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/79274012
answers question: http://stackoverflow.com/q/2715118
score: 0
type: Answer
has body: The method I made fixes all of the problems with most popular solution on this thread (I think). If you have other HTML commands that you use—I only use center—you can remove them from the String before splitting it as well. If you want this to work for JButtons, just change the parameter to JButton and it will work. You can put this method in a repeater to continuously update font and it works. public void maxFont(JLabel label){ String sin = label.getText(); String[] ss = sin.replace(" ","").replace(" ", "").split(" "); int lines = ss.length; String s=""; FontMetrics fm = getFontMetrics(new JLabel().getFont()); int maxWidth=0; if(!sin.equals(ss[0])){ for (String sss : ss) { int p = fm.stringWidth(sss); if(p>maxWidth){ maxWidth=p; s=sss; } } }else { s=sin; maxWidth=fm.stringWidth(s); } int newWidth = (label.getWidth()/maxWidth)*10; int maxHeight = label.getHeight()*7/8/lines; int fontSize = Math.min(newWidth,maxHeight); label.setFont(new Font(label.getFont().getName(), Font.PLAIN, fontSize)); }

http://stackoverflow.com/comment/2682561
comment on: http://stackoverflow.com/a/2664417
has text: Actually, it would be simpler to choose an existing one. Hopefully someone will add an answer that lists some good alternatives.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/2697549
has answer: http://stackoverflow.com/a/2697681
has answer: http://stackoverflow.com/a/2697668
upvote count: 6
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2697668
score: 6
has answer: http://stackoverflow.com/a/2697598
has body: I have a db, that stores dates in OleDateTime format, in GMT timezone. I've implemented a class, extending Date in java to represent that in classic date format. But my class is locale-dependent (I'm in GMT+2). Therefore, it converts the date in the db as date - 2 hours. How do I make it convert the date correctly? I want my class to be locale-independent, always using GMT timezone. Actually, the question is: class MyOleDateTime extends Date { static { Locale.setDefault(WhatGoesHere?) } // ... some constructors // ... some methods }
type: Question
tagged with: gmt
tagged with: java
tagged with: locale
downvote count: 0
favorite count: 0
has title: How to make Date locale-independent?
answer count: 5
possible better answer: http://stackoverflow.com/a/2697752
has answer: http://stackoverflow.com/a/17151706
has answer: http://stackoverflow.com/a/2697752

http://stackoverflow.com/comment/2686276
has text: Andy Gherna took the time to link the Tomcat doc - it explains how Tomcat class loading works. +1'd him, it's a bit more of a full explanation than mine.
type: Comment
comment on: http://stackoverflow.com/a/2653377
score: 0
type: AnswerComment

http://stackoverflow.com/q/2623957
tagged with: jtable
has answer: http://stackoverflow.com/a/2623987
favorite count: 0
score: 6
tagged with: swing
has title: How to display a JTable in a JPanel with Java?
upvote count: 6
accepted answer: http://stackoverflow.com/a/2623987
has body: How to display a JTable in a JPanel with Java?
type: AnsweredQuestion
tagged with: java
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/2623985
downvote count: 0
tagged with: jpanel
possible better answer: http://stackoverflow.com/a/2623985

http://stackoverflow.com/q/2608245
tagged with: callback
favorite count: 0
has title: Java RMI timeout in callback
type: UnansweredQuestion
score: 1
tagged with: java
upvote count: 1
type: Question
tagged with: rmi
has body: We are using Java RMI for communication. An RMI client passes a processing request and an object with a callback method to an RMI server. The server invokes the callback when it is done with processing. The setup is similar to the one described in RMI Callbacks. Occasionally we are getting a "read time out" exception in the server upon invoking the callback method. The callback thread stalls for about a minute before the exception is raised. java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is: java.net.SocketTimeoutException: Read timed out at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:286) at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184) at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:110) at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:178) at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132) at $Proxy2.finished(Unknown Source) at com.unrisk.db.grid.GridTask.invokeCallback(com.unrisk.db.grid.GridTask:1292) at com.unrisk.db.grid.GridTask.invokeCallbacks(com.unrisk.db.grid.GridTask:1304) at com.unrisk.db.service.tasks.EquityMDTask.afterRun(com.unrisk.db.service.tasks.EquityMDTask:276) at com.unrisk.db.grid.GridTask.run(com.unrisk.db.grid.GridTask:720) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) Caused by: java.net.SocketTimeoutException: Read timed out 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) at java.io.DataInputStream.readByte(DataInputStream.java:248) at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPCh…
has answer: http://stackoverflow.com/a/2614864
answer count: 1
downvote count: 0

http://stackoverflow.com/q/2711118
has comment: http://stackoverflow.com/comment/8970818
answer count: 3
has comment: http://stackoverflow.com/comment/2735873
downvote count: 0
has answer: http://stackoverflow.com/a/29935739
has comment: http://stackoverflow.com/comment/2735897
favorite count: 0
has title: Multiple lines of text to a single map
has body: I've been trying to use Hadoop to send N amount of lines to a single mapping. I don't require for the lines to be split already. I've tried to use NLineInputFormat, however that sends N lines of text from the data to each mapper one line at a time [giving up after the Nth line]. I have tried to set the option and it only takes N lines of input sending it at 1 line at a time to each map: job.setInt("mapred.line.input.format.linespermap", 10); I've found a mailing list recommending me to override LineRecordReader::next, however that is not that simple, as that the internal data members are all private. I've just checked the source for NLineInputFormat and it hard codes LineReader, so overriding will not help. Also, btw I'm using Hadoop 0.18 for compatibility with the Amazon EC2 MapReduce.
has comment: http://stackoverflow.com/comment/3429276
has answer: http://stackoverflow.com/a/5398215
accepted answer: http://stackoverflow.com/a/2719496
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/3429376
score: 7
tagged with: java
has comment: http://stackoverflow.com/comment/8746814
possible better answer: http://stackoverflow.com/a/29935739
tagged with: mapreduce
upvote count: 7
type: Question
tagged with: hadoop
has answer: http://stackoverflow.com/a/2719496
has comment: http://stackoverflow.com/comment/2735895

http://stackoverflow.com/q/2607289
has answer: http://stackoverflow.com/a/36057027
has comment: http://stackoverflow.com/comment/27372396
has answer: http://stackoverflow.com/a/34428978
has body: How do I convert an array to a list in Java? I used the Arrays.asList() but the behavior (and signature) somehow changed from Java SE 1.4.2 (docs now in archive) to 8 and most snippets I found on the web use the 1.4.2 behaviour. For example: int[] numbers = new int[] { 1, 2, 3 }; Arrays.asList(numbers) on 1.4.2 returns a list containing the elements 1, 2, 3 on 1.5.0+ returns a list containing the array 'numbers' In many cases it should be easy to detect, but sometimes it can slip unnoticed: Assert.assertTrue(Arrays.asList(numbers).indexOf(4) == -1);
has answer: http://stackoverflow.com/a/2607327
has answer: http://stackoverflow.com/a/57836782
linked to: http://stackoverflow.com/q/2965747
has answer: http://stackoverflow.com/a/38920860
possible better answer: http://stackoverflow.com/a/30281879
has answer: http://stackoverflow.com/a/26076682
upvote count: 1315
has answer: http://stackoverflow.com/a/30281879
linked to: http://stackoverflow.com/q/322715
linked to: http://stackoverflow.com/q/2721546
type: AnsweredQuestion
tagged with: list
has answer: http://stackoverflow.com/a/25265142
has answer: http://stackoverflow.com/a/58846892
has answer: http://stackoverflow.com/a/75269723
has answer: http://stackoverflow.com/a/2607335
tagged with: java
has answer: http://stackoverflow.com/a/71921599
has answer: http://stackoverflow.com/a/76959848
has comment: http://stackoverflow.com/comment/2617440
downvote count: 1
has answer: http://stackoverflow.com/a/42602008
type: Question
has answer: http://stackoverflow.com/a/68451663
accepted answer: http://stackoverflow.com/a/2607335
has answer: http://stackoverflow.com/a/47542599
has comment: http://stackoverflow.com/comment/48700921
has title: Converting array to list in Java
has answer: http://stackoverflow.com/a/32695224
tagged with: arrays
has comment: http://stackoverflow.com/comment/2617486
has answer: http://stackoverflow.com/a/45366236
has answer: http://stackoverflow.com/a/69301974
has answer: http://stackoverflow.com/a/74139744
has answer: http://stackoverflow.com/a/49611856
answer count: 25
linked to: http://stackoverflow.com/q/27647407
has answer: http://stackoverflow.com/a/35932105
linked to: http://stackoverflow.com/q/26027396
score: 1314
has answer: http://stackoverflow.com/a/25594467
favorite count: 0
has answer: http://stackoverflow.com/a/44481846
has answer: http://stackoverflow.com/a/46058441

http://stackoverflow.com/q/2777045
has body: I have a jComboBox that I am populating with some objects. The objects are of a type which I have made myself, and include a String and an int. The object's toString method returns the String, which is displayed in the Combo Box. Now, I wish to select an item in the Combo Box with code. How do I do this? There are multiple items starting with the same letter Thanks
has answer: http://stackoverflow.com/a/2777073
tagged with: java
tagged with: swing
score: 9
type: Question
upvote count: 9
answer count: 2
downvote count: 0
favorite count: 0
has title: How to select item in jComboBox
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/58206580

http://stackoverflow.com/comment/2685167
type: AnswerComment
comment on: http://stackoverflow.com/a/2667281
score: 0
type: Comment
has text: I hope ur correct. because I assumed so and wrote my code accordingly. R u sure of it?

hudson
type: Tag
tags question: http://stackoverflow.com/q/2639636
tag name: hudson
tags question: http://stackoverflow.com/q/2689691
tags question: http://stackoverflow.com/q/2746113

http://stackoverflow.com/comment/2767554
type: QuestionComment
comment on: http://stackoverflow.com/q/2738792
has text: My usual solution to see where the problem is when it is this pronounced is to use `jstack` or similar, and check the stack traces. It might not be a CPU issue, perhaps it is trying to check a certificate with OCSP, which depends upon the performance of the OCSP server (which often sucks).
score: 0
type: Comment

http://stackoverflow.com/comment/75011177
score: 2
comment on: http://stackoverflow.com/a/37605954
type: AnswerComment
has text: I like the fact that it throws an AssertionError instead of an Exception. Too many developers still haven't learned that they shouldn't catch Exception if the code can only throw something like IOException. I've had bugs in my code get completely swallowed because somebody caught Exception. Assertions don't get caught in this trap. Exceptions are for situations that you expect to see in production code. As for logging, you should be logging all your errors too, even though errors are rare. For example, do you really want to let an OutOfMemoryError pass without logging it?
type: Comment

variables
tag name: variables
tags question: http://stackoverflow.com/q/2678997
tags question: http://stackoverflow.com/q/2647349
type: Tag
tags question: http://stackoverflow.com/q/2649573
tags question: http://stackoverflow.com/q/2665655
tags question: http://stackoverflow.com/q/2674554
tags question: http://stackoverflow.com/q/2685254
tags question: http://stackoverflow.com/q/2672399

http://stackoverflow.com/a/26727332
answers question: http://stackoverflow.com/q/2740725
upvote count: 74
has comment: http://stackoverflow.com/comment/139996998
has body: As always, check your local JVM's specific implementation but here is a quick way to check from the command line without having to code. &gt; java -version; java -Xmx1G -XX:+PrintFlagsFinal -Xmx2G 2&gt;/dev/null | grep MaxHeapSize java version "1.8.0_25" Java(TM) SE Runtime Environment (build 1.8.0_25-b17) Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode) uintx MaxHeapSize := 2147483648 {product} So you'll see in this case, the second instance of the argument (2G) is what takes precedence (at least in 1.8) and that has been my experience with most other modern versions as well.
score: 74
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/47765029

http://stackoverflow.com/comment/2715284
type: Comment
has text: In fact StreamTokenizer seems to be the fastest solution so far (please check my question update). But it still needs about 1400 ms to read necessary data.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2693483

http://stackoverflow.com/a/2654241
has comment: http://stackoverflow.com/comment/38621612
has comment: http://stackoverflow.com/comment/41077244
downvote count: 7
accepted answer of: http://stackoverflow.com/q/2653954
has comment: http://stackoverflow.com/comment/50751950
type: Answer
has comment: http://stackoverflow.com/comment/64748623
has comment: http://stackoverflow.com/comment/50751897
score: 16
has body: There is no "lock screen image" in Android. There most certainly is no "lock screen image" concept that is the same between stock Android, HTC Sense, MOTOBLUR, etc. This simply is not part of the Android SDK. The project that Mr. Rijk points to is a security violation that pretends to be a lock screen replacement.
has comment: http://stackoverflow.com/comment/50751664
type: AcceptedAnswer
upvote count: 23
answers question: http://stackoverflow.com/q/2653954

http://stackoverflow.com/q/2677079
downvote count: 0
type: Question
tagged with: jakarta-ee
score: 3
has answer: http://stackoverflow.com/a/2768621
tagged with: java
possible better answer: http://stackoverflow.com/a/2677284
tagged with: database
has body: I have the following code: Hashtable env1 = new Hashtable(); env1.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory"); log.info("Executed step 1"); env1.put(javax.naming.Context.PROVIDER_URL, "iiop://myhost.com:9301"); log.info("Executed step 2"); Context ctx = new InitialContext(env1); DataSource ds = (DataSource)ctx.lookup("jdbc/mydatasource"); log.info("Excecuted lookup ="+ds); conn = ds.getConnection(); I have the previous code in an standalone application that is connecting to WAS 6.1.0.3 in order to retrieve a connection from the datasource. The code is very straighforward, and I have seen the same code working in a different environment, but in this case when I call getConnection I get an exception. The datasource is WAS has the proper authentication alias set and when the connection is tested it works OK from the WAS side, but the previous code won't work. If I change this line: conn = ds.getConnection(); to this: conn = ds.getConnection("username","password"); Then the code will work! But that's not what I want since the connections in the datasource should already have the credentials set. I was initially thinking this was a Sybase problem, but it's also happening with Oracle, so would rather say I have a problem with WAS. If you are curious about the exceptions, for Sybase I get: java.sql.SQLException: JZ004: User name property missing in DriverManager.getConnection(..., Properties).DSRA0010E: SQL State = JZ004, Error Code = 0 at com.sybase.jdbc2.jdbc.ErrorMessage.raiseError(ErrorMessage.java:569) at com.sybase.jdbc2.tds.LoginToken.&lt;init&gt;(LoginToken.java:128) at com.sybase.jdbc2.tds.Tds.doLogin(Tds.java:506) at com.sybase.jdbc2.tds.Tds.login(Tds.java:449) at com.sybase.jdbc2.jdbc.SybConnection.tryLogin(SybConnection.java:254) at com.sybase.jdbc2.jdbc.SybConnection.regularConnect(SybConnection.java:230) at com.sybase.jdbc2.jdbc.SybConnection.&lt;init&gt;(SybConnection.java:200) at com.sybase.jdbc2.jdb…
has answer: http://stackoverflow.com/a/2678167
accepted answer: http://stackoverflow.com/a/2678167
upvote count: 3
tagged with: websphere
answer count: 3
favorite count: 0
has title: Call to DataSource.getConnection not returning the expected connection
has answer: http://stackoverflow.com/a/2677284
tagged with: jdbc
type: AnsweredQuestion

http://stackoverflow.com/comment/2697474
type: AnswerComment
has text: the whole example can be found here: http://java.sun.com/docs/books/tutorial/java/javaOO/constructors.html
type: Comment
score: 0
comment on: http://stackoverflow.com/a/2678132

http://stackoverflow.com/a/13253551
upvote count: 1
downvote count: 1
answers question: http://stackoverflow.com/q/2683914
has body: But the main problem is we can't compare spring with lift. Lift is basically use as UI framework and Spring is use as DI framework. If you are developing web app that does have that much of backend sure you can use lift. but if your developing web app that have some series backend and you definelty need to goto spring.
score: 0
type: Answer

http://stackoverflow.com/q/2629180
has answer: http://stackoverflow.com/a/2629249
downvote count: 0
answer count: 7
accepted answer: http://stackoverflow.com/a/2629470
favorite count: 0
upvote count: 8
has answer: http://stackoverflow.com/a/2629279
tagged with: garbage-collection
type: AnsweredQuestion
has body: I'm trying to monitor the gc activity in my app, using -verbosegc flag. I can see there are full and minor collections, but is there a way to determine (subscrbing to events/vm flags/whatever) which objects actually collected? Thanks!
has answer: http://stackoverflow.com/a/2629431
tagged with: java
has title: Java GC - is there a way to determine which objects collected
has answer: http://stackoverflow.com/a/2629245
type: Question
has answer: http://stackoverflow.com/a/2629441
has answer: http://stackoverflow.com/a/2629470
score: 8
has answer: http://stackoverflow.com/a/2629317
possible better answer: http://stackoverflow.com/a/2629249

http://stackoverflow.com/comment/2809489
type: Comment
has text: @voyager: I concur. I think this may be what you're referring to: http://msdn.microsoft.com/en-us/library/dd900818.aspx
score: 1
comment on: http://stackoverflow.com/q/2775409
type: QuestionComment

http://stackoverflow.com/q/2694589
has comment: http://stackoverflow.com/comment/2716522
has title: Java serialization problem
has answer: http://stackoverflow.com/a/2694694
downvote count: 0
favorite count: 0
tagged with: serialization
possible better answer: http://stackoverflow.com/a/2694694
has answer: http://stackoverflow.com/a/2694914
answer count: 4
has comment: http://stackoverflow.com/comment/2716353
has answer: http://stackoverflow.com/a/2694888
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/2716555
has body: I have two classes X and Y, like this: class X implements Serializable { int val1; Y val2; } class Y implements Serializable { int val; } I want to transmit an object of type X from a client to server but i can't because the class X has a field of type Y. I replaced the field of type Y with a field of type X in class X and it works. EDIT These are my classes: class Y implements Serializable { int val; Y() { val = 3; } } class X implements Serializable { int val; Y ob; X(int i, Y o) { val = i; ob = o; } } public class Server { public static void main(String[] s) { ServerSocket ss = null; Socket cs = null; ObjectInputStream ois = null; ObjectOutputStream oos = null; try { ss = new ServerSocket(1234); System.out.println("Server pornit!"); cs = ss.accept(); oos = new ObjectOutputStream(cs.getOutputStream()); ois = new ObjectInputStream(cs.getInputStream()); } catch(Exception e) { System.out.println("Exceptie!"); } System.out.println("Asteapta mesaj..."); X x; try { x = (X) ois.readObject(); System.out.println(x.val); } catch(Exception e) { System.out.println(e.toString()); } try { ss.close(); cs.close(); } catch(Exception e) { } } } public class Client { public static void main(String[] s) { Socket cs; ObjectInputStream ois = null; ObjectOutputStream oos = null; System.out.println("Connect..."); try { cs = new Socket("127.0.0.1",1234); oos = new ObjectOutputStream(cs.getOutputStream()); ois = new ObjectInputStream(cs.getInputStream()); } catch(Exception e) { System.out.println("Exceptie!"); } try { oos.writeObject(new X(8,new Y())); } catch(Exception e) { System.out.println(e.getMessage()); } } }
has comment: http://stackoverflow.com/comment/2716534
has comment: http://stackoverflow.com/comment/2716384
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2694789
has comment: http://stackoverflow.com/comment/2716681
accepted answer: http://stackoverflow.com/a/2694914
tagged with: java
type: Question

http://stackoverflow.com/a/2607728
downvote count: 0
score: 1
upvote count: 1
has body: You should always give members of a class the most restrictive visibility level possible. You can use private members of a class in any method contained in that class.
answers question: http://stackoverflow.com/q/2607676
type: Answer

http://stackoverflow.com/q/2613921
answer count: 3
has answer: http://stackoverflow.com/a/2613931
tagged with: graphics2d
downvote count: 0
score: 1
favorite count: 0
has answer: http://stackoverflow.com/a/2614058
has body: I'm about to create a java crossword application but I am unsure of what packages to use to draw the crossword grid. I know you can manually draw grids with Graphics2D etc. but I'm not sure if this is the easiest way to do it as I'll need text fields in the grid squares. Anyone have any suggestions as to creating the crossword grid.
accepted answer: http://stackoverflow.com/a/2613953
type: AnsweredQuestion
tagged with: crossword
has title: Java Crossword Application - what package to use?
upvote count: 1
type: Question
tagged with: java
has answer: http://stackoverflow.com/a/2613953
possible better answer: http://stackoverflow.com/a/2613931

http://stackoverflow.com/q/2630514
has answer: http://stackoverflow.com/a/2630550
tagged with: serialization
answer count: 5
has answer: http://stackoverflow.com/a/2630571
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2630563
has body: In a java serialization problem, I want to save some classes name and I have some problems with generic classes. For example : - If I have ArrayList&lt;String&gt; listToDump = new ArrayList&lt;String&gt;(); - If I take the name : listToDump.getName(); or listToDump.getCanonicalName(); - I will have java.util.ArrayList or ArrayList - And I want to have java.util.ArrayList&lt;String&gt; or ArrayList&lt;String&gt; Any ideas on how I can do this? Damien.
score: 3
upvote count: 3
tagged with: java
has title: Get a class name with generics information
type: Question
accepted answer: http://stackoverflow.com/a/2630563
has answer: http://stackoverflow.com/a/2630591
has answer: http://stackoverflow.com/a/8867224
downvote count: 0
possible better answer: http://stackoverflow.com/a/2630591
tagged with: generics
favorite count: 0

http://stackoverflow.com/a/2681099
type: AcceptedAnswer
score: 28
has comment: http://stackoverflow.com/comment/2702434
type: Answer
has comment: http://stackoverflow.com/comment/31464741
accepted answer of: http://stackoverflow.com/q/2680837
has comment: http://stackoverflow.com/comment/26460071
answers question: http://stackoverflow.com/q/2680837
has comment: http://stackoverflow.com/comment/31479164
downvote count: 0
upvote count: 28
has body: the third / is in the wrong place, the file url is contructed with file:///&lt;path&gt;

http://stackoverflow.com/a/2683991
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2683958
has body: Null pointer exceptions are extensions of Runtime exceptions and are therefore unexpected occurances in your program flow. It wouldn't make sense to expect a null pointer exception to be thrown (I hope!) and therefore you would never declare it as a checked exception.
score: 12
upvote count: 12

http://stackoverflow.com/comment/2689435
has text: OK, Cool, it is a zipped XML format. I changed the filename to .zip and was able to read the file. Thanks.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2667973
type: Comment

http://stackoverflow.com/comment/2699090
comment on: http://stackoverflow.com/a/2677184
score: 0
type: AnswerComment
type: Comment
has text: So, Noway. Thanks too much. I cannot tell you how I am thoughtful to you. Thanks for your time and your patient. BTW, I get happy once see you replying my dump Questions :)

http://stackoverflow.com/a/2640157
type: Answer
has comment: http://stackoverflow.com/comment/2654713
score: 3
has body: This sounds like the classic consumer-producer problem. Have a look at Wikipedia's article about it. They have plenty of pseudo code there.
upvote count: 3
downvote count: 0
answers question: http://stackoverflow.com/q/2640135

http://stackoverflow.com/a/2707916
downvote count: 0
type: Answer
score: 1
has body: What do you mean by automatically? My plugin lets one create fields with Getters or Setters. You might look into this : http://fast-code.sourceforge.net/. It has simple popup as below: (source: sourceforge.net) I should mention that eclipse has create Getters/Setters from the source menu. It also puts a marker beside any private member. Then one just needs to press Ctrl-1. Problem with that is it creates both getters or setters.
answers question: http://stackoverflow.com/q/2707912
upvote count: 1

http://stackoverflow.com/a/20056245
score: 92
has comment: http://stackoverflow.com/comment/98093161
has comment: http://stackoverflow.com/comment/100250515
has body: In my experience there are three main solutions, each with its disadvantages and advantages: Implementing Parcelable Implementing Serializable Using a light-weight event bus library of some sort (for example, Greenrobot's EventBus or Square's Otto) Parcelable - fast and Android standard, but it has lots of boilerplate code and requires hard-coded strings for reference when pulling values out the intent (non-strongly typed). Serializable - close to zero boilerplate, but it is the slowest approach and also requires hard-coded strings when pulling values out the intent (non-strongly typed). Event Bus - zero boilerplate, fastest approach, and does not require hard-coded strings, but it does require an additional dependency (although usually lightweight, ~40 KB) I posted a very detailed comparison of these three approaches, including efficiency benchmarks.
has comment: http://stackoverflow.com/comment/99910657
has comment: http://stackoverflow.com/comment/84392330
upvote count: 92
type: Answer
has comment: http://stackoverflow.com/comment/135771181
has comment: http://stackoverflow.com/comment/88620579
downvote count: 0
has comment: http://stackoverflow.com/comment/73390971
has comment: http://stackoverflow.com/comment/84276982
answers question: http://stackoverflow.com/q/2736389
has comment: http://stackoverflow.com/comment/76601675

http://stackoverflow.com/a/2721217
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2747277
type: Answer
upvote count: 13
answers question: http://stackoverflow.com/q/2721194
score: 13
has body: You can absolutely attribute parameters: public Factory([Inject("name")] String name, [Inject("value")] String value) Of course the attribute has to be declared to permit it to be specified for parameters via AttributeUsageAttribute(AttributeTargets.Parameter). See OutAttribute and DefaultParameterValueAttribute as examples.
accepted answer of: http://stackoverflow.com/q/2721194

http://stackoverflow.com/comment/2761187
comment on: http://stackoverflow.com/a/2727867
score: 0
type: AnswerComment
has text: I agree, normally you don’t secure internal API’s. A database is such an internal API and it should not be exposed. So the database ports should never be publicly accessible and reside behind a firewall.
type: Comment

http://stackoverflow.com/q/2620011
has title: Object type to Reader type?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2620481
score: 0
tagged with: java
possible better answer: http://stackoverflow.com/a/2620051
type: Question
has answer: http://stackoverflow.com/a/2620051
has answer: http://stackoverflow.com/a/2620042
accepted answer: http://stackoverflow.com/a/2620481
answer count: 3
has body: I have a java.io.Reader as the return type of my method. But i have Object type of an instance which i get from Database. So how can I convert this to Reader type and return? I have the following code where getByteArrayObject() return a byte array. and the same i need to return, but the return type is Reader which i cant change. public Reader getMediaReader(String arg0) { // TODO Auto-generated method stub Object obj = getByteArrayObject(); System.out.println("HELLO I AM DETCTED....... in getMediaReader"); return null; } need help thanks.

http://stackoverflow.com/comment/2741113
comment on: http://stackoverflow.com/a/2715460
type: Comment
has text: I'm pretty sure you can install more secure PRNGs and then ask for it by name using [`SecureRandom.getInstance(String)`](http://java.sun.com/javase/6/docs/api/java/security/SecureRandom.html#getInstance(java.lang.String)).
score: 0
type: AnswerComment

http://stackoverflow.com/comment/29464611
comment on: http://stackoverflow.com/a/2732264
has text: Any relevant link in Java documentation saying that it happens for all Output Streams? As far as I could find though the API the surety for this is given in some Classes while in others there is no such surety.
type: AnswerComment
type: Comment
score: 11

http://stackoverflow.com/comment/2731904
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2707913
score: 1
has text: But i am not updating database outside of JPA. I used persist method of jpa and record is seen in database. But when i retrieve list, i don't see the newly added entity. Please help me.

http://stackoverflow.com/comment/56281644
score: 0
comment on: http://stackoverflow.com/a/2616827
type: AnswerComment
has text: Great - glad to hear that this has gotten better in the 5.5 years that has passed since I originally answered the question. Actually I thought that Eclipse has but in name entered maintenance mode.
type: Comment

http://stackoverflow.com/a/55350052
answers question: http://stackoverflow.com/q/2770321
type: Answer
has body: Avoid raw types. Raw types refer to using a generic type without specifying a type parameter. For example: A list is a raw type, while List<String> is a parameterized type. When generics were introduced in JDK 1.5, raw types were retained only to maintain backwards compatibility with older versions of Java. Although using raw types is still possible, they should be avoided: They usually require casts. They aren't type safe, and some important kinds of errors will only appear at runtime. They are less expressive, and don't self-document in the same way as parameterized types.. Example: import java.util.*; public final class AvoidRawTypes { void withRawType() { //Raw List doesn't self-document, //doesn't state explicitly what it can contain List stars = Arrays.asList("Arcturus", "Vega", "Altair"); Iterator iter = stars.iterator(); while (iter.hasNext()) { String star = (String) iter.next(); //cast needed log(star); } } void withParameterizedType() { List < String > stars = Arrays.asList("Spica", "Regulus", "Antares"); for (String star: stars) { log(star); } } private void log(Object message) { System.out.println(Objects.toString(message)); } } For reference: https://docs.oracle.com/javase/tutorial/java/generics/rawTypes.html
downvote count: 0
score: 8
upvote count: 8

http://stackoverflow.com/q/2781672
has answer: http://stackoverflow.com/a/2781760
has answer: http://stackoverflow.com/a/2781726
accepted answer: http://stackoverflow.com/a/2782040
tagged with: generics
answer count: 4
has comment: http://stackoverflow.com/comment/79722213
possible better answer: http://stackoverflow.com/a/2781738
has title: When is a parameterized method call useful?
has answer: http://stackoverflow.com/a/2781738
upvote count: 23
tagged with: parameters
type: AnsweredQuestion
tagged with: call
has comment: http://stackoverflow.com/comment/79691224
tagged with: java
has answer: http://stackoverflow.com/a/2782040
score: 23
tagged with: methods
type: Question
downvote count: 0
has body: A Java method call may be parameterized like in the following code: class Test { &lt;T&gt; void test() { } public static void main(String[] args) { new Test().&lt;Object&gt;test(); // ^^^^^^^^ } } I found out this is possible from the Eclipse Java Formatter settings dialog and wondered if there are any cases where this is useful or required. EDIT Based on Arne's excellent answer i came up with the following conclusion: In addition to improved type safety as Arne's example illustrates a parameterized method call enables you to specify the common base type of the methods arguments that should be the type of the container elements. This type is normally inferenced automatically by the compiler to the most specific common base type. By parameterizing the method call this behaviour may be overridden. A parameterized method call may be required if there are multiple common types inferenced by the compiler. The following example demonstrates that behaviour: import java.util.Arrays; import java.util.List; class Test { public static void main(String[] args) { Integer a=new Integer(0); Long b=new Long(0); List&lt;Object&gt; listError=Arrays.asList(a, b); //error because Number&amp;Comparable&lt;?&gt; is not Object List&lt;Object&gt; listObj=Arrays.&lt;Object&gt;asList(a, b); List&lt;Number&gt; listNum=Arrays.&lt;Number&gt;asList(a, b); List&lt;Comparable&lt;?&gt;&gt; listCmp=Arrays.&lt;Comparable&lt;?&gt;&gt;asList(a, b); } } This behaviour is defined in The Java Language Specification Third Edition paragraphs 8.4.4 and 15.12.2.7 but not easily understood.
favorite count: 0

http://stackoverflow.com/comment/2699723
score: 1
type: AnswerComment
type: Comment
has text: Unless I'm mistaken, `"(?s)^.*$(?<=[aeiou]{3})"` should be optimizable to `O(1)`. The way I understand it, in single-line `(?s)/Pattern.DOTALL` mode, `^.*$` is an instant `O(1)` match to everything. The lookbehind from the `$` anchor is "obviously" a simple suffix matching attempt. I think it's very possible that some sophisticated regex implementation can optimize this to `O(1)`, no?
comment on: http://stackoverflow.com/a/2679869

http://stackoverflow.com/comment/2624556
comment on: http://stackoverflow.com/a/2613553
type: AnswerComment
has text: it seems that a declaration attaches a var to a block such such as if-else, method, class and perhaps something else.
score: 0
type: Comment

http://stackoverflow.com/comment/2706601
score: 1
has text: How is it not working? What is it doing that is "wrong"? Wrong result, exception, etc?
comment on: http://stackoverflow.com/q/2686236
type: Comment
type: QuestionComment

http://stackoverflow.com/a/2673654
upvote count: 1
has body: Get the Eclipse Pulsar release from http://www.eclipse.org/pulsar/. It provides the integration with the S60 SDKs.
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/2629228
type: Answer

http://stackoverflow.com/comment/2680788
score: 0
type: Comment
has text: JSP is quite capable of doing those things.
comment on: http://stackoverflow.com/a/2663144
type: AnswerComment

http://stackoverflow.com/a/2610932
type: Answer
has comment: http://stackoverflow.com/comment/2625892
downvote count: 0
has comment: http://stackoverflow.com/comment/2625916
has body: How do you specify a custom compilerId that points to your own ajc compiler (that is make compile:compile use an aspectj compiler other than the plexus one)? I don't know how to specify another compilerId than the "official" ones. Not sure it's possible. My understanding is that http://jira.codehaus.org/browse/MCOMPILER-107 would solve your problem (AspectJ 1.6+ does support Java 1. 6 right?). Sadly, it's still open. How do you ignore the failure of compile:compile? The compiler:compile goal of the Maven Compiler plugin has a failOnError optional parameter allowing to Indicate whether the build will continue even if there are compilation errors. ... ... ... maven-compiler-plugin 2.2 false ... This could be a ugly workaround to the above problem. How do you get maven to run the aspectj:compile goal directly, without ever running compile:compile? The problem is that compiler:compile is bound to the compile phase and that you can't remove a default lifecyle binding. So there is maybe another option but the only one I can think of would be to turn everything off by using a <packaging>pom<packaging> and to rebind all the goals manually (at least for these phases: process-resources, compile, process-test-resources, test-compile, test, package). Schematically, something like this: process-resources resources:resources compile aspectj:compile process-test-resources resources:testResources test-compile compiler:testCompile test surefire:test package ejb:ejb or ejb3:ejb3 or jar:jar or par:par or rar:rar or war:war install install:install deploy deploy:deploy That could be another ugly workaround. Disclaimer: not tested but should work.
has comment: http://stackoverflow.com/comment/2625865
answers question: http://stackoverflow.com/q/2610633
score: 1
has comment: http://stackoverflow.com/comment/2625420
upvote count: 1

http://stackoverflow.com/comment/2731816
comment on: http://stackoverflow.com/a/2707830
has text: Also i got the following while googling :- http://wiki.eclipse.org/FAQ_How_do_I_write_to_the_console_from_a_plug-in%3F and http://stackoverflow.com/questions/104254/java-io-console-support-in-eclipse-ide while googling.....
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/2654449
type: QuestionComment
comment on: http://stackoverflow.com/q/2639943
score: 0
type: Comment
has text: Is the resource file in the same folder as the class file? Is this a standalone application or running in a web server?

http://stackoverflow.com/comment/2703186
comment on: http://stackoverflow.com/q/2683466
type: Comment
type: QuestionComment
score: 2
has text: Yes, and what is the question?

http://stackoverflow.com/comment/2703160
has text: I know this is nitpicking, but shouldn't your argument have a two-argument constructor that takes the exception that caused the current exception? All the framework exceptions do...
comment on: http://stackoverflow.com/q/2683328
type: Comment
type: QuestionComment
score: 0

http://stackoverflow.com/a/2662393
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/2679807
answers question: http://stackoverflow.com/q/2662333
downvote count: 0
type: Answer
has body: I think the core of your problem is here: for(Animal a : shelter.getTopFloor()){ a.growl(); } How is shelter defined?

http://stackoverflow.com/a/2624408
score: 5
has comment: http://stackoverflow.com/comment/2637108
has body: No but you can re-arrange it to make it better, or write a wrapper if it irks you: if (InRange(x, 10, 20)) { ... } Or, as Carl says: if (new Range(10, 20).contains(x)) { ... } Though personally, I don't see the point. It's a useless abstraction. The bare boolean statement is perfectly obvious. Though, now that I think about it, and in light of Carl's comment below, there are times when a Range is a perfectly valid and useful abstraction (e.g. when dealing with Feeds). So, depending on the semantics of x, maybe you do want an abstraction.
upvote count: 5
type: Answer
answers question: http://stackoverflow.com/q/2624393
has comment: http://stackoverflow.com/comment/2637176
downvote count: 0
has comment: http://stackoverflow.com/comment/2637117
has comment: http://stackoverflow.com/comment/2637177

http://stackoverflow.com/a/2769440
downvote count: 0
upvote count: 2
type: Answer
score: 2
has body: I suppose that you use the default model. You can obtain the selected cell and display the content by writing something like this : int i = jTable1.getSelectedRow(); int j = jTable1.getSelectedColumn(); JOptionPane.showMessageDialog(null, jTable1.getModel().getValueAt(i, j)); Or if you want , use getRowCount() and getColumnCount() to get other cells value. But all that explanation depends on one question: how did you create/fill the table - as @nc3b said ?
answers question: http://stackoverflow.com/q/2769155

http://stackoverflow.com/a/12703579
type: Answer
answers question: http://stackoverflow.com/q/2750289
has body: WebLogic doesn't support embedded mode like Glassfish but you can have control over your Weblogic using "WebLogic Maven Plugin", this provide several maven goals for managing and working with Weblogic instance. See this link for further information.
score: 0

http://stackoverflow.com/a/7833447
has body: You can do this by the following code: SVTableModel model = new SVTableModel(sheet); lastRowNum = model.getRowCount(); However, I am trying to do this in Apache POI 3.7 but couldn't find the SVTableModel in the API. This has been removed since 3.2, I guess.
answers question: http://stackoverflow.com/q/2645566
score: 0
type: Answer

http://stackoverflow.com/comment/2683323
score: 0
type: Comment
type: QuestionComment
has text: Take a look at http://stackoverflow.com/questions/2527021/how-to-disable-minimize-button-in-frame and see if that answers your question.
comment on: http://stackoverflow.com/q/2665355

http://stackoverflow.com/comment/2680886
comment on: http://stackoverflow.com/q/2663199
has text: Add an ActionListener to the button (see e.g. http://java.sun.com/docs/books/tutorial/uiswing/events/actionlistener.html) in which you open the second dialog.
type: Comment
type: QuestionComment
score: 1

http://stackoverflow.com/comment/2684667
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/2666012
has text: A break would end the for-loop immediately. As the loop contains more code, than only the method-call, I assume a break isn't intended.
type: Comment

http://stackoverflow.com/comment/2806867
type: Comment
has text: Leave those 100.000 rows in the DB. Query **only** those you **need** to display per page. Google also doesn't query those zillion of rows at once to only show the first ten ones on the result page.
comment on: http://stackoverflow.com/a/2772937
type: AnswerComment
score: 4

http://stackoverflow.com/comment/2650694
type: Comment
score: 1
has text: @sarah It would be better if you post your code.
comment on: http://stackoverflow.com/q/2636645
type: QuestionComment

http://stackoverflow.com/q/2763340
downvote count: 0
tagged with: java
has body: I am able to insert, filter and order records but can't use a simple count!! I am wondering if there a way to get no of total rows in a table?? Is there a way to use GROUP BY in query?
possible better answer: http://stackoverflow.com/a/2770907
type: Question
score: 3
upvote count: 3
answer count: 2
has title: Google App-Engine Java Group By and Count(*) queries
favorite count: 0
has answer: http://stackoverflow.com/a/2770907
tagged with: google-app-engine
has answer: http://stackoverflow.com/a/2763799
accepted answer: http://stackoverflow.com/a/2763799
type: AnsweredQuestion

http://stackoverflow.com/a/2649378
type: Answer
score: 2
downvote count: 0
has body: If you're talking full boat Java EE, then Glassfish. GFv2.1 is rock solid, GFv3 is too young to say, but offers new Java EE 6. Actively developed, free and commercial support, good forums. Oracle has published it roadmap for it. It's easy to use, easy to configure, well organized. Great console. Really well documented, vast amounts of supplementary documents and article from folks working different aspects of it (Metro, Grizzly, JAX-RS, NetBeans, etc.) NetBeans + Glassfish is a painless out of box experience to get started. Offers clustering and all sorts of management options.
upvote count: 2
answers question: http://stackoverflow.com/q/2648145

http://stackoverflow.com/a/2727719
type: Answer
upvote count: 29
score: 29
has comment: http://stackoverflow.com/comment/10553757
downvote count: 0
has body: Calendar tCalendar = Calendar.getInstance(); tCalendar.setTime(date); date is a java.util.Date object. You may use Calendar.getInstance() as well to obtain the Calendar instance(much more efficient).
answers question: http://stackoverflow.com/q/2727698

http://stackoverflow.com/comment/2814998
comment on: http://stackoverflow.com/a/2780170
type: Comment
score: 1
type: AnswerComment
has text: Nice solution. That's the one I came to think of as well. I usually populate the map inside `static { ... }`

http://stackoverflow.com/q/2612057
has answer: http://stackoverflow.com/a/2612309
upvote count: 2
possible better answer: http://stackoverflow.com/a/2612129
score: 2
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2612109
tagged with: java
tagged with: hibernate
accepted answer: http://stackoverflow.com/a/2612309
type: Question
downvote count: 0
has body: I'm hesitating between two designs of a database project using Hibernate. Design #1. (1) Create a general data provider interface, including a set of DAO interfaces and general data container classes. It hides the underneath implementation. A data provider implementation could access data in database, or an XML file, or a service, or something else. The user of a data provider does not to know about it. (2) Create a database library with Hibernate. This library implements the data provider interface in (1). The bad thing about Design #1 is that in order to hide the implementation details, I need to create two sets of data container classes. One in the general data provider interface - let's call them DPI-Objects, the other set is used in the database library, exclusively for entity/attribute mapping in Hibernate - let's call them H-Objects. In the DAO implementation, I need to read data from database to create H-Objects (via Hibernate) and then convert H-Objects into DPI-Objects. Design #2. Do not create a general data provider interface. Expose H-Objects directly to components that use the database lib. So the user of the database library needs to be aware of Hibernate. I like design #1 more, but I don't want to create two sets of data container classes. Is that the right way to hide H-Objects and other Hibernate implementation details from the user who uses the database-based data provider? Are there any drawbacks of Design #2? I will not implement other data provider in the new future, so should I just forget about the data provider interface and use Design #2? What do you think about this? Thanks for your time!
has title: About Data Objects and DAO Design when using Hibernate
favorite count: 0
answer count: 3
has answer: http://stackoverflow.com/a/2612129

http://stackoverflow.com/q/2757066
has answer: http://stackoverflow.com/a/2757301
has body: Is there any mechanism within the Eclipse debugging environment to see the state of synchronization locks held and processes waiting?
has answer: http://stackoverflow.com/a/65808750
possible better answer: http://stackoverflow.com/a/2757295
answer count: 3
has answer: http://stackoverflow.com/a/2757295
downvote count: 0
has comment: http://stackoverflow.com/comment/2788621
favorite count: 0
has comment: http://stackoverflow.com/comment/2788726
accepted answer: http://stackoverflow.com/a/2757301
has title: debugging Java synchronization
score: 14
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/2081766
upvote count: 14
tagged with: java
type: Question

http://stackoverflow.com/comment/2691385
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2670366
has text: Chances are that Solr's index versuin is more advanced than Zend's. You may want to consider going an extra step, using Solr for search as well and communicating with PHP via an HTTP interface, such as XML or JSON.

http://stackoverflow.com/a/2617446
type: Answer
downvote count: 0
score: 3
has body: You need to look at the JNI functions GetMethodID and Call&lt;type&gt;Method*. The details of the various variants and how to call them are documented the JNI specification.
upvote count: 3
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2617313
answers question: http://stackoverflow.com/q/2617313

http://stackoverflow.com/q/2624319
score: 2
type: AnsweredQuestion
tagged with: java
type: Question
has body: I have the requirement of updating an app to use multiple (i.e., two in this case) datasources depending upon the type of query. For instance, use DB1 for reads and DB2 for write operations. How would I approach this?
has answer: http://stackoverflow.com/a/2657562
accepted answer: http://stackoverflow.com/a/2657562
has comment: http://stackoverflow.com/comment/2637153
has title: Using different datasources for particular queries with Spring and IBATIS
downvote count: 0
answer count: 1
favorite count: 0
tagged with: ibatis
upvote count: 2
tagged with: spring

http://stackoverflow.com/q/2619429
has answer: http://stackoverflow.com/a/2619899
has title: C# to Java: where T : new() Syntax
type: AnsweredQuestion
score: 4
has body: I am porting some C# code over to Java. I am having trouble with the where Syntax, specifically new(). I understand that where is similar to Java's generic: T extends FOO. How I can replicate the new() argument in Java? "The new() Constraint lets the compiler know that any type argument supplied must have an accessible parameterless--or default-- constructor." - MSDN ie: public class BAR&lt;T&gt; : BAR where T : FOO, new() Here is how I implemented cletus's solution: public class BAR&lt;T extends FOO&gt; extends ABSTRACTBAR { public BAR(T t) throws InstantiationException, IllegalAccessException{ t.getClass().newInstance(); this.value = t; } }
tagged with: java
accepted answer: http://stackoverflow.com/a/2619436
type: Question
upvote count: 4
tagged with: c#
downvote count: 0
answer count: 3
tagged with: generics
possible better answer: http://stackoverflow.com/a/2619438
favorite count: 0
has answer: http://stackoverflow.com/a/2619436
has answer: http://stackoverflow.com/a/2619438

http://stackoverflow.com/comment/2744511
comment on: http://stackoverflow.com/a/2718636
type: AnswerComment
has text: @Edward, in both UNIX and Windows, mutex is a particular primitive that supports lock, unlock, and trylock. Whereas the Java monitor also supports wait and notify which are aspects of condition variables.
type: Comment
score: 1

http://stackoverflow.com/comment/84746300
type: Comment
comment on: http://stackoverflow.com/a/32201073
has text: yes the record exists , but my problem is why hibernate try to update , i'm just using a select service to get the object from the database !
score: 0
type: AnswerComment

http://stackoverflow.com/a/2660705
type: Answer
answers question: http://stackoverflow.com/q/2660522
has comment: http://stackoverflow.com/comment/2677961
upvote count: 2
has comment: http://stackoverflow.com/comment/2678031
score: 2
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2678163
has body: Unless escaped at the regex level, $ means match the end of line. And to get the single \ needed to escape the $ it needs to be escaped in the String literal; i.e. two \ characters. So ... ... Pattern.compile("\"blue\"&gt;&amp;nbsp;&amp;nbsp;\\$&amp;nbsp;(.*)&amp;nbsp;&lt;/font&gt;&lt;/td&gt;"); But the folks who commented that you shouldn't use regexes to parse HTML are absolutely right!! Unless you want chronically fragile code, your code should use a strict or non-strict HTML parser.
accepted answer of: http://stackoverflow.com/q/2660522

http://stackoverflow.com/comment/72314371
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/42591037
has text: any recommendations why using it?

http://stackoverflow.com/comment/2638321
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2625398
has text: Comment to my own post: The question is about tools, not libraries. Something that would be applicable no matter what functionality you are trying to implement.

http://stackoverflow.com/comment/50098515
score: 0
type: AnswerComment
has text: You argument about changing HTML is invalid. Check official taglet example on Oracle [site](http://docs.oracle.com/javase/7/docs/technotes/guides/javadoc/taglet/overview.html) they use HTML without any preconditions...
comment on: http://stackoverflow.com/a/13017949
type: Comment

http://stackoverflow.com/comment/2705553
type: AnswerComment
has text: I think once you get it running, you're bound to be happier with it. The only other suggestion I have is to try to see if you can force Solr to create the Lucene index in 2.3 format. But I don't know how one could do that.
type: Comment
score: 1
comment on: http://stackoverflow.com/a/2677657

http://stackoverflow.com/a/2774782
has body: It's called a Declaration.
upvote count: 6
answers question: http://stackoverflow.com/q/2774747
score: 6
downvote count: 0
type: Answer

http://stackoverflow.com/comment/2696456
score: 0
type: Comment
has text: Just to be clear, setting it to a daemon will cause the JVM to exit before it is finished if no other non-daemon threads are running. So it is the opposite of what you want. You set it by calling setDaemon(true) on the Thread object *before* calling start().
type: AnswerComment
comment on: http://stackoverflow.com/a/2676712

http://stackoverflow.com/comment/2759346
has text: Just this is not sufficient for what op asked.
comment on: http://stackoverflow.com/a/2725747
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/2642930
tagged with: dll
has title: Can I someone point to me what I did wrong? Trying to map VB to Java using JNA to access the library
has body: Original Working VB_Code Private Declare Function ConnectReader Lib "rfidhid.dll" () As Integer Private Declare Function DisconnectReader Lib "rfidhid.dll" () As Integer Private Declare Function SetAntenna Lib "rfidhid.dll" (ByVal mode As Integer) As Integer Private Declare Function Inventory Lib "rfidhid.dll" (ByRef tagdata As Byte, ByVal mode As Integer, ByRef taglen As Integer) As Integer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim desc As String desc = "1. Click ""Connect"" to talk to reader." &amp; vbCr &amp; vbCr desc &amp;= "2. Click ""RF On"" to wake up the TAG." &amp; vbCr &amp; vbCr desc &amp;= "3. Click ""Read Tag"" to get tag PCEPC." lblDesc.Text = desc End Sub Private Sub cmdConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdConnect.Click If cmdConnect.Text = "Connect" Then If ConnectReader() Then cmdConnect.Text = "Disconnect" Else MsgBox("Unable to connect to RFID Reader. Please check reader connection.") End If Else If DisconnectReader() Then cmdConnect.Text = "Connect" End If End If End Sub Private Sub cmdRF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRF.Click If cmdRF.Text = "RF On" Then If SetAntenna(&amp;HFF) Then cmdRF.Text = "RF Off" End If Else If SetAntenna(&amp;H0) Then cmdRF.Text = "RF On" End If End If End Sub Private Sub cmdReadTag_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdReadTag.Click Dim tagdata(64) As Byte Dim taglen As Integer, cnt As Integer Dim pcepc As String pcepc = "" If Inventory(tagdata(0), 1, taglen) Then For cnt = 0 To taglen - 1 pcepc &amp;= tagdata(cnt).ToString("X2") Next txtPCEPC.Text = pcepc Else txtPCEPC.Text = "ReadError" End If End Sub Java Code (Simplified) import com.sun.jna.Library; import com.sun.jna.Native; public class HelloWorld { public interface MyLibrary extends Library { public int ConnectReader(); public int SetAntenna (int mode); public int I…
tagged with: jna
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/2642959
tagged with: vb.net
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/2642959
type: Question

http://stackoverflow.com/comment/64160157
comment on: http://stackoverflow.com/a/13508779
type: Comment
has text: Not documented, so you can't trust this to work in the future. Check my answer: http://stackoverflow.com/a/38374931/480894
score: 0
type: AnswerComment

http://stackoverflow.com/comment/2817661
type: Comment
comment on: http://stackoverflow.com/a/2782426
score: 0
type: AnswerComment
has text: Thank you sooo much for your reply. I am still studying the code. Thanks.

http://stackoverflow.com/a/2622140
accepted answer of: http://stackoverflow.com/q/2621996
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2621996
upvote count: 2
has comment: http://stackoverflow.com/comment/2634501
type: Answer
score: 2
has body: Here is how I use the AccountManager on 2.* but have a fallback on 1.* where it isn't available. I build with the 2.1 SDK, but my Manifest states &lt;uses-sdk android:minSdkVersion="3" /&gt; This does allow the app to run on 1.5 devices upwards. I restrict my use of android.accounts.AccountManager to a wrapper class, I called it UserEmailFetcher. It will be possible to use this class on 2.* devices. However on earlier devices a java.lang.VerifyError will fire the first time this class is encountered in the code. This I catch, and perform some fallback action. String name; try { name = UserEmailFetcher.getEmail(this); } catch (VerifyError e) { // Happens if the AccountManager is not available (e.g. 1.x) } Hope that helps.
has comment: http://stackoverflow.com/comment/2634830
downvote count: 0
has comment: http://stackoverflow.com/comment/2634880

http://stackoverflow.com/comment/2738511
has text: @extraneon a stack trace doesn't help tell you with a statement that has three possible null values in one Java statement.
type: Comment
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/2713500

http://stackoverflow.com/a/47761711
has body: apart all those mentioned here, one can also go for H2 database which is light and can be used in-memory or in server mode.
score: 0
type: Answer
answers question: http://stackoverflow.com/q/2713758

http://stackoverflow.com/a/2730902
has body: Adding to the node only is not enough, the Tree needs to be notified. The correct way to do this is to let the model take care of adding/removing nodes, as it will notify correctly the Tree on the way. In case of a DefaultTreeModel (which should be the one used in the JTree if you haven't made your own TreeModel), you have the method insertNodeInto(MutableTreeNode newChild, MutableTreeNode parent, int index), which you can use.
upvote count: 5
accepted answer of: http://stackoverflow.com/q/2730851
score: 5
type: AcceptedAnswer
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2730851

http://stackoverflow.com/comment/2731152
type: Comment
comment on: http://stackoverflow.com/a/2705653
score: 0
type: AnswerComment
has text: @user324929 Are you saying that you do not have the right JRE ? I would recommend installing a newer one, or change to an encryption that is supported. If you want to know how to add a JCE provider in Java I suggest you open another question on this site, that is not really my area of expertise.

http://stackoverflow.com/q/2776724
tagged with: io
has answer: http://stackoverflow.com/a/2777276
score: 7
favorite count: 0
tagged with: blocking
type: UnansweredQuestion
upvote count: 7
has answer: http://stackoverflow.com/a/2873296
tagged with: network-programming
has body: I want to make an HTTP request and then get the response as sketched here: URLConnection c = new URL("http://foo.com").openConnection(); c.setDoOutput(true); /* write an http request here using a new OutputStreamWriter(c.getOutputStream) */ BufferedReader reader = new BufferedReader(new InputStreamReader(c.getInputStream)); reader.readLine(); But my question is, if the request I send takes a long time before a response is received, what happens in the call reader.readLine() above? Will this process stay running/runnable on the CPU or will it get taken off the CPU and be notified to wake up and run again when there is IO to be read? If it stays on the CPU, what can be done to make it get off and be notified later?
tagged with: java
type: Question
answer count: 2
downvote count: 0
tagged with: bufferedreader
has comment: http://stackoverflow.com/comment/2980727
has title: Java BufferedReader readline blocking?

http://stackoverflow.com/a/2744382
score: 1
has body: Got the way for the above scenario. For resizing use the following code: image = new ImageIcon(movpath); l5 = new JLabel () { public void paintComponent (Graphics g) { super.paintComponent (g); g.drawImage (image.getImage(), 0, 0, getWidth (), getHeight (), null); } }; l5.setBounds(360,300,200,200); p1.add(l5); l5.addMouseListener(this);
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2744283
upvote count: 1

http://stackoverflow.com/a/2670483
score: -1
answers question: http://stackoverflow.com/q/2670460
upvote count: 0
type: Answer
has body: public int[] reverse3(int[] nums) { int[] values = new int[nums.length]; for(int i=0; i&lt;nums.length; i++) { values[nums.length - (i + 1)]=nums[i]; } return values; }
downvote count: 1

http://stackoverflow.com/a/2678791
answers question: http://stackoverflow.com/q/2678745
score: -2
has body: Using getters and setters is the way to go. It's commonly accepted practise So other programmers are more likely to understand your code. It gives the class author options in the future Say you want to prevent someone setting a to null. Expose the member and you can never do it. As for whether to use this - I try to use this consistently to make it very clear to anyone else which are instance members and which are local variables at any point - also helps avoid accidental shadowing, but I think this is less important and more a style thing. Also - this.a is an instance member (one per instance) not a class member (one-per-class, would be static). Another reason to use this to be clear.
type: Answer
upvote count: 1
downvote count: 3

http://stackoverflow.com/comment/2713198
has text: You could use a List instead, such as an ArrayList - which follows the Collections framework and is sometimes easier for people to understand.
type: Comment
comment on: http://stackoverflow.com/a/2691780
score: 0
type: AnswerComment

http://stackoverflow.com/a/21779780
upvote count: 4
downvote count: 0
has body: Use command line utility Apache Tika. Tika suports a wide number of formats (ex: doc, docx, pdf, html, rtf ...) java -jar tika-app-1.3.jar -t somedocfile.doc &gt; converted.txt Programatically: File inputFile = ...; Tika tika = new Tika(); String extractedText = tika.parseToString(inputFile); You can use Apache POI too. They have a tool to extract text from doc/docx Text Extraction. If you want to extract only the text, you can use the code below. If you want to extract Rich Text (such as formatting and styling), you can use Apache Tika. Extract doc: InputStream fis = new FileInputStream(...); POITextExtractor extractor; // if docx if (fileName.toLowerCase().endsWith(".docx")) { XWPFDocument doc = new XWPFDocument(fis); extractor = new XWPFWordExtractor(doc); } else { // if doc POIFSFileSystem fileSystem = new POIFSFileSystem(fis); extractor = ExtractorFactory.createExtractor(fileSystem); } String extractedText = extractor.getText();
answers question: http://stackoverflow.com/q/2709923
type: Answer
score: 4

http://stackoverflow.com/a/2726357
score: 9
downvote count: 0
upvote count: 9
answers question: http://stackoverflow.com/q/2726300
type: Answer
has body: Hibernate does not require serializable at all.

http://stackoverflow.com/q/2604238
tagged with: java
type: Question
has title: How to filter rows in JTable based on boolean valued columns?
type: AnsweredQuestion
tagged with: filtering
accepted answer: http://stackoverflow.com/a/2604290
has body: Im trying to filter rows based on a column say c1 that contains boolean values. I want to show only rows that have 'true' in c1. I looked up the examples in http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#sorting. The example uses a regex filter. Is there any way I can use boolean values to filter rows? Following is the code Im using (borrowed from the example) private void filter(boolean show) { RowFilter&lt;TableModel, Object&gt; filter = null; TableModel model = jTb.getModel(); boolean value = (Boolean) model.getValueAt(0,1); //If current expression doesn't parse, don't update. try { // I need to used 'value' to filter instead of filterText. filter =RowFilter.regexFilter(filterText, 0); } catch (java.util.regex.PatternSyntaxException e) { return; } sorter.setRowFilter(filter); } thank you.
tagged with: jtable
answer count: 1
downvote count: 0
tagged with: rowfilter
favorite count: 0
has answer: http://stackoverflow.com/a/2604290
score: 2
upvote count: 2

http://stackoverflow.com/a/38841810
score: 7
upvote count: 7
has body: Lazy property loading requires buildtime bytecode instrumentation. Hibernate docs: Using lazy property fetching If you want to avoid bytecode instrumentation one option is to to create two entities that use same table, one with the blob one without. Then only use the entity with blob when you need the blob.
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2605477

http://stackoverflow.com/a/2765923
upvote count: 14
type: AcceptedAnswer
has body: If all you want to do is execute existing applictions, you can use the exec methods from the java.io.runtime namespace. Runtime rt = Runtime.getRuntime(); Process ps = rt.exec("path to my executable.exe");
score: 14
downvote count: 0
answers question: http://stackoverflow.com/q/2765888
type: Answer
accepted answer of: http://stackoverflow.com/q/2765888
has comment: http://stackoverflow.com/comment/43475408

hibernate-annotations
tags question: http://stackoverflow.com/q/2669389
tag name: hibernate-annotations
type: Tag

http://stackoverflow.com/comment/108942046
type: AnswerComment
comment on: http://stackoverflow.com/a/58908439
type: Comment
score: 0
has text: @Holger Will that (i being null) be detected by JEP 358 in this case?

http://stackoverflow.com/a/42224314
downvote count: 2
answers question: http://stackoverflow.com/q/2646195
has comment: http://stackoverflow.com/comment/91466840
type: Answer
has body: public boolean isElementFound( String text) { try{ WebElement webElement = appiumDriver.findElement(By.xpath(text)); System.out.println("isElementFound : true :"+text + "true"); }catch(NoSuchElementException e){ System.out.println("isElementFound : false :"+text); return false; } return true; } text is the xpath which you would be passing when calling the function. the return value will be true if the element is present else false if element is not pressent
has comment: http://stackoverflow.com/comment/71616982
upvote count: 2
score: 0

http://stackoverflow.com/comment/130663300
type: AnswerComment
has text: In case I, all subtype of Thing is Thing, why adding Thing instance is not allowed? As all operation only happen in Thing type. Can you give a concrete example why adding Thing instance to the list in case I will cause issue?
type: Comment
score: 0
comment on: http://stackoverflow.com/a/2723538

http://stackoverflow.com/comment/62925196
comment on: http://stackoverflow.com/a/34217962
score: 0
type: AnswerComment
type: Comment
has text: That doesn't access the constructor, only the constructed object.

http://stackoverflow.com/a/29435138
upvote count: 9
has body: We are using HTTPClient 4.3.5 and we tried almost all solutions exist on the stackoverflow but nothing, After thinking and figuring out the problem, we come to the following code which works perfectly, just add it before creating HttpClient instance. some method to call when making post requests.... SSLContextBuilder builder = new SSLContextBuilder(); builder.loadTrustMaterial(null, new TrustStrategy() { @Override public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException { return true; } }); SSLConnectionSocketFactory sslSF = new SSLConnectionSocketFactory(builder.build(), SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(sslSF).build(); HttpPost postRequest = new HttpPost(url); continue your request in the normal form
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/2703161
score: 9

http://stackoverflow.com/comment/80223451
comment on: http://stackoverflow.com/a/2782657
type: Comment
has text: @Steve11235 Have you read the question or just the title! His answer correctly addresses the problem.
score: 1
type: AnswerComment

http://stackoverflow.com/q/2628356
has answer: http://stackoverflow.com/a/2631146
type: Question
score: 5
upvote count: 5
tagged with: database
answer count: 3
tagged with: sql
downvote count: 0
has answer: http://stackoverflow.com/a/2628614
favorite count: 0
type: UnansweredQuestion
has title: Move million records from MEMORY table to MYISAM table
tagged with: c++
tagged with: java
tagged with: mysql
has body: I am looking for a fast way to move records from a MEMORY table to MYISAM table. MEMORY table has around 0.5 million records. Both tables have exactly the same structure (same number of columns, data types etc.). But the MYISAM table is indexed (B-TREE) on a few columns. There are around 25 columns most of which are unsigned integers. I have already tried using "INSERT INTO SELECT * FROM " query. But is there any faster way to do this? Appreciate your help. Prashant
has answer: http://stackoverflow.com/a/2630396

asp.net
tags question: http://stackoverflow.com/q/2606049
type: Tag
tag name: asp.net

http://stackoverflow.com/q/2728311
has answer: http://stackoverflow.com/a/2728336
possible better answer: http://stackoverflow.com/a/2728347
tagged with: synchronization
favorite count: 0
score: 8
accepted answer: http://stackoverflow.com/a/2728362
downvote count: 0
answer count: 5
tagged with: multithreading
has comment: http://stackoverflow.com/comment/24738146
has answer: http://stackoverflow.com/a/2728362
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2728334
tagged with: java
tagged with: concurrency
has answer: http://stackoverflow.com/a/2728347
upvote count: 8
type: Question
has body: What is the difference between synchronized methods and synchronized statements? If possible, please use an example to make it more clear.
has answer: http://stackoverflow.com/a/2728358
has title: What is the difference between synchronized methods and blocks?

http://stackoverflow.com/comment/2706790
comment on: http://stackoverflow.com/a/2686380
score: 0
type: AnswerComment
type: Comment
has text: I've changed it in the code, but now the while loop lets squares fall through.

http://stackoverflow.com/comment/45596875
type: Comment
comment on: http://stackoverflow.com/a/3195202
type: AnswerComment
score: 0
has text: I tend to disagree. How can it hold that "Map is-a Set" if you can't always add non-member elements of the domain to your set (as in the example in @cletus' answer).

http://stackoverflow.com/comment/114637790
comment on: http://stackoverflow.com/a/56846990
has text: Solution from https://stackoverflow.com/questions/33103798/how-to-get-wi-fi-mac-address-in-android-marshmallow to get my own mac address works for me on an Android 10 emulator
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/tag/csv
type: Tag
tag name: csv
tags question: http://stackoverflow.com/q/2601122
tags question: http://stackoverflow.com/q/2785467
tags question: http://stackoverflow.com/q/2614416
tags question: http://stackoverflow.com/q/2600876

http://stackoverflow.com/a/4604443
answers question: http://stackoverflow.com/q/2768780
downvote count: 0
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/18403780
type: Answer
has body: Baretail might be an option.

http://stackoverflow.com/a/2667203
type: AcceptedAnswer
downvote count: 0
score: 4
accepted answer of: http://stackoverflow.com/q/2666940
type: Answer
answers question: http://stackoverflow.com/q/2666940
has comment: http://stackoverflow.com/comment/2685573
has body: First of all, I think you using the mouse event coordinates (x,y) incorrectly, since those are relative to the source component. In this case the source is the label itself. So you should add to those values the original (x,y) of the source component: label.setBounds(label.getX() + arg0.getX(), label.getY() + arg0.getY(),90,20); It's been a while since I had to struggle with the mouse events, but maybe you could try this and let us know if it helps. Another thing which I'm not sure of is the adding of label to the JTable. The LayoutManager of the JTable might prevent you from actually implementing this way, you may need to use GlassPane or something on top of the table.
upvote count: 4

constructor
tags question: http://stackoverflow.com/q/2678113
tags question: http://stackoverflow.com/q/2698690
tags question: http://stackoverflow.com/q/2710260
tags question: http://stackoverflow.com/q/2679918
tags question: http://stackoverflow.com/q/2715032
tags question: http://stackoverflow.com/q/2758310
tags question: http://stackoverflow.com/q/2729580
tags question: http://stackoverflow.com/q/2683735
tags question: http://stackoverflow.com/q/2599440
tags question: http://stackoverflow.com/q/2752529
tags question: http://stackoverflow.com/q/2709277
tag name: constructor
tags question: http://stackoverflow.com/q/2716897
tags question: http://stackoverflow.com/q/2681568
tags question: http://stackoverflow.com/q/2747146
tags question: http://stackoverflow.com/q/2709678
tags question: http://stackoverflow.com/q/2636129
type: Tag
tags question: http://stackoverflow.com/q/2713426
tags question: http://stackoverflow.com/q/2619643
tags question: http://stackoverflow.com/q/2613596
tags question: http://stackoverflow.com/q/2741066
tags question: http://stackoverflow.com/q/2601857
tags question: http://stackoverflow.com/q/2712971

http://stackoverflow.com/comment/132649851
comment on: http://stackoverflow.com/a/2698527
type: AnswerComment
has text: How would you implement an equals method of an abstract class which is extends by other classes? Than you
score: 0
type: Comment

http://stackoverflow.com/q/2764031
has title: displaying special characters in hyperlink text
tagged with: hyperlink
tagged with: jsp
has comment: http://stackoverflow.com/comment/2796468
has comment: http://stackoverflow.com/comment/2796505
score: 0
has comment: http://stackoverflow.com/comment/2796739
has comment: http://stackoverflow.com/comment/2797386
has comment: http://stackoverflow.com/comment/2796540
tagged with: http://stackoverflow.com/tag/html
has answer: http://stackoverflow.com/a/2767830
has answer: http://stackoverflow.com/a/2764050
type: UnansweredQuestion
has body: I have used HTML in my Java class and in one case I have used username. Username is a variable that gets values dynamically. In one case its value is 'rg@bg' but here instead of the name I'm getting the URL to which it is directed in my jsp. How do I ensure that the value of username comes on the display page as it is. I have tried "@"+username. Didn't work
tagged with: anchor
has comment: http://stackoverflow.com/comment/2796421
tagged with: java
type: Question
answer count: 2

http://stackoverflow.com/comment/2766707
comment on: http://stackoverflow.com/a/2738259
type: Comment
score: 11
has text: There's even a method in the JDK to create a `Set` with a specified backing `Map` and it's called `newSetFromMap`: http://java.sun.com/javase/6/docs/api/java/util/Collections.html#newSetFromMap(java.util.Map%29
type: AnswerComment

http://stackoverflow.com/a/2682556
score: 0
type: Answer
has body: I think this is probably a build path problem in Eclipse. Check that the JAR file containing the Listener class is on the build path. Another possibility is that you are missing an import some.package.Listener; statement in the source code of your CTManager class.
answers question: http://stackoverflow.com/q/2682429

http://stackoverflow.com/a/2720000
downvote count: 0
answers question: http://stackoverflow.com/q/2719983
has comment: http://stackoverflow.com/comment/2746179
has body: It means you are missing dependant classes. If you look at the requirements it also requires "Synthetica Standard Look and Feel" you can download it here
upvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/2747595
score: 2
has comment: http://stackoverflow.com/comment/2753713

http://stackoverflow.com/a/2681051
answers question: http://stackoverflow.com/q/2680993
has body: Well, FTP creates a new socket for each file transfer. Note that the connection can be established on the same port as the one used for chat, but with a different initialization dialog.
type: Answer
upvote count: 3
score: 3
accepted answer of: http://stackoverflow.com/q/2680993
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/2715619
type: Answer
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/2714508
upvote count: 2
has body: You're using Facelets, but defining a JSP tag. Facelets have their own tag definition files (with a .taglib.xml suffix). If you're using JSF 1.2 with Facelets, you'll find the DTD here. If you're using JSF 2.0, a schema is defined in the JSR 314 spec (Appendix A, section 1.2).

http://stackoverflow.com/comment/46583713
type: AnswerComment
type: Comment
score: 0
comment on: http://stackoverflow.com/a/12506009
has text: Thanks you have saved me. I think its mylyn plugin that activate this features.

http://stackoverflow.com/a/2758914
has body: Util-type classes that hold a mishmash of usually static functions are not generally good things. I've even seen that kind of class named UglyGlobals in one project I worked on. At least they were honest about it! As a general rule, you are correct. Something like mailing is a great candidate for turning into a singleton bean that gets injected.
type: Answer
answers question: http://stackoverflow.com/q/2758879
score: 7
upvote count: 7
downvote count: 0

http://stackoverflow.com/comment/2673714
score: 10
comment on: http://stackoverflow.com/a/2656747
type: AnswerComment
has text: How exactly will a maintaining a linux server be *easier* for someone who's decided they can't follow the GAE cron docs?
type: Comment

http://stackoverflow.com/comment/2750528
has text: Agreed, using `clean` is a thoughtless practice in this case. Thank you.
type: Comment
score: 1
comment on: http://stackoverflow.com/a/2723660
type: AnswerComment

http://stackoverflow.com/a/2661744
answers question: http://stackoverflow.com/q/2661698
type: AcceptedAnswer
score: 75
has comment: http://stackoverflow.com/comment/45822490
has body: The naming convention for packages is specified in the JLS. Here is the relevant snippet (there's a lot more in the section): JLS 7.7 Unique Package Names You form a unique package name by first having (or belonging to an organization that has) an Internet domain name, such as sun.com. You then reverse this name, component by component, to obtain, in this example, com.sun, and use this as a prefix for your package names, using a convention developed within your organization to further administer package names. It's also given in Naming Conventions section of Sun's code conventions document: Packages: The prefix of a unique package name is always written in all-lowercase ASCII letters and should be one of the top-level domain names, currently com, edu, gov, mil, net, org, or one of the English two-letter codes identifying countries as specified in ISO Standard 3166, 1981. Subsequent components of the package name vary according to an organization's own internal naming conventions. Such conventions might specify that certain directory name components be division, department, project, machine, or login names. Examples: com.sun.eng, com.apple.quicktime.v2, edu.cmu.cs.bovik.cheese So com. prefix in package names means the same as .com suffix in domain names: "commercial".
type: Answer
has comment: http://stackoverflow.com/comment/2679083
downvote count: 0
upvote count: 75
accepted answer of: http://stackoverflow.com/q/2661698
has comment: http://stackoverflow.com/comment/2679136

http://stackoverflow.com/a/2668746
score: 8
upvote count: 8
type: Answer
has body: One could use a MouseAdapter class, which implements the MouseListener interface, so one does not need to implement all the methods. However, by overriding the methods of interest, one can get the desired behavior. For example, if one overrides the mouseClicked method, then one can define some behavior for the mouse click event. For example (untested code): JLabel label = new JLabel("Hello"); label.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { System.out.println("Clicked!"); } }); In the code above, the JLabel will print "Clicked!" to the console upon being clicked on.
answers question: http://stackoverflow.com/q/2668718
downvote count: 0

http://stackoverflow.com/q/2651819
has body: I was surprised by the fact that Map&lt;?,?&gt; is not a Collection&lt;?&gt;. I thought it'd make a LOT of sense if it was declared as such: public interface Map&lt;K,V&gt; extends Collection&lt;Map.Entry&lt;K,V&gt;&gt; After all, a Map&lt;K,V&gt; is a collection of Map.Entry&lt;K,V&gt;, isn't it? So is there a good reason why it's not implemented as such? Thanks to Cletus for a most authoritative answer, but I'm still wondering why, if you can already view a Map&lt;K,V&gt; as Set&lt;Map.Entries&lt;K,V&gt;&gt; (via entrySet()), it doesn't just extend that interface instead. If a Map is a Collection, what are the elements? The only reasonable answer is "Key-value pairs" Exactly, interface Map&lt;K,V&gt; extends Set&lt;Map.Entry&lt;K,V&gt;&gt; would be great! but this provides a very limited (and not particularly useful) Map abstraction. But if that's the case then why is entrySet specified by the interface? It must be useful somehow (and I think it's easy to argue for that position!). You can't ask what value a given key maps to, nor can you delete the entry for a given key without knowing what value it maps to. I'm not saying that that's all there is to it to Map! It can and should keep all the other methods (except entrySet, which is redundant now)!
downvote count: 0
favorite count: 0
score: 163
has comment: http://stackoverflow.com/comment/23666736
upvote count: 163
answer count: 10
has answer: http://stackoverflow.com/a/28649822
has answer: http://stackoverflow.com/a/3195202
has answer: http://stackoverflow.com/a/2651833
has comment: http://stackoverflow.com/comment/118563601
tagged with: java
has answer: http://stackoverflow.com/a/2652043
tagged with: collections
type: Question
has answer: http://stackoverflow.com/a/2655737
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/39856863
tagged with: oop
has answer: http://stackoverflow.com/a/2652083
has title: Why doesn't Java Map extend Collection?
has answer: http://stackoverflow.com/a/76192324
possible better answer: http://stackoverflow.com/a/2655737
has answer: http://stackoverflow.com/a/2652078
accepted answer: http://stackoverflow.com/a/2651833
has answer: http://stackoverflow.com/a/42998166
has comment: http://stackoverflow.com/comment/2667918

http://stackoverflow.com/q/2712670
type: AnsweredQuestion
score: 2
possible better answer: http://stackoverflow.com/a/2712702
has answer: http://stackoverflow.com/a/2712685
tagged with: java
has title: How to ensure that no non-ascii unicode characters are entered?
has answer: http://stackoverflow.com/a/2712702
tagged with: character-encoding
type: Question
accepted answer: http://stackoverflow.com/a/2712685
downvote count: 0
tagged with: unicode
answer count: 3
favorite count: 0
upvote count: 2
has body: Given a java.lang.String instance, I want to verify that it doesn't contain any unicode characters that are not ASCII alphanumerics. e.g. The string should be limited to [A-Za-z0-9.]. What I'm doing now is something very inefficient: import org.apache.commons.lang.CharUtils; String s = ...; char[] ch = s.toCharArray(); for( int i=0; i&lt;ch.length; i++) { if( ! CharUtils.isAsciiAlphanumeric( ch[ i ] ) throw new InvalidInput( ch[i] + " is invalid" ); } Is there a better way to solve this ?
has answer: http://stackoverflow.com/a/2712783

http://stackoverflow.com/comment/2726248
comment on: http://stackoverflow.com/a/2698745
has text: @rsp-Thanks for fixing my problem. In fact,what I want to make clear is that when to use a Abstract Factory,that's to say we assume the two ways mentioned above can not cause some thread problems. well,if the problems does not exist,why do we use the Abstract Factory? In the Ab.Fatory pattern,the different products are created by different factories,in the following way(the one you fixed),the products are created by a Repository(the DaoRepository in the example),so,what's the difference? WHen the Repository create a new instance,it also does not know which object it is creating,isn't it?
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/2808240
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2774252
has text: WHAT do you want to reuse ? The Field objects, or the Runnables ?
score: 0

http://stackoverflow.com/q/2636629
has body: I have a ratingbar in my app, and I would like when I pass the mouse over it, the rating changes How can I do that ? it's possible? best regards
has comment: http://stackoverflow.com/comment/2650816
upvote count: 2
answer count: 2
has comment: http://stackoverflow.com/comment/2650682
favorite count: 0
tagged with: android
score: 2
type: AnsweredQuestion
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/2637034
accepted answer: http://stackoverflow.com/a/2637034
possible better answer: http://stackoverflow.com/a/6381914
has answer: http://stackoverflow.com/a/6381914
has title: Change Rating Bar on Android
type: Question

http://stackoverflow.com/comment/60867677
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/31660211
type: Comment
has text: `System.exit(0); return;` is good too, the return prevents any ruther code from being run before the System can exit, otherwise you'd need a flag (.. `i.e. if (!called_exit) { further code after exit statement }`

http://stackoverflow.com/comment/80294592
type: AnswerComment
has text: Then they're not "quite different" as you state. The only difference is scope - Spring container verses classloader
comment on: http://stackoverflow.com/a/2640769
type: Comment
score: 5

http://stackoverflow.com/comment/2691405
score: 0
type: Comment
has text: @ Chris and Wizard, thanks for the discussion. It's clear that I have to go back to the drawing board to make this RPG smoother from the beginning.
type: AnswerComment
comment on: http://stackoverflow.com/a/2672194

http://stackoverflow.com/comment/2664001
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/2643311
score: 0
has text: Thanks... Yes. I am not using a GUI at all. This is a remote ssh. In addition, when I use the Xvfb command, it keeps giving me "error opening security policy file /usr/lib/xserver/SecurityPolicy" and never allows azureus to start.

http://stackoverflow.com/a/2783221
has comment: http://stackoverflow.com/comment/2818529
has comment: http://stackoverflow.com/comment/2819938
downvote count: 0
answers question: http://stackoverflow.com/q/2783135
has body: Use an enum for dealing with it (RPSObj) that has a beats(RPSObj o) method, with each enum element having a Set passed in, stored as beatset. Then, the beats(RPSObj o) method can do return beatset.contains(o);. Simples :) Edit: You can actually use an EnumSet as the Set implementation, which should be even more efficient than other set implementations :)
upvote count: 2
type: Answer
score: 2

http://stackoverflow.com/comment/2833355
comment on: http://stackoverflow.com/a/2795721
type: AnswerComment
score: 0
has text: Thanks for your reply... I've edited the post so that it provides more information.
type: Comment

http://stackoverflow.com/a/2622301
has comment: http://stackoverflow.com/comment/2634975
has comment: http://stackoverflow.com/comment/2636135
downvote count: 0
score: 4
has comment: http://stackoverflow.com/comment/2636783
answers question: http://stackoverflow.com/q/2622240
type: Answer
has body: "i am a student" This is Java's polymorphism in action. The method speaks() is defined in base class Person and is overridden in the derived class Student. In Java a base class reference can refer to a derived class object, and when a overridden method is call on such a reference, the type of the object to which the reference refers to decides the version of the method to be executed.
upvote count: 4

http://stackoverflow.com/a/2697290
has body: This question has been asked many, many times before here on SO. Here's why you don't want to use regexes to parse email addresses. Note please that that monster of a regex doesn't even handle comments.
answers question: http://stackoverflow.com/q/2697256
has comment: http://stackoverflow.com/comment/2719719
type: Answer
has comment: http://stackoverflow.com/comment/2719791
has comment: http://stackoverflow.com/comment/2719693
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/2719761
has comment: http://stackoverflow.com/comment/2719663
upvote count: 2
has comment: http://stackoverflow.com/comment/2719644
has comment: http://stackoverflow.com/comment/2719686
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2697256
has comment: http://stackoverflow.com/comment/2719627

http://stackoverflow.com/comment/2701389
score: 2
type: Comment
has text: But without the pom files I can't run the exploded war on my local JBoss. So I can't test and debug it either. Or I've got the wrong sense of testing ...
comment on: http://stackoverflow.com/a/2681388
type: AnswerComment

http://stackoverflow.com/q/2753741
possible better answer: http://stackoverflow.com/a/2753753
downvote count: 0
has answer: http://stackoverflow.com/a/2753753
score: 4
linked to: http://stackoverflow.com/q/2658554
answer count: 3
has answer: http://stackoverflow.com/a/2754412
has comment: http://stackoverflow.com/comment/2785310
favorite count: 0
accepted answer: http://stackoverflow.com/a/2754412
has answer: http://stackoverflow.com/a/2753978
tagged with: javax.imageio
has title: Java 1.5.0_16 corrupted colours when saving jpg image
type: AnsweredQuestion
tagged with: java
tagged with: image-processing
has body: i have a loaded image from disk (stored as a BufferedImage), which i display correctly on a JPanel but when i try to re-save this image using the command below, the image is saved in a reddish hue. ImageIO.write(image, "jpg", fileName); Note! image is a BufferedImage and fileName is a File object pointing to the filename that will be saved which end in ".jpg". I have read that there were problems with ImageIO methods in earlier JDKs but i'm not on one of those versions as far as i could find. What i am looking for is a way to fix this issue without updating the JDK, however having said that i would still like to know in what JDK this issue was fixed in (if it indeed is still a bug with the JDK i'm using). Thanks.
type: Question
upvote count: 4

http://stackoverflow.com/a/2630027
has comment: http://stackoverflow.com/comment/2643580
upvote count: 1
has comment: http://stackoverflow.com/comment/2643471
has comment: http://stackoverflow.com/comment/2643171
has body: First of all, it is always helpful to see the relevant code and stacktrace when trying to debug a problem. Thus I cannot give an answer to your first question. However, I will try to explain how the conversation model works. This is from the Seam in Action book: @ScopeType.EVENT = Goes from Restore View to Render Response, but not redirect @ScopeType.CONVERSATION = Goes from Restore VIew to Render Response, and redirect. If long-running conversation, then it spans multiple JSF life cycles. So imagine you are in a.xhtml you push a button that will take ComponentA and fill some data in it. This component you want to inject and use in b.xhtml ie: Push commandbutton in a.xhtml performing post, putting some data in ComponentA Now you redirect to next page (b.xhtml)which uses the ComponentA @Name("componentB") @Scope(ScopeType.CONVERSATION) public class ComponentB { @In(create=true) ComponentA componentA; //OK } So if you now push another button from b.xhtml expecting to be able to inject ComponentA again, that will fail. ie: @Name("componentC") @Scope(ScopeType.CONVERSATION) public class ComponentC { @In(create=true) ComponentA componentA; //Injection of the component you really want fails (you will get default component) } So in the background now, seam has created a new cid for you, ending the previous cid because a conversation scoped component can only live one request.
has comment: http://stackoverflow.com/comment/2645436
downvote count: 0
has comment: http://stackoverflow.com/comment/2643492
answers question: http://stackoverflow.com/q/2629759
has comment: http://stackoverflow.com/comment/2643452
type: Answer
has comment: http://stackoverflow.com/comment/2643266
score: 1

http://stackoverflow.com/comment/2807057
type: AnswerComment
has text: If you think about it, though, it's really not anywhere "worse" than half the other solutions presented here. While your solution takes a completely different approach, I argue that mine is more robust, and more portable/modifiable. If I were OP, I would also provide the original code (commented out) for clarify on what's been generalised, with a number next to each case. I got them on my editor here, and that's how I come to this solution.
type: Comment
comment on: http://stackoverflow.com/a/2772416
score: 0

http://stackoverflow.com/q/2745003
possible better answer: http://stackoverflow.com/a/4027996
has answer: http://stackoverflow.com/a/69199418
has comment: http://stackoverflow.com/comment/2774717
has body: I would like to run a Java program with garbage collection switched off. Managing memory in my own code is not so difficult. However the program needs quite a lot of I/O. Is there any way (short of using JNI for all I/O operations) that I could achieve this using pure Java? Thanks Daniel
favorite count: 0
has comment: http://stackoverflow.com/comment/2774897
has answer: http://stackoverflow.com/a/2745052
has comment: http://stackoverflow.com/comment/2774798
has answer: http://stackoverflow.com/a/2747151
has answer: http://stackoverflow.com/a/2745464
has answer: http://stackoverflow.com/a/2745034
has comment: http://stackoverflow.com/comment/2775216
tagged with: io
has answer: http://stackoverflow.com/a/2745402
type: AnsweredQuestion
upvote count: 2
score: 1
tagged with: java
tagged with: garbage-collection
accepted answer: http://stackoverflow.com/a/2745052
downvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/2774971
has comment: http://stackoverflow.com/comment/2774358
answer count: 8
has answer: http://stackoverflow.com/a/2747189
has answer: http://stackoverflow.com/a/4027996
has title: Java without gc - io
has comment: http://stackoverflow.com/comment/2774288
has comment: http://stackoverflow.com/comment/2774207

http://stackoverflow.com/comment/2723681
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/2700775
has text: @sepp2k What if you wanted the resulting list to be List<Object> even though the arguments are Strings?
type: Comment

http://stackoverflow.com/comment/2768196
has text: To send email to Gmail, from Java: http://stackoverflow.com/questions/46663/how-do-you-send-email-from-a-java-app-using-gmail
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2739596

http://stackoverflow.com/comment/2684638
comment on: http://stackoverflow.com/q/2665731
has text: Perhaps a typo, but shouldn't you pass "key" to m.init instead of "secret"?
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/2624438
has comment: http://stackoverflow.com/comment/2637359
answers question: http://stackoverflow.com/q/2624410
score: 6
type: Answer
has body: I don't know, but I suspect it's there for symmetry with the (obviously necessary) unary minus operator.
has comment: http://stackoverflow.com/comment/116371838
upvote count: 8
downvote count: 2

http://stackoverflow.com/a/2771557
has comment: http://stackoverflow.com/comment/2805323
score: 2
has comment: http://stackoverflow.com/comment/2805620
has body: If you are using MySQL or PostgreSQL limit and offset are your keywords. MSSqlServer and Oracle have similar features, but I seems to be a bit more painful. For MySQL and PostgreSQL have a look here: http://www.petefreitag.com/item/451.cfm For Oracle have a look here: http://www.oracle-base.com/forums/viewtopic.php?f=2&amp;t=8635
downvote count: 0
answers question: http://stackoverflow.com/q/2771439
has comment: http://stackoverflow.com/comment/2806129
type: Answer
upvote count: 2
has comment: http://stackoverflow.com/comment/2804999

http://stackoverflow.com/comment/2633197
comment on: http://stackoverflow.com/a/2620818
type: AnswerComment
has text: I am using netbeans :( in eclipse i had this problem that i wasn't able to add servlets to my project.
score: 0
type: Comment

http://stackoverflow.com/a/2767332
upvote count: 3
type: AcceptedAnswer
type: Answer
has body: As cletus says, erasure means that you can't check for this at runtime (and thanks to your casting you can't check this at compile time). Bear in mind that generics are a compile-time only feature. A collection object does not have any generic parameters, only the references you create to that object. This is why you get a lot of warning about "unchecked cast" if you ever need to downcast a collection from a raw type or even Object - because there's no way for the compiler to verify that the object is of the correct generic type (as the object itself has no generic type). Also, bear in mind what casting means - it's a way of telling the compiler "I know that you can't necessarily check that the types match, but trust me, I know they do". When you override type checking (incorrectly) and then end up with a type mismatch, who ya gonna blame? ;-) It seems like your problem lies around the lack of heterogenous generic data structures. I would suggest that the type signature of your method should be more like private static&lt;K,V&gt; void addToMap(Map&lt;K,V&gt; map, List&lt;Pair&lt;K, V&gt;&gt; vals), but I'm not convinced that gets you anything really. A list of pairs basically is a map, so contructing the typesafe vals parameter in order to call the method would be as much work as just populating the map directly. If you really, really want to keep your class roughly as it is but add runtime type-safety, perhaps the following will give you some ideas: private static&lt;K,V&gt; void addToMap(Map&lt;K,V&gt; map, Object ... vals, Class&lt;K&gt; keyClass, Class&lt;V&gt; valueClass) { for(int i = 0; i &lt; vals.length; i += 2) { if (!keyClass.isAssignableFrom(vals[i])) { throw new ClassCastException("wrong key type: " + vals[i].getClass()); } if (!valueClass.isAssignableFrom(vals[i+1])) { throw new ClassCastException("wrong value type: " + vals[i+1].getClass()); } map.put((K)vals[i], (V)vals[i+1]); //Never throws ClassCastException! } }
score: 3
has comment: http://stackoverflow.com/comment/131247878
downvote count: 0
has comment: http://stackoverflow.com/comment/2800071
has comment: http://stackoverflow.com/comment/2800028
accepted answer of: http://stackoverflow.com/q/2767212
answers question: http://stackoverflow.com/q/2767212

http://stackoverflow.com/a/2661075
type: AcceptedAnswer
score: 4
type: Answer
upvote count: 4
accepted answer of: http://stackoverflow.com/q/2661022
downvote count: 0
answers question: http://stackoverflow.com/q/2661022
has body: I was just looking at how I handled that in a piece of code I wrote about a year ago. It was my first time playing with the nio stuff (and actually last ... I've been away from Java since). I don't know if this is the perfect solution BUT ... Any time that I read data from a socket, I store the current time in an object stored in SelectionKey.attachment(). Periodically I iterate through the SelectionKeys, check the time, and disco any that have been idle past a certain time.

http://stackoverflow.com/a/15494993
type: Answer
has body: Synchronization helps to create read and write barriers. i.e. it establishes a boundary whereby you can be assured that whatever be the order of operations (read/write) there will be a 'happens-before' relationship between them. It makes it obvious for the processor to flush out all changes in local (cache/register) copies of objects under synchronization to the main memory, in the meanwhile giving no access to that particular memory instance under synchronization.
score: 0
answers question: http://stackoverflow.com/q/2691041

http://stackoverflow.com/comment/59179831
has text: Please [edit] with more information. Code-only and "try this" answers are [discouraged](//meta.stackexchange.com/questions/196187), because they contain no searchable content, and don't explain why someone should "try this". We make an effort here to be a resource for knowledge.
comment on: http://stackoverflow.com/a/35752968
type: AnswerComment
type: Comment
score: 2

http://stackoverflow.com/a/2757542
answers question: http://stackoverflow.com/q/2757529
score: 9
type: Answer
has body: what I want it to match is any amount of whitespace in between the string before and the string after, with only one item of punctuation allowed Try this: \s*\p{P}\s* Explanation: \s* Match any amount of whitespace \p{P} Match a single punctuation character \s* Match any amount of whitespace Note that in Java string literals the backslashes need escaping.
upvote count: 9
downvote count: 0

http://stackoverflow.com/comment/12308922
has text: From what I can read if you have a fresh 10.7 install, not an upgrade, then the src.jar is not available. Additionally, when I was looking on the internets for it on Mar 8, Apple's developer site was (gasp) down.
score: 1
comment on: http://stackoverflow.com/a/4197279
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2742442
type: Comment
type: QuestionComment
has text: @Nick You are right, I edited the title. If you know a better one, feel free to change it again ;-)
comment on: http://stackoverflow.com/q/2716749
score: 0

http://stackoverflow.com/comment/2616732
has text: @andyjohnson: Either you misunderstood me or my grammar was broken. Anyway I tried to fix it. No control on the time when objects are destructed is in Java. In C++ you have full control on it (modulo complicated rules about lifetime of temporaries).
type: Comment
score: 2
comment on: http://stackoverflow.com/a/2606588
type: AnswerComment

http://stackoverflow.com/a/2617826
type: Answer
upvote count: 1
has body: I don't know exactly what you want, but I think BeanShell is something you can use. BeanShell is an interpreter. You can run uncompiled Java-code (So you give it a String with code and he runs it). Of course if you really want to do what you wrote, the machine where the program is running needs a JDK to compile your program. Hope this helps
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/2617792

http://stackoverflow.com/a/2626777
upvote count: 3
downvote count: 0
has body: This solution has a nice symmetry. public static String transpose(String s) { StringBuilder sb = new StringBuilder(); sb.setLength(s.length()); for (int i = 0, j = s.length() - 1, x = 0; i &lt;= j; ) { sb.setCharAt(x++, s.charAt(i++)); if (i &gt; j) break; sb.setCharAt(x++, s.charAt(j--)); } return sb.toString(); } public static String untranspose(String s) { StringBuilder sb = new StringBuilder(); sb.setLength(s.length()); for (int i = 0, j = s.length() - 1, x = 0; i &lt;= j; ) { sb.setCharAt(i++, s.charAt(x++)); if (i &gt; j) break; sb.setCharAt(j--, s.charAt(x++)); } return sb.toString(); } This makes it obvious that the logic between the two methods are identical; the only difference is that: In transpose, i and j are read indices, x is a write index In untranspose, i and j are write indices, x is a read index (i.e. it's the other way around) It's really quite simple: i always goes from beginning to middle of string j always goes from end to middle of string x always goes from beginning to end of string If the input is of odd length, inevitably i == j eventually At that point you only need i, so break Lalith came up with the first recursive solution; this one is essentially the same, with minor modification: public static String transpose(String s) { int L = s.length(); return (L &lt; 2) ? s : s.substring(0, 1) + s.substring(L-1, L) + transpose(s.substring(1, L-1)); } public static String untranspose(String s) { int L = s.length(); return (L &lt; 2) ? s : s.substring(0, 1) + untranspose(s.substring(2, L)) + s.substring(1, 2); }
type: Answer
score: 3
answers question: http://stackoverflow.com/q/2626640

http://stackoverflow.com/comment/2806798
comment on: http://stackoverflow.com/a/2773033
type: Comment
has text: Need to make your getInstance() methods `synchronized` to be thread-safe.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/2798755
score: 0
type: AnswerComment
has text: I know but actually a singleton can more or less be stateless... If it doesn't share any class attribute...
type: Comment
comment on: http://stackoverflow.com/a/2765566

http://stackoverflow.com/comment/2638365
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2625466
has text: Yishai: Either would be helpful, as I think it may be the case that there are never literal quotes, >s, etc. in the file. However, I can't be sure, and if there were I would want to preserve them.
score: 0

http://stackoverflow.com/a/2786219
type: Answer
answers question: http://stackoverflow.com/q/2783007
has body: I would try to use AOP to throw failures. Something like this should work (note, I haven't tested this, and you obviouslly need to have AspectJ Setup to use AOP annotations) public class ClassUnderTest { private static Boolean exceptionThrown; @Before public void resetExceptionFlag() { ClassUnderTest.exceptionThrown = false; } @Test public void myTestMethod() { //.... // My Test Exception Code //.... assertFalse(ClassUnderTest.exceptionThrown); } @Aspect static class TestAspects { @Pointcut("handler(Exception)") public void intereceptAllExceptions(){} //This is Fully Qualified because of the conflict with the junit Before annotation above @org.aspectj.lang.annotation.Before("intereceptAllExceptions()") public void flagExceptionThrown() { ClassUnderTest.exceptionThrown = true; } } }
upvote count: 1
downvote count: 0
score: 1

http://stackoverflow.com/q/2717889
favorite count: 0
possible better answer: http://stackoverflow.com/a/7615479
has answer: http://stackoverflow.com/a/7615479
linked to: http://stackoverflow.com/q/2353964
accepted answer: http://stackoverflow.com/a/2717935
has title: Eclipse or Netbeans for Swing based application?
tagged with: netbeans
linked to: http://stackoverflow.com/q/623692
tagged with: swing
upvote count: 7
has answer: http://stackoverflow.com/a/2719367
linked to: http://stackoverflow.com/q/1126779
has answer: http://stackoverflow.com/a/2718377
has body: My next university project is going to be Java based. We will have to develop this with Swing and I was wondering what's the common preference for that? A quick glimpse through Netbeans website and I could see a powerful Swing editor, or what it looks like one; since I never used it, I don't know. As for Eclipse, I'm sure there are plugins for Swing, but are they any good? How do they compare to Netbeans? The bottom line is, should I go with Netbeans or Eclipse for a Swing based project?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2719170
has answer: http://stackoverflow.com/a/7460989
score: 7
tagged with: java
tagged with: eclipse
type: Question
has answer: http://stackoverflow.com/a/2717935
downvote count: 0
answer count: 6

http://stackoverflow.com/comment/2812088
type: Comment
has text: @David-- I'm not the judge here. If he were my student, I'd be a bit miffed that he answered using a precomputed lookup table, and probably disqualify the answer. Just saying he may want to see; calculating a full Sieve would be overkill of the input is '100', so he wouldn't want to do it on the fly, but if he can precompute the closest answer to '100', his runtime will be really fast.
type: AnswerComment
comment on: http://stackoverflow.com/a/2777526
score: 0

http://stackoverflow.com/comment/119858723
type: Comment
has text: Depending on the resulting list size, this may crash and burn with a large data set. Have found that the general pattern of storing RI data in a database, then using a search engine (Lucene et al) on top of that is superior. Provides full-text search pattern support, superior performance, built-in paging without overburdening client memory requirements, etc. In short, almost never just return (some) Collection in response to (arbitrary) user queries in that it may be thousands (or millions?) of records in size.
type: AnswerComment
comment on: http://stackoverflow.com/a/12691624
score: 0

rpc
tag name: rpc
tags question: http://stackoverflow.com/q/2650893
tags question: http://stackoverflow.com/q/2728495
type: Tag

http://stackoverflow.com/comment/2751008
has text: @Matt assuming I have many entities with the mentioned scenario is there a more structured procedure/design pattern/library which can help me do this? Also what do you mean by send a notification to other viewers? evict? (i though this is a session specific method)
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/2724171
type: Comment

http://stackoverflow.com/a/24734294
has comment: http://stackoverflow.com/comment/41250538
has body: For those of you looking for a solution for Oracle, I made a method from the code of Log4Jdbc. You will need to provide the query and the parameters passed to the preparedStatement since retrieving them from it is a bit of a pain: private String generateActualSql(String sqlQuery, Object... parameters) { String[] parts = sqlQuery.split("\\?"); StringBuilder sb = new StringBuilder(); // This might be wrong if some '?' are used as litteral '?' for (int i = 0; i &lt; parts.length; i++) { String part = parts[i]; sb.append(part); if (i &lt; parameters.length) { sb.append(formatParameter(parameters[i])); } } return sb.toString(); } private String formatParameter(Object parameter) { if (parameter == null) { return "NULL"; } else { if (parameter instanceof String) { return "'" + ((String) parameter).replace("'", "''") + "'"; } else if (parameter instanceof Timestamp) { return "to_timestamp('" + new SimpleDateFormat("MM/dd/yyyy HH:mm:ss.SSS"). format(parameter) + "', 'mm/dd/yyyy hh24:mi:ss.ff3')"; } else if (parameter instanceof Date) { return "to_date('" + new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"). format(parameter) + "', 'mm/dd/yyyy hh24:mi:ss')"; } else if (parameter instanceof Boolean) { return ((Boolean) parameter).booleanValue() ? "1" : "0"; } else { return parameter.toString(); } } }
upvote count: 26
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/2683214
has comment: http://stackoverflow.com/comment/86300047
has comment: http://stackoverflow.com/comment/90186116
score: 26
has comment: http://stackoverflow.com/comment/41225895
has comment: http://stackoverflow.com/comment/41268415

http://stackoverflow.com/a/2693497
type: Answer
has body: If you are looking for a JSR 286 (Portlet 2) or JSR 168 (Portlet 1) compliant portlet, what you have read is correct. You need a portlet container. JBoss used to have JBoss Portal that should fit in your stack if you are focused on the JBoss products. In fact, you can find an entire bridge between JBoss Portal and the stack you are using. If you decide that you need a portal and want to look to other apps, I have successfully run Liferay on JBoss in the past. At the same time, you can get something that looks and behaves like a portlet by using iframes or a div and JavaScript and back-end coding. With more specifics on what you want your pseudo-portlets to do, the community can more specifically help you figure out if wiring your own smaller framework within your existing code or attempting to have some sort of larger portlet container seems more reasonable. If you want to reproduce all of the Portlet 1 or 2 spec, I'd go with the container. If you want to reproduce a mini-iGoogle, you can probably do someting with JS and HTML. EDIT: Looking through other questions with the same portlet tag, I found the jQuery UI Sortable - Portlets demo that might provide just the portlet-like features you are looking for without an entire Portal framework. It does, of course, pull in jQuery UI.
score: 1
upvote count: 1
accepted answer of: http://stackoverflow.com/q/2693473
answers question: http://stackoverflow.com/q/2693473
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/q/2772284
accepted answer: http://stackoverflow.com/a/2772355
upvote count: 2
answer count: 2
tagged with: stream
tagged with: network-programming
tagged with: java
has title: Client Server communication in Java - which approach to use?
tagged with: client-server
score: 2
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/2772355
favorite count: 0
possible better answer: http://stackoverflow.com/a/2772365
has answer: http://stackoverflow.com/a/2772365
type: Question
has body: I have a typical client server communication - Client sends data to the server, server processes that, and returns data to the client. The problem is that the process operation can take quite some time - order of magnitude - minutes. There are a few approaches that could be used to solve this. Establish a connection, and keep it alive, until the operation is finished and the client receives the response. Establish connection, send data, close the connection. Now the processing takes place and once it is finished the server could establish a connection to the client to send the data. Establish a connection, send data, close the connection. Processing takes place. client asks server, every n minutes/seconds if the operation is finished. If the processing is finished the client fetches the data. I was wondering which approach would be the best way to use. Is there maybe some "de facto" standard for solving this problem? How "expensive" is opening a socket in Java? Solution 1. seems pretty nasty to me, but 2. and 3. could do. The problem with solution 2. is that the server needs to know on which port the client is listening, while solution 3. adds some network overhead.

http://stackoverflow.com/a/2737960
upvote count: 1
downvote count: 0
has body: Try passing a reference of the JTextarea in question to the output.java as a Constructor or method argument.
type: Answer
answers question: http://stackoverflow.com/q/2735943
score: 1

http://stackoverflow.com/a/32736631
score: 2
answers question: http://stackoverflow.com/q/2755445
downvote count: 0
type: Answer
has body: Yes, if you are using Java 8 or above. Java 8 make it possible to define anonymous functions, which was impossible in previous versions. Lets take example from java docs to get know how we can declare anonymous functions, classes The following example, HelloWorldAnonymousClasses, uses anonymous classes in the initialization statements of the local variables frenchGreeting and spanishGreeting, but uses a local class for the initialization of the variable englishGreeting: public class HelloWorldAnonymousClasses { interface HelloWorld { public void greet(); public void greetSomeone(String someone); } public void sayHello() { class EnglishGreeting implements HelloWorld { String name = "world"; public void greet() { greetSomeone("world"); } public void greetSomeone(String someone) { name = someone; System.out.println("Hello " + name); } } HelloWorld englishGreeting = new EnglishGreeting(); HelloWorld frenchGreeting = new HelloWorld() { String name = "tout le monde"; public void greet() { greetSomeone("tout le monde"); } public void greetSomeone(String someone) { name = someone; System.out.println("Salut " + name); } }; HelloWorld spanishGreeting = new HelloWorld() { String name = "mundo"; public void greet() { greetSomeone("mundo"); } public void greetSomeone(String someone) { name = someone; System.out.println("Hola, " + name); } }; englishGreeting.greet(); frenchGreeting.greetSomeone("Fred"); spanishGreeting.greet(); } public static void main(String... args) { HelloWorldAnonymousClasses myApp = new HelloWorldAnonymousClasses(); myApp.sayHello(); } } Syntax of Anonymous Classes Consider the instantiation of the frenchGreeting object: HelloWorld frenchGreeting = new HelloWorld() { String name = "tout le monde"; public void greet() { greetSomeone("tout le monde"); } public void greetSomeone(String someone) { name = someone; System.out.println("Salut " + name); } }; The anonymous class expression consists of the following: The new operator The name of an interface to imple…
upvote count: 2

http://stackoverflow.com/q/2756772
type: AnsweredQuestion
tagged with: jsf
score: 0
accepted answer: http://stackoverflow.com/a/2756831
type: Question
tagged with: java
has body: I have a folder named Common/Images/Photounavailable.jpg. Is this right way of refering to a image from root? I want to refer this image from any page in any folder in my web application. private String getPhotoUnavailablePath = "/Common/Images/PhotoNotAvailable.jpg"; private String getPhotoUnavailablePath(){ return photoUnavailablePath; } And from my JSF page i write something like :- &lt;h:outputLink id ="blogPhoto" value="#{BlogBean.photoUnavailablePath}" &gt; &lt;h:graphicImage value="#{BlogBean.photoUnavailablePath}" style="width: 180px;height: 180px;"/&gt; &lt;/h:outputLink&gt; I get the image to see in h:graphicImage. But when i click on it, i get 404 error. OutputLink doesn't get proper link to image. How is it possible? That h:graphicImage gets proper link and h:outputLink doesn't? Further, this code works perfectly :- &lt;h:outputLink id ="blogPhoto" value="..#{BlogBean.photoUnavailablePath}" &gt; &lt;h:graphicImage value="#{BlogBean.photoUnavailablePath}" style="width: 180px;height: 180px;"/&gt; &lt;/h:outputLink&gt; Just by putting .. it works! Can anybody explain me what is happening and how do I solve this?
has title: How do i refer to any image in my java web application from root of my web application?
answer count: 1
has answer: http://stackoverflow.com/a/2756831

http://stackoverflow.com/q/2692445
has answer: http://stackoverflow.com/a/2692712
upvote count: 3
tagged with: java
has body: How can I take a string in a format such as: 2008-06-02 00:00:00.0 and convert it to: 02-Jun-2008? Can I somehow take the original string, convert it to a Date object, then use a formatter to get the final output (rather than parsing the string myself)? Thanks!
has comment: http://stackoverflow.com/comment/2713911
type: Question
downvote count: 0
has answer: http://stackoverflow.com/a/2692500
has title: Date conversion in Java
tagged with: date
accepted answer: http://stackoverflow.com/a/2692485
has comment: http://stackoverflow.com/comment/2714025
has comment: http://stackoverflow.com/comment/2713886
linked to: http://stackoverflow.com/q/2675666
score: 3
has answer: http://stackoverflow.com/a/2692491
has comment: http://stackoverflow.com/comment/2714112
tagged with: string
has comment: http://stackoverflow.com/comment/2713827
favorite count: 0
possible better answer: http://stackoverflow.com/a/2692491
answer count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2692485

http://stackoverflow.com/q/2728739
accepted answer: http://stackoverflow.com/a/2729857
has body: I'm developing some widgets into a library for internal use at the company I work for. I don't know what's the recommended way to style the widgets. There are at least these ways: use Widget.setPrimaryStyleName and let the user provide an external css. We use maven archetypes to build applications so we can provide default styles. Anyway I don't like it very much. use the GWT 2.0 CssResourceBundle. So we can compile the CSS into the module and it will be optimized (and it can be browser-dependant too). provide a module with the styling. Something like the default GWT themes. But I don't know how exactly this works. I want to: make the components as cohesive as I can (don't depend on externally included css's) leave open the door to modify styles (if I want to change the way some widget looks in a concrete application). What's your experience in this subject? Note: if you are looking for a definitive answer look through all the answers and the comments. There are different ideas and all good ones. Then choose what is best for you :)
answer count: 2
downvote count: 0
favorite count: 0
possible better answer: http://stackoverflow.com/a/2755615
has answer: http://stackoverflow.com/a/2755615
tagged with: css
type: AnsweredQuestion
tagged with: widget
score: 7
tagged with: java
upvote count: 7
has answer: http://stackoverflow.com/a/2729857
has title: Best way to style GWT widgets in a library
type: Question
tagged with: gwt

http://stackoverflow.com/comment/2618825
has text: You should limit it, yes, but sometimes you've got to leave cracks in the armor so that everything can work. Limiting access to fields though, that's very useful anyway. (If nothing else, going through getters and setters lets you change how the field works without impacting clients of the class. Very convenient.)
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2606652

http://stackoverflow.com/a/2663465
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/2681210
answers question: http://stackoverflow.com/q/2662740
downvote count: 0
has body: I wonder, is there something I can do to my Swing applications behave the same in every computer? I'm working on a complex Java Swing app that is shipped on OS X / Windows / Linux so just like Bozhidar answered, the issues are all far too real. For some components, if you happen to have some UI design/programming skills, you can simply write your own component: I realize it's probably not a helpful answer, but it works. For example, we wanted a drop-down "find-as-you-type" popup list (like the one that appears when you start a search on Google's main search page) that would look and work the same on Linux/Windows/OS X. After trying countless of "solutions" full of Swing idiosynchrasies that would not work everywhere (like, guess what, focus issues ; ) we decided to simply write our own component "from scractch". We can intercept mouse and keyboard events on both OS X / Windows / Linux: we can write a component that not only looks but also behaves identically on all three platforms. In addition to the "find-as-you-type", we also wrote our own tooltip-popup component, a dual progress bar (to progress bar in one to show producer/consumer style progress in a single bar) and a complex component involving several "text fields" which was absurdly complex and broken when we tried to do it using Swing (and broken in different ways on different platforms, like weird focus issues or caret not showing, etc.). So we "went dirty" and rewrote the entire component ourselves. Result? Working identically on all platforms where Java can give you notifications about mouse and keyboard events... I realize this may not be what you want to hear: I happen to have worked on both games UI and mobile apps UI back in the days and I have some graphic skills so it's not "hard" for me to write good looking UI components. Sadly if you want some Java UI component to look and behave identically on all platforms, it's sometimes your only alternative...
type: Answer
has comment: http://stackoverflow.com/comment/2685155

http://stackoverflow.com/q/2705640
answer count: 1
has answer: http://stackoverflow.com/a/2705680
tagged with: jsp
tagged with: http://stackoverflow.com/tag/html
has title: Form character encoding problems with special characters
accepted answer: http://stackoverflow.com/a/2705680
score: 0
type: AnsweredQuestion
tagged with: java
has body: Hello I have a jsp with an html form. I set the content type like this: &lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %&gt; When I send special characters like á é í ó ú they are saved correctly in the database. My table charset is utf-8. I want to change iso-8859 to utf-8 like this to standardize my application and accept more special characters: &lt;%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %&gt; but when I change it to utf-8 the special characters á é í ó ú are not saved correctly in the databse. When I try to save á it is saved as Ã¡ In the server side I'm using Spring MVC. I'm getting the text field value like this: String strField = ServletRequestUtils.getStringParameter(request, "field");
tagged with: forms
type: Question
tagged with: encoding

http://stackoverflow.com/q/2773779
tagged with: final
tagged with: java
has comment: http://stackoverflow.com/comment/3129119
has answer: http://stackoverflow.com/a/2773976
type: Question
has answer: http://stackoverflow.com/a/26619431
score: 21
has comment: http://stackoverflow.com/comment/2807805
has answer: http://stackoverflow.com/a/2773814
has title: Problems initializing a final variable in Java
upvote count: 21
has comment: http://stackoverflow.com/comment/3133038
has answer: http://stackoverflow.com/a/2773811
favorite count: 0
accepted answer: http://stackoverflow.com/a/2773811
has body: I keep running into slight variations of a problem in Java and it's starting to get to me, and I can't really think of a proper way to get around it. I have an object property that is final, but dynamic. That is, I want the value to be constant once assigned, but the value can be different each runtime. So I declare the class level variable at the beginning of the class - say private final FILE_NAME;. Then, in the constructor, I assign it a value - say FILE_NAME = buildFileName(); The problem begins when I have code in the buildFileName() method that throws an exception. So I try something like this in the constructor: try{ FILE_NAME = buildFileName(); } catch(Exception e){ ... System.exit(1); } Now I have an error - "The blank final field FILE_NAME may not have been initialized." This is where I start to get slightly annoyed at Java's strict compiler. I know that this won't be a problem because if it gets to the catch the program will exit... But the compiler doesn't know that and so doesn't allow this code. If I try to add a dummy assignment to the catch, I get - "The final field FILE_NAME may already have been assigned." I clearly can't assign a default value before the try-catch because I can only assign to it once. Any ideas...?
has comment: http://stackoverflow.com/comment/2807675
linked to: http://stackoverflow.com/q/3301635
answer count: 5
tagged with: exception
has answer: http://stackoverflow.com/a/2773912
possible better answer: http://stackoverflow.com/a/2773814
has comment: http://stackoverflow.com/comment/3123951
tagged with: constants
type: AnsweredQuestion
downvote count: 0
has comment: http://stackoverflow.com/comment/2807630

http://stackoverflow.com/comment/101158855
score: 2
has text: What happens when you send it a primitive array, is that it interprets that primitive array as the first vararg. This happens because `asList` requires objects because it and `List` use generic typing which requires objects, not primitives. Since an `int` is not an object, but an `int[]` is an object, it interprets it differently than if you sent an `Integer[]` which is an object array containing `Integer` objects. So in the second case it treats the `Integers` within the array as the vararg terms instead of the `Integer[]` as a vararg term itself.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2607335

http://stackoverflow.com/q/2755972
has answer: http://stackoverflow.com/a/2755987
has comment: http://stackoverflow.com/comment/2792764
has answer: http://stackoverflow.com/a/2756001
upvote count: 34
linked to: http://stackoverflow.com/q/465953
tagged with: throwable
has title: Extending Throwable in Java
tagged with: java
has answer: http://stackoverflow.com/a/2756014
answer count: 7
has answer: http://stackoverflow.com/a/2756629
possible better answer: http://stackoverflow.com/a/2756629
accepted answer: http://stackoverflow.com/a/2756001
has comment: http://stackoverflow.com/comment/2794042
score: 34
has comment: http://stackoverflow.com/comment/2788000
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/498217
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2755999
has body: Java lets you create an entirely new subtype of Throwable, e.g: public class FlyingPig extends Throwable { ... } Now, very rarely, I may do something like this: throw new FlyingPig("Oink!"); and of course elsewhere: try { ... } catch (FlyingPig porky) { ... } My questions are: Is this a bad idea? And if so, why? What could've been done to prevent this subtyping if it is a bad idea? Since it's not preventable (as far as I know), what catastrophies could result? If this isn't such a bad idea, why not? How can you make something useful out of the fact that you can extends Throwable? Proposed scenario #1 A scenario where I was really tempted to do something like this has the following properties: The "event" is something that will happen eventually. It is expected. It most definitely is not an Error, and there's nothing Exception-al about when it occurs. Because it is expected, there will be a catch waiting for it. It will not "slip" past anything. It will not "escape" from any attempt to catch general Exception and/or Error. The "event" happens extremely rarely. When it happens, usually there's a deep stack trace. So perhaps it's clear now what I'm trying to say: FlyingPig is the result of an exhaustive recursive search. The object to be searched exists: it's only a matter of finding it in the big sea that is the search space. The search process will be a long one, so the relatively expensive cost of exception handling is negligible. In fact, the traditional control flow construct alternative of using a boolean isFound flag may be more expensive, because it has to be checked continuously throughout the search process, most likely at every level of the recursion. This check will fail 99.99% of the time, but it's absolutely necessary to propagate the termination condition. In a way, while effective, the check is inefficient! By simply throw-ing a FlyingPig when the sought object is found, you don't have to clutter the code with the management of the boolean isFound flag.…
type: Question
tagged with: exception
has answer: http://stackoverflow.com/a/3600756
has answer: http://stackoverflow.com/a/3600459

http://stackoverflow.com/comment/76396490
type: QuestionComment
has text: Honestly, I don't remember. I have touched Java in years.
comment on: http://stackoverflow.com/q/2766343
score: 0
type: Comment

http://stackoverflow.com/a/2656295
has body: It should be as below: while ((count = in.read(b)) &gt;= 0) in.read can return 0.
score: 3
answers question: http://stackoverflow.com/q/2656209
has comment: http://stackoverflow.com/comment/2676700
has comment: http://stackoverflow.com/comment/2674563
has comment: http://stackoverflow.com/comment/2674168
downvote count: 0
type: Answer
upvote count: 3

http://stackoverflow.com/comment/14612687
type: Comment
comment on: http://stackoverflow.com/a/2642267
has text: Worked like a charm for me, and I just keep them in the same workspace. When you switch between C++ and Java projects it should automatically switch between C++ and Java perspectives as well.
score: 0
type: AnswerComment

http://stackoverflow.com/a/2695535
downvote count: 0
has comment: http://stackoverflow.com/comment/2720217
score: 1
has body: I think you need to choose a new (higher) version number, and modify your onUpgrade method to delete routes if it exists as well. Of course you may not actually need to delete your existing tables (e.g. creating and altering may be enough), but doing so is consistent with your current implementation. You will call the SQLiteOpenHelper constructor with the new version, and it will internally call onUpgrade, passing the old and new versions.
has comment: http://stackoverflow.com/comment/2720816
type: Answer
answers question: http://stackoverflow.com/q/2695505
upvote count: 1
has comment: http://stackoverflow.com/comment/2720573
has comment: http://stackoverflow.com/comment/2719893

http://stackoverflow.com/comment/2774432
has text: Are Game, GameStatus and Ticket implementing serializable? Have you Tried to isolate each writeObject to see where this exception come from?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2744962
score: 2

http://stackoverflow.com/q/2710883
type: Question
has answer: http://stackoverflow.com/a/2718949
has answer: http://stackoverflow.com/a/71947841
has answer: http://stackoverflow.com/a/8929557
has body: Is there a way in Java to find the "Last Fired Time" from a Cron Expression? E.g. If now = 25-Apr-2010 10PM, and the cron expression is 0 15 10 ? * * (quartz), it should return 25-Apr-2010 10:15AM. Note: I do not care if we use standard cron expressions (like Unix and Quartz) or less popular ones if they can fetch me the correct "Last Fired Time" Also it is not literally "Last Fire time" as the trigger may not have fired, but logically there should be a way of telling when it (would have) fired last.
has answer: http://stackoverflow.com/a/58025578
answer count: 11
tagged with: scheduling
has answer: http://stackoverflow.com/a/31238479
has answer: http://stackoverflow.com/a/40800995
downvote count: 0
favorite count: 0
score: 16
has answer: http://stackoverflow.com/a/77179174
has answer: http://stackoverflow.com/a/51303967
has answer: http://stackoverflow.com/a/34722770
has answer: http://stackoverflow.com/a/58216163
upvote count: 16
has title: Finding Last Fired time using a Cron Expression in Java
tagged with: crontrigger
type: UnansweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/2711139
tagged with: quartz-scheduler

http://stackoverflow.com/comment/20451011
comment on: http://stackoverflow.com/a/2611900
score: 0
type: AnswerComment
has text: @RajeevM, no, it's not the same. But last time I checked, it was better in some ways (see second paragraph).
type: Comment

http://stackoverflow.com/a/2667888
downvote count: 0
has body: What you described is only merging (without sorting), sorting is done recursivly in merge sort. Also, what are the ramifications of doing this on a linked list? It's probalby too expensive to split linked lists, if you have two sorted lists you could easily merge them maintaining the order.
type: Answer
score: 1
answers question: http://stackoverflow.com/q/2667647
upvote count: 1

http://stackoverflow.com/comment/26253634
has text: The link is Dead! > http://blogs.webtide.com/athena/entry/asynchronous_blazeds_polling_with_jetty
comment on: http://stackoverflow.com/a/2671560
type: Comment
type: AnswerComment
score: 0

http://stackoverflow.com/a/2786056
upvote count: 1
accepted answer of: http://stackoverflow.com/q/2786038
answers question: http://stackoverflow.com/q/2786038
has body: For text representation, I would recommend picking a few characters that are very unlikely to occur in your strings, then outputting a CSV format file with those characters as separators, quotes, terminators, and escapes. Essentially, each row (as designated by the terminator, since otherwise there might be line-ending characters in either string) would have as the first CSV "field" the key of an entry in the hashtable, as the second field, the value for it. A simpler approach along the same lines would be to designate one arbitrary character, say the backslash \, as the escape character. You'll have to double up backslashes when they occur in either string, and express in escape-form the tab (\t) and line-end ('\n); then you can use a real (not escape-sequence) tab character as the field separator between the two fields (key and value), and a real (not escape-sequence) line-end at the end of each row.
type: AcceptedAnswer
downvote count: 0
type: Answer
score: 1

http://stackoverflow.com/comment/2716191
type: Comment
has text: Are you sure to have packaged your jar correctly?Can you use it on a simple test java program from command line?
comment on: http://stackoverflow.com/q/2694392
type: QuestionComment
score: 0

http://stackoverflow.com/a/14399850
answers question: http://stackoverflow.com/q/2621701
has comment: http://stackoverflow.com/comment/34777125
score: 22
downvote count: 12
has comment: http://stackoverflow.com/comment/34220905
has comment: http://stackoverflow.com/comment/34822407
type: Answer
has body: Try switching to Logback and use ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger)LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME); rootLogger.setLevel(Level.toLevel("info")); I believe this will be the only call to Logback and the rest of your code will remain unchanged. Logback uses SLF4J and the migration will be painless, just the xml config files will have to be changed. Remember to set the log level back after you're done.
upvote count: 34

http://stackoverflow.com/a/2623364
has body: I kind of combined both answers: I used two tables that share one's scrollbar. This works with sorting, and it actually makes the model simpler. Tabbing doesn't matter, but comparing "A" and "B" does. I think I was trying to solve a "view" problem in the "model". I made this a separate answer, because I'd appreciate any critical comments. public TablePanel() { this.setLayout(new GridLayout(1, 0, 8, 0)); JTable tableA = new JTable(new MyModel("A")); tableA.setPreferredScrollableViewportSize(new Dimension(200, 400)); final JScrollPane jspA = new JScrollPane(tableA); jspA.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); this.add(jspA); JTable tableB = new JTable(new MyModel("B")); tableB.setPreferredScrollableViewportSize(new Dimension(200, 400)); final JScrollPane jspB = new JScrollPane(tableB); jspB.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); this.add(jspB); tableA.setSelectionModel(tableB.getSelectionModel()); jspA.getVerticalScrollBar().setModel(jspB.getVerticalScrollBar().getModel()); }
score: 6
downvote count: 0
type: Answer
upvote count: 6
answers question: http://stackoverflow.com/q/2614457

http://stackoverflow.com/a/2724400
answers question: http://stackoverflow.com/q/2724327
downvote count: 0
type: Answer
has body: I'm not sure what your end goal is, but perhaps http://browsershots.org/ offers the functionality you're looking for? It would appear they offer both an XML-RPC interface and also the source code freely. Edit: It looks like the source code link isn't properly hooked up currently.
score: 1
upvote count: 1

http://stackoverflow.com/q/2786379
tagged with: date-format
has title: Java Date sorting method?
type: AnsweredQuestion
has body: I have an String array of dates in the format ex:'2010-05-04 11:26:46 +0530'. How can I check whether a particular date in the array is > today? thanks
downvote count: 0
tagged with: calendar
type: Question
score: 3
tagged with: java
tagged with: sorting
tagged with: date
has comment: http://stackoverflow.com/comment/2821999
upvote count: 3
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/2786391
accepted answer: http://stackoverflow.com/a/2786391

http://stackoverflow.com/comment/2786327
comment on: http://stackoverflow.com/a/2755162
has text: @adam08 - Make sure to mark your question as answered if it solved the problem!
type: Comment
score: 3
type: AnswerComment

http://stackoverflow.com/comment/2629831
has text: @steve-emmerson C is similar to Java, at least, syntax-wise, and C provides the capability of inline assembly which is difficult in Java. So @wizardofodds is correct in that respect. In other words, it isn't just this particular assembly that's difficult, it's assembly in general, in comparison.
type: Comment
comment on: http://stackoverflow.com/a/2617719
type: AnswerComment
score: 0

http://stackoverflow.com/comment/2649782
comment on: http://stackoverflow.com/a/2635520
type: Comment
score: 3
has text: The Java Control Panel is available on Linux & Solaris as well. On GNOME it can usually be found under System->Preferences->Java
type: AnswerComment

http://stackoverflow.com/comment/2941160
type: QuestionComment
comment on: http://stackoverflow.com/q/2638622
has text: @Oscar Reyes, I don't think Java 7 specification for closures has been published officially yet.
score: 0
type: Comment

http://stackoverflow.com/comment/54047763
comment on: http://stackoverflow.com/a/2663565
score: 0
type: AnswerComment
has text: When pressing back button from maps app,there shows a black screen and underlying activity is recreated.Any idea how to fix this?
type: Comment

http://stackoverflow.com/q/2686236
favorite count: 0
has title: Require help with program for edutainment game
has comment: http://stackoverflow.com/comment/2706619
has answer: http://stackoverflow.com/a/2686308
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2706837
has comment: http://stackoverflow.com/comment/2706749
downvote count: 0
has comment: http://stackoverflow.com/comment/2706656
linked to: http://stackoverflow.com/q/2685524
type: Question
has body: I am working on a factorisation problem and for small numbers it is working well. I've been able to calculate the factors (getting the answers from Wolfram Alpha) for small numbers, like the one on the Wikipedia page (5959). Along with the Wikipedia page I have been following this guide. Once again, as my Math knowledge is pretty poor I cannot follow what I need to do next. EDIT: It finally works! I'll post the working code up here once I've got it fully working so that others in my predicament can learn from it.
has comment: http://stackoverflow.com/comment/2706601
score: 3
tagged with: math
tagged with: java
has comment: http://stackoverflow.com/comment/2706630
possible better answer: http://stackoverflow.com/a/2686308
upvote count: 3
answer count: 3
has answer: http://stackoverflow.com/a/2686368
has answer: http://stackoverflow.com/a/2686380
accepted answer: http://stackoverflow.com/a/2686380

http://stackoverflow.com/comment/2624102
type: AnswerComment
score: 0
type: Comment
has text: @WizardOfOdds thank you,elegant and brilliant ideea,i was thinking of that too,but my question is the following: When i start assign the numbers,i travel trough the array and where i find 1,i check min(up,down,left,right)+1 (which will be size 1 or to,in the first loop of the array-"traveling"). So i will have the new array made of 0,1 and 2.Then i have to loop it again,so i will have an array made of 0,1,2 and 3s.And so on, n-times.But...how would this work on a huge array?
comment on: http://stackoverflow.com/a/2608446

http://stackoverflow.com/q/2644330
tagged with: null
score: 4
answer count: 2
possible better answer: http://stackoverflow.com/a/2652709
has title: Setting nested object to null when selected option has empty value
accepted answer: http://stackoverflow.com/a/2665942
favorite count: 0
has answer: http://stackoverflow.com/a/2665942
upvote count: 4
tagged with: spring
tagged with: spring-mvc
type: AnsweredQuestion
tagged with: data-binding
downvote count: 0
has answer: http://stackoverflow.com/a/2652709
tagged with: java
has body: I have a Class which models a User and another which models his country. Something like this: public class User{ private Country country; //other attributes and getter/setters } public class Country{ private Integer id; private String name; //other attributes and getter/setters } I have a Spring form where I have a combobox so the user can select his country or can select the undefined option to indicate he doen't want to provide this information. So I have something like this: &lt;form:select path="country"&gt; &lt;form:option value=""&gt;-Select one-&lt;/form:option&gt; &lt;form:options items="${countries}" itemLabel="name" itemValue="id"/&gt; &lt;/form:select&gt; In my controller I get the autopopulated object with the user information and I want to have country set to null when the "-Select one-" option has been selected. So I have set a initBinder with a custom editor like this: @InitBinder protected void initBinder(WebDataBinder binder) throws ServletException { binder.registerCustomEditor(Country.class, "country", new CustomCountryEditor()); } and my editor do something like this: public class CustomCountryEditor(){ @Override public String getAsText() { //I return the Id of the country } @Override public void setAsText(String str) { //I search in the database for a country with id = new Integer(str) //and set country to that value //or I set country to null in case str == null } } When I submit the form it works because when I have country set to null when I have selected "-Select one-" option or the instance of the country selected. The problem is that when I load the form I have a method like the following one to load the user information. @ModelAttribute("user") public User getUser(){ //loads user from database } The object I get from getUser() has country set to a specific country (not a null value), but in the combobox is not selected any option. I've debugged the application and the CustomCountryEditor works good when setting and getting the text, thoug…
type: Question

http://stackoverflow.com/a/2776714
score: 4
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/2811496
answers question: http://stackoverflow.com/q/2772303
upvote count: 4
has body: Question has been answered, but I'll post there here for those who care for a cleaner solution: //Set debit if exactly one or all three are true, else set credit if(adjustment.adjustmentAccount.isIncrease ^ adjustment.increaseVATLine ^ adjustment.vatItem.isSalesType) { entry2.setDebit(adjustment.total); entry2.setCredit(0d); } else { entry2.setCredit(adjustment.total); entry2.setDebit(0d); }

http://stackoverflow.com/q/2603580
has title: Sonar and Eclipse IAM Plugin
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2603643
tagged with: maven
has body: When I am using the newest IAM Eclipse Plugin for Maven with the current Sonar version on a JDK 6 and I get an error while executing the sonar:sonar goal in clean install sonar:sonar The error in eclipse is 23:02:55 MESZ Starting Starting mojoExecution sonar-core:internal 23:03:44 MESZ fatal org.sonar.maven2.BatchMojo#execute() caused a linkage error (java.lang.NoSuchMethodError). Check the realms: ... java.lang.NoSuchMethodError: org.apache.maven.execution.ReactorManager.&lt;init&gt;(Ljava/util/List;)V Any idea how to fix it? PS: If I do a mvn clean install sonar:sonar manually this it not an issue.
tagged with: java
tagged with: sonarqube
tagged with: eclipse
type: Question
answer count: 1
score: 0

http://stackoverflow.com/q/2693473
answer count: 2
accepted answer: http://stackoverflow.com/a/2693497
has title: Can I add a java portlet to an existing java Web App?
has body: I'm building a webapp that uses jboss-seam with jsf, facelets and rich faces, running on top of jboss AS 5.1. I would like to add a portlet area where I could add my own portlets, but from what I got (reading forums and documentation) I need to be running a portlet container/portal (something like liferay or gatein). But I don't want to be running a portal. I just want some kind of control where I can embed a portlet (something like an iFrame). Is this true or I got it wrong? If I'm wrong, how can I add an area to my webapp where I can add a portlet? Thanks Best regards.
score: 0
tagged with: portlet
possible better answer: http://stackoverflow.com/a/2693955
tagged with: richfaces
has answer: http://stackoverflow.com/a/2693955
has answer: http://stackoverflow.com/a/2693497
type: AnsweredQuestion
tagged with: java
tagged with: jboss
type: Question
tagged with: portal

http://stackoverflow.com/comment/53655685
comment on: http://stackoverflow.com/q/2745265
has text: Related SO question - [Whats the use of saying <? extends SomeObject> instead of <SomeObject>](http://stackoverflow.com/questions/17834145/whats-the-use-of-saying-extends-someobject-instead-of-someobject/17834223)
score: 5
type: QuestionComment
type: Comment

http://stackoverflow.com/a/5203440
has body: The right way to do this is to use normalize(str,NFD) fromjava.text.Normalizer, and then delete the characters of general category Mark \pM or Non-Spacing Mark \p{Mn}. Java does not support the standard Unicode property \p{Diacritic} or you could use that. Note that not all Diacritics are Non-Spacing Marks, nor vice versa. However, this is probably the wrong thing to do. If you are trying to do accent-insensitive string searches and comparisons, the right way to do that is to leave the strings as they are. You need to create a UCA collation object with the level set to 1 (or rather, PRIMARY), then use that to compare your strings. If strings compare equal at the primary strength, it disregards things like accent marks. Here are examples in Java of how to do that using ICU’s Collator class. If you’re using proper UCA collators, then you don’t have to normalize; they take care of this for you. This answer in Perl uses two UCA collator objects, one at the primary strength to completely ignore accents for string searches and comparisons, and another that allows diacritics to be distinguished at the secondary strength as is normal for Unicode.
downvote count: 0
type: Answer
score: 5
answers question: http://stackoverflow.com/q/2774320
upvote count: 5

http://stackoverflow.com/comment/2849485
comment on: http://stackoverflow.com/a/2774301
type: AnswerComment
has text: My answer was intended to give you an idea of the use of Executors. There are also some fine tutorials out there. Hopefully if you decide Executors will work you can adapt the code as needed. Did you have another specific question you needed to ask?
score: 0
type: Comment

http://stackoverflow.com/comment/12999963
score: 0
type: Comment
comment on: http://stackoverflow.com/a/10139947
type: AnswerComment
has text: easiest way to do it without using any specific method.

http://stackoverflow.com/comment/89444095
has text: _But at least it enforces for wait() and notify(), right?_ That's right. I can't think of any situation where the condition can be put outside synchronized. That would be a situation where the evaluation of the condition doesn't really matter at the point where wait or notify is called.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2779674

http://stackoverflow.com/comment/83182275
comment on: http://stackoverflow.com/q/2707531
type: QuestionComment
has text: Were you able to figure out how to parse this? I am having the same difficulties parsing the same type of xml document
score: 0
type: Comment

http://stackoverflow.com/comment/2752822
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2725929
has text: do you know some simple description of what EDT violations are (why they can happen) and how I can remove them?
type: AnswerComment

http://stackoverflow.com/a/2734995
type: Answer
score: 0
answers question: http://stackoverflow.com/q/2734981
has body: Try a = 1 and b = 1 ;) + and | have different when two bits at the same positions are 1

http://stackoverflow.com/q/2699488
downvote count: 0
tagged with: java
type: Question
upvote count: 2
tagged with: flash
has title: Can I call a java class method from inside a flash movie?
accepted answer: http://stackoverflow.com/a/2699526
has body: Can I call a java class method from inside a flash movie?
answer count: 1
has answer: http://stackoverflow.com/a/2699526
favorite count: 0
score: 2
type: AnsweredQuestion

http://stackoverflow.com/comment/2775835
type: AnswerComment
has text: @FredOverflow: and I like your solution for its specificity. Which is why I upvoted your answer. What do you want me to do? Downvote my own answer? Delete it? Like I said, I still stand by my answer, generality being what I was aiming for (which is why I used `K` in the first place).
comment on: http://stackoverflow.com/a/2742339
type: Comment
score: 0

http://stackoverflow.com/q/2704417
tagged with: performance
has title: Why is Go so slow (compared to Java)?
tagged with: java
has comment: http://stackoverflow.com/comment/2728596
has comment: http://stackoverflow.com/comment/22496335
has answer: http://stackoverflow.com/a/2705047
has answer: http://stackoverflow.com/a/52325174
has comment: http://stackoverflow.com/comment/2728346
downvote count: 10
has comment: http://stackoverflow.com/comment/2731562
has answer: http://stackoverflow.com/a/26938756
has answer: http://stackoverflow.com/a/41539785
has comment: http://stackoverflow.com/comment/138126479
score: 116
tagged with: benchmarking
has comment: http://stackoverflow.com/comment/2741917
has comment: http://stackoverflow.com/comment/99010540
possible better answer: http://stackoverflow.com/a/2705047
has comment: http://stackoverflow.com/comment/2737085
has comment: http://stackoverflow.com/comment/5424754
favorite count: 0
tagged with: go
has answer: http://stackoverflow.com/a/30689114
has answer: http://stackoverflow.com/a/2704455
has comment: http://stackoverflow.com/comment/2739910
has comment: http://stackoverflow.com/comment/22496232
has answer: http://stackoverflow.com/a/6867046
answer count: 10
upvote count: 126
has comment: http://stackoverflow.com/comment/2735921
has comment: http://stackoverflow.com/comment/2727906
has comment: http://stackoverflow.com/comment/2729133
has comment: http://stackoverflow.com/comment/96591559
has comment: http://stackoverflow.com/comment/2728936
has answer: http://stackoverflow.com/a/11866136
has answer: http://stackoverflow.com/a/56174069
has comment: http://stackoverflow.com/comment/55280658
has answer: http://stackoverflow.com/a/56192769
has body: As we could see from The Computer Language Benchmarks Game in 2010: Go is on average 10x slower than C Go is 3x slower than Java !? How can this be, bearing in mind that Go compiler produces native code for execution? Immature compilers for Go? Or there is some intrinsic problem with the Go language? EDIT: Most answers deny intrinsic slowness of Go languge, claiming the problem resides in immature compilers. Therefore I've made some own tests to calculate Fibonacci numbers: Iterative algorithm runs in Go (freebsd,6g) with the same speed as in C (with O3 option). The dull recursive one runs in Go 2 times slower than in C (with -O3 option; with -O0 - the same). But I haven't seen 10x fall as in the Benchmarks Game.
type: Question
accepted answer: http://stackoverflow.com/a/2704455
has comment: http://stackoverflow.com/comment/2727929
type: AnsweredQuestion

http://stackoverflow.com/q/2618833
tagged with: netbeans
has title: NetBeans Platform - how to refresh the property sheet view of a node?
answer count: 3
upvote count: 1
tagged with: properties
has body: I am using the PropertySheetView component to visualize and edit the properties of a node. This view should always reflect the most recent properties of the object; if there is a change to the object in another process, I want to somehow refresh the view and see the updated properties. The best way I was able to do this is something like the following (making use of EventBus library to publish and subscribe to changes in objects): public DomainObjectWrapperNode(DomainObject obj) { super (Children.LEAF, Lookups.singleton(obj)); EventBus.subscribe(DomainObject.class, this); } public void onEvent(DomainObject event) { // Do a check to determine if the updated object is the one wrapped by this node; // if so fire a property sets change firePropertySetsChange(null, this.getPropertySets()); } This works, but my place in the scrollpane is lost when the sheet refreshes; it resets the view to the top of the list and I have to scroll back down to where I was before the refresh action. So my question is, is there a better way to refresh the property sheet view of a node, specifically so my place in the property list is not lost upon refresh? The solution of firePropertySetsChange comes from this thread.
tagged with: java
has answer: http://stackoverflow.com/a/12075972
has answer: http://stackoverflow.com/a/40601231
has answer: http://stackoverflow.com/a/3335789
downvote count: 0
type: UnansweredQuestion
score: 1
tagged with: netbeans-platform
type: Question
favorite count: 0

http://stackoverflow.com/comment/2648001
type: AnswerComment
has text: Yeah, now that I think about it, I could have easily tested this my self. Heh, I feel dumb. Thanks. :)
type: Comment
score: 0
comment on: http://stackoverflow.com/a/2634026

collections
tags question: http://stackoverflow.com/q/2773824
tags question: http://stackoverflow.com/q/2694517
tags question: http://stackoverflow.com/q/2714353
tags question: http://stackoverflow.com/q/2746744
tags question: http://stackoverflow.com/q/2660295
tags question: http://stackoverflow.com/q/2606562
tags question: http://stackoverflow.com/q/2658356
tags question: http://stackoverflow.com/q/2781666
tags question: http://stackoverflow.com/q/2674021
tags question: http://stackoverflow.com/q/2651819
tags question: http://stackoverflow.com/q/2753860
tags question: http://stackoverflow.com/q/2625579
tags question: http://stackoverflow.com/q/2765750
tags question: http://stackoverflow.com/q/2699029
tags question: http://stackoverflow.com/q/2738230
tags question: http://stackoverflow.com/q/2701630
tags question: http://stackoverflow.com/q/2698217
tags question: http://stackoverflow.com/q/2599703
tags question: http://stackoverflow.com/q/2772836
tags question: http://stackoverflow.com/q/2704597
tags question: http://stackoverflow.com/q/2622591
type: Tag
tags question: http://stackoverflow.com/q/2745899
tags question: http://stackoverflow.com/q/2773864
tags question: http://stackoverflow.com/q/2786132
tags question: http://stackoverflow.com/q/2766855
tags question: http://stackoverflow.com/q/2722343
tags question: http://stackoverflow.com/q/2781100
tag name: collections
tags question: http://stackoverflow.com/q/2700775
tags question: http://stackoverflow.com/q/2681816
tags question: http://stackoverflow.com/q/2707605
tags question: http://stackoverflow.com/q/2754756
tags question: http://stackoverflow.com/q/2778592
tags question: http://stackoverflow.com/q/2774891
tags question: http://stackoverflow.com/q/2767134
tags question: http://stackoverflow.com/q/2774142
tags question: http://stackoverflow.com/q/2681415

http://stackoverflow.com/comment/2642865
type: Comment
score: 2
has text: @downvoter - let me fix what you think is wrong with this answer.
type: AnswerComment
comment on: http://stackoverflow.com/a/2629695

http://stackoverflow.com/comment/2702652
comment on: http://stackoverflow.com/q/2682619
score: 0
type: QuestionComment
has text: "Broker is the module that communicates with other brokers" is something that could use a bit more clarity, as well. Is a broker one per server? One per thread?
type: Comment

http://stackoverflow.com/comment/102014916
type: Comment
has text: It seems that you are passing an `File` as second argument whereas the functions expects a `Path`. You could `File.toPath()` to obtain the `Path`.
type: AnswerComment
comment on: http://stackoverflow.com/a/15006249
score: 0

http://stackoverflow.com/a/2716239
answers question: http://stackoverflow.com/q/2716178
type: Answer
has body: Your filter is accepting too many nodes. For your sample input, you want to create a NodeList that has only a single node--for the tag. The other two nodes are children of that first node so should not be added to the NodeList. If you add the following code, you may see better what the problem is. for (Node node : theList.toNodeArray()) { System.out.println(node.toHtml()); } It should print Welcome, User Welcome, User
score: 0

http://stackoverflow.com/a/2648471
has body: Does this work: List&lt;MyClass&gt; newData = new ArrayList&lt;MyClass&gt;(data); setData(newData); ? Or even a one-liner: setData(new ArrayList&lt;MyClass&gt;(data));
upvote count: 1
answers question: http://stackoverflow.com/q/2648438
type: Answer
downvote count: 0
score: 1

http://stackoverflow.com/comment/2614981
type: AnswerComment
type: Comment
has text: Loading an entire JavaScript interpreter to do some math seems like a huge waste. But you're right, it works, especially if efficiency isn't a priority.
score: 34
comment on: http://stackoverflow.com/a/2605051

http://stackoverflow.com/comment/2861132
type: AnswerComment
type: Comment
has text: the client and server are in one project and referencing it in the migration project brings problems as the GAE JPA provider from DataNucleus starts interfering with the EclipseLink one (used in the migration project).
comment on: http://stackoverflow.com/a/2811720
score: 0

http://stackoverflow.com/comment/2679235
score: 6
type: Comment
has text: I would be careful with learning by reading other's code. You might not know whether the *other* is doing it correctly.
comment on: http://stackoverflow.com/a/2661886
type: AnswerComment

http://stackoverflow.com/comment/83413974
type: Comment
has text: The problem with interfaces and constants the way you describe, you can add a constant to an interface, but there is no binding that enforces the consumer of your API to actually use that constant.
score: 2
comment on: http://stackoverflow.com/a/41447549
type: AnswerComment

http://stackoverflow.com/a/2665612
type: Answer
has body: You could absolutely change the interface as you've suggested, but what is the point? What advantage does it bring to provide an instance of MyInterface rather than Runnable? One advantage of Runnable is that it would make it easier to make the code multi-threaded in the future, because most of the APIs that execute threads (e.g. Executor) work with instances of Runnable.
downvote count: 0
answers question: http://stackoverflow.com/q/2665556
score: 5
has comment: http://stackoverflow.com/comment/6282962
upvote count: 5
has comment: http://stackoverflow.com/comment/6282958

http://stackoverflow.com/a/2688129
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2687926
score: 4
upvote count: 4
has body: Use the g2d.transform() to shift the image back where it's needed. I'm just imagining what the calculation might be but I think something like: int diff = ( image.getWidth() - image.getHeight() ) / 2; g2.transform( -diff, diff ); BTW, you may have a problem with the label reporting its preferred size - you might need to override getPreferredSize() and account for swapping the images width and height if rotated.

http://stackoverflow.com/q/2735237
score: 1
tagged with: java
type: Question
tagged with: google-cloud-datastore
answer count: 1
downvote count: 0
accepted answer: http://stackoverflow.com/a/2744615
has body: I have following code running perfectly. It filter records based on single parameter. public List&lt;Orders&gt; GetOrders(String email) { PersistenceManager pm = PMF.get().getPersistenceManager(); Query query = pm.newQuery(Orders.class); query.setFilter("Email == pEmail"); query.setOrdering("Id desc"); query.declareParameters("String pEmail"); query.setRange(0,50); return (List&lt;Orders&gt;) query.execute(email); } Now i want to filter on multiple parameters. sdate and edate is Start Date and End Date. In datastore it is saved as Date (not String). public List&lt;Orders&gt; GetOrders(String email,String icode,String sdate, String edate) { PersistenceManager pm = PMF.get().getPersistenceManager(); Query query = pm.newQuery(Orders.class); query.setFilter("Email == pEmail"); query.setFilter("ItemCode == pItemCode"); query.declareParameters("String pEmail"); query.declareParameters("String pItemCode"); .....//Set filter and declare other 2 parameters .....// ...... query.setRange(0,50); query.setOrdering("Id desc"); return (List&lt;Orders&gt;) query.execute(email,icode,sdate,edate); } Any clue? My first problem is solved. But still have some problem 1: How I can filter by Date parameter (Getting as string in jsp) ? 2: The query.execute() method support upto 3 parameters. Is it possible to pass more?
favorite count: 0
tagged with: google-app-engine
upvote count: 1
has answer: http://stackoverflow.com/a/2744615
type: AnsweredQuestion
has title: Filtering records in app-engine (Java)

http://stackoverflow.com/a/2741681
score: 43
answers question: http://stackoverflow.com/q/2740725
type: Answer
has comment: http://stackoverflow.com/comment/64817176
has body: The IBM JVM treats the rightmost instance of an argument as the winner. I can't speak to HotSpot, etc.. We do this as there are often deeply nested command lines from batch files where people can only add to the end, and want to make that the winner.
has comment: http://stackoverflow.com/comment/36602950
upvote count: 43
downvote count: 0

http://stackoverflow.com/a/38109559
answers question: http://stackoverflow.com/q/2707793
downvote count: 0
score: 2
upvote count: 2
has body: On FreeBSD systems the location is ${LOCALBASE}/share/java -- and subdirectories thereof. Not that all software-ports respect it, but they should. LOCALBASE is usually /usr/local -- unless overwritten by the system administrator.
type: Answer

http://stackoverflow.com/a/18012577
upvote count: 0
type: Answer
downvote count: 1
has body: Using "ISO-8859-1" helped me deal with the French charactes.
score: -1
answers question: http://stackoverflow.com/q/2766780

http://stackoverflow.com/a/44830208
downvote count: 1
type: Answer
has body: All well and good when you have total control over all of the code in question and can implement this upfront. Now imagine you have an existing public class used in many places with a method public class MyClass{ private String name; MyClass(String name){ this.name = name; } public String getName(){ return name; } } Now you need to pass it into the off the shelf WizzBangProcessor which requires classes to implement the WBPInterface... which also has a getName() method, but instead of your concrete implementation, this interface expects the method to return the name of a type of Wizz Bang Processing. In C# it would be a trvial public class MyClass : WBPInterface{ private String name; String WBPInterface.getName(){ return "MyWizzBangProcessor"; } MyClass(String name){ this.name = name; } public String getName(){ return name; } } In Java Tough you are going to have to identify every point in the existing deployed code base where you need to convert from one interface to the other. Sure the WizzBangProcessor company should have used getWizzBangProcessName(), but they are developers too. In their context getName was fine. Actually, outside of Java, most other OO based languages support this. Java is rare in forcing all interfaces to be implemented with the same method NAME. Most other languages have a compiler that is more than happy to take an instruction to say "this method in this class which matches the signature of this method in this implemented interface is it's implementation". After all the whole point of defining interfaces is to allow the definition to be abstracted from the implementation. (Don't even get me started on having default methods in Interfaces in Java, let alone default overriding.... because sure, every component designed for a road car should be able to get slammed into a flying car and just work - hey they are both cars... I'm sure the the default functionality of say your sat nav will not be affected with default pitch and roll inputs, because…
answers question: http://stackoverflow.com/q/2598009
score: 0
upvote count: 1

http://stackoverflow.com/comment/2714594
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2692643
has text: Actually, the package name matching the folder structure is just a convention.

http://stackoverflow.com/comment/2727116
type: Comment
comment on: http://stackoverflow.com/a/2700960
has text: Why not use "of"? The same reason: just save a bit of typing. There is main idea to express (creation of collection), and this seems to be the shortest way. The actual implementation of collection doesn't matter at all here. Collection and its data is the main thing. This save of a few characters is especially important if you want pass "inline" collection as argument to some method.
type: AnswerComment
score: 0

http://stackoverflow.com/q/2632785
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2632904
tagged with: dialog
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/2632904
tagged with: ubuntu
has comment: http://stackoverflow.com/comment/2685178
has answer: http://stackoverflow.com/a/2660218
type: Question
has body: (Problem occur in Ubuntu only. Works fine in Windows. I don't know in other Linux environments) I have used the approach of the ComponentListener to call focus in JTextField within a dialog, but for this case is just not working, I don't know why. It shows the focus in the text field and fast change to the button. Run and see: import java.awt.Component; import java.awt.GridLayout; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JTextField; import javax.swing.SwingUtilities; public class User { private String username = ""; private String password = ""; public User() { // default constructor } public User(String username, String password) { this.username = username; this.password = password; } /** Create a panel containing the componet and tha label. */ public JPanel createLabeledComponent(JLabel label, Component comp) { GridLayout layout = new GridLayout(2, 1); JPanel panel = new JPanel(layout); panel.add(label); panel.add(comp); label.setLabelFor(comp); return panel; } public void showEditDialog() { JLabel usernameLbl = new JLabel(username); final JTextField usernameField = new JTextField(); usernameField.setText(username); JPanel usernamePnl = createLabeledComponent(usernameLbl, usernameField); JLabel passwordLbl = new JLabel(password); JPasswordField passwordField = new JPasswordField(password); JPanel passwordPnl = createLabeledComponent(passwordLbl, passwordField); Object[] fields = { "User:", usernamePnl, "Password:", passwordPnl }; JOptionPane optionPane = new JOptionPane(fields, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, null); JDialog dialog = optionPane.createDialog("User Data"); dialog.addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override p…
has answer: http://stackoverflow.com/a/2662882
has comment: http://stackoverflow.com/comment/2647005
has comment: http://stackoverflow.com/comment/2680543
upvote count: 1
has comment: http://stackoverflow.com/comment/2646412
has title: Problem to focus JTextField
favorite count: 0
has comment: http://stackoverflow.com/comment/2646394
tagged with: focus
answer count: 3
downvote count: 0
accepted answer: http://stackoverflow.com/a/2660218

http://stackoverflow.com/comment/2757415
type: Comment
comment on: http://stackoverflow.com/a/2727039
has text: Removed the downvote. I believe he's implementing this: http://en.wikipedia.org/wiki/Data_Encryption_Standard
score: 0
type: AnswerComment

multithreading
tags question: http://stackoverflow.com/q/2624503
tags question: http://stackoverflow.com/q/2607019
tags question: http://stackoverflow.com/q/2711817
tags question: http://stackoverflow.com/q/2779484
tags question: http://stackoverflow.com/q/2743467
type: Tag
tags question: http://stackoverflow.com/q/2756647
tags question: http://stackoverflow.com/q/2760294
tags question: http://stackoverflow.com/q/2755338
tags question: http://stackoverflow.com/q/2704198
tags question: http://stackoverflow.com/q/2745512
tags question: http://stackoverflow.com/q/2762922
tags question: http://stackoverflow.com/q/2637309
tags question: http://stackoverflow.com/q/2780255
tags question: http://stackoverflow.com/q/2726091
tags question: http://stackoverflow.com/q/2698471
tags question: http://stackoverflow.com/q/2712232
tags question: http://stackoverflow.com/q/2780761
tags question: http://stackoverflow.com/q/2778213
tags question: http://stackoverflow.com/q/2652403
tags question: http://stackoverflow.com/q/2784009
tags question: http://stackoverflow.com/q/2653458
tags question: http://stackoverflow.com/q/2663419
tags question: http://stackoverflow.com/q/2599090
tags question: http://stackoverflow.com/q/2758612
tags question: http://stackoverflow.com/q/2759406
tags question: http://stackoverflow.com/q/2756993
tags question: http://stackoverflow.com/q/2719650
tags question: http://stackoverflow.com/q/2623453
tags question: http://stackoverflow.com/q/2775550
tags question: http://stackoverflow.com/q/2641645
tags question: http://stackoverflow.com/q/2781286
tags question: http://stackoverflow.com/q/2745375
tags question: http://stackoverflow.com/q/2609036
tags question: http://stackoverflow.com/q/2719837
tags question: http://stackoverflow.com/q/2756626
tags question: http://stackoverflow.com/q/2640135
tags question: http://stackoverflow.com/q/2756481
tags question: http://stackoverflow.com/q/2667264
tags question: http://stackoverflow.com/q/2688099
tags question: http://stackoverflow.com/q/2736378
tags question: http://stackoverflow.com/q/2733356
tags question: http://stackoverflow.com/q/2722324
tags question: http://stackoverflow.com/q/2653431
tags question: http://stackoverflow.com/q/2757043
tags question: http://stackoverflow.com/q/2668389
tags question: http://stackoverflow.com/q/2674174
tags question: http://stackoverflow.com/q/2664738
tags question: http://stackoverflow.com/q/2695426
tags question: http://stackoverflow.com/q/2687238
tags question: http://stackoverflow.com/q/2755969
tags question: http://stackoverflow.com/q/2665569
tags question: http://stackoverflow.com/q/2645652
tags question: http://stackoverflow.com/q/2644611
tags question: http://stackoverflow.com/q/2677335
tags question: http://stackoverflow.com/q/2596916
tags question: http://stackoverflow.com/q/2676687
tags question: http://stackoverflow.com/q/2649375
tags question: http://stackoverflow.com/q/2691041
tags question: http://stackoverflow.com/q/2665556
tags question: http://stackoverflow.com/q/2702834
tags question: http://stackoverflow.com/q/2778476
tags question: http://stackoverflow.com/q/2644688
tags question: http://stackoverflow.com/q/2719107
tags question: http://stackoverflow.com/q/2600862
tags question: http://stackoverflow.com/q/2690207
tags question: http://stackoverflow.com/q/2664687
tags question: http://stackoverflow.com/q/2622804
tags question: http://stackoverflow.com/q/2598390
tags question: http://stackoverflow.com/q/2659996
tags question: http://stackoverflow.com/q/2653786
tags question: http://stackoverflow.com/q/2728311
tags question: http://stackoverflow.com/q/2735632
tags question: http://stackoverflow.com/q/2688629
tags question: http://stackoverflow.com/q/2779984
tags question: http://stackoverflow.com/q/2769646
tags question: http://stackoverflow.com/q/2765636
tags question: http://stackoverflow.com/q/2619230
tags question: http://stackoverflow.com/q/2689101
tags question: http://stackoverflow.com/q/2601094

http://stackoverflow.com/q/2642069
has answer: http://stackoverflow.com/a/2642267
type: AnsweredQuestion
tagged with: java
tagged with: eclipse-jdt
tagged with: eclipse
type: Question
has body: I have an Eclipse CDT environment up and running and customised just the way I like it. I'm also going to be heavily dealing with Java. I don't want to install a separate version of Eclipse just to get the Java features, as I'll be switching between C -> C++ -> ADA -> Java quite often. Because of this I'd like the one IDE to support all the languages. At the moment I've got C/C++ and Ada working together (CDT + GNAT workbench). How can I get the Eclipse Java support installed with out installing Eclipse from scratch again?
tagged with: eclipse-cdt
accepted answer: http://stackoverflow.com/a/2642267
has title: Is it possible to have CDT and Java IDE together in Eclipse?
upvote count: 20
score: 20
answer count: 1
downvote count: 0
favorite count: 0

http://stackoverflow.com/comment/33146424
has text: @WesWinn: This question is so old, I had forgotten that the emulator ever looked like it did in the screenshot... :-) Glad to hear it helped, though!
score: 1
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2630124

http://stackoverflow.com/q/2616397
tagged with: java
downvote count: 2
has answer: http://stackoverflow.com/a/4029168
has comment: http://stackoverflow.com/comment/3977969
has title: Best "General Purpose" Maven plugins
has comment: http://stackoverflow.com/comment/2628731
has answer: http://stackoverflow.com/a/2616850
score: 39
has comment: http://stackoverflow.com/comment/2628256
answer count: 12
has answer: http://stackoverflow.com/a/2620371
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/3682794
has comment: http://stackoverflow.com/comment/2628609
has comment: http://stackoverflow.com/comment/24317532
has answer: http://stackoverflow.com/a/2617036
has answer: http://stackoverflow.com/a/2616937
has body: We are just moving to Maven, and I understand there is a world of different plugins &amp; extensions. Which are the best ones you recommend for general usage? (On plugin per answer please)
tagged with: maven-2
has answer: http://stackoverflow.com/a/2616690
has comment: http://stackoverflow.com/comment/68071163
favorite count: 0
has answer: http://stackoverflow.com/a/2618146
has answer: http://stackoverflow.com/a/2616864
type: Question
upvote count: 41
has answer: http://stackoverflow.com/a/2616871
tagged with: plugins
has answer: http://stackoverflow.com/a/2859987
has answer: http://stackoverflow.com/a/2616531

http://stackoverflow.com/comment/2747905
type: AnswerComment
has text: Hi thanks for your help :) Could the session be closed by the Transaction manager, but the SessionImpl instance still be held by a Spring bean? Spring configures my persistance bean with an EntityManager, and the bean is not destroyed correctly, so the EntityManager stays in memory, and the session instance as well...
type: Comment
comment on: http://stackoverflow.com/a/2721728
score: 0

http://stackoverflow.com/a/2718035
has comment: http://stackoverflow.com/comment/2744321
has comment: http://stackoverflow.com/comment/2749396
has body: The last-modified timestamp is apparently stored in seconds, not in milliseconds. That might be a file system limitation. I'd suggest to compare it against seconds rather than milliseconds.
answers question: http://stackoverflow.com/q/2717936
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/2743877
upvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/2744328

http://stackoverflow.com/q/2605385
has answer: http://stackoverflow.com/a/33611590
tagged with: jdbc
upvote count: 23
type: AnsweredQuestion
tagged with: java
tagged with: hibernate
score: 23
possible better answer: http://stackoverflow.com/a/2605861
has answer: http://stackoverflow.com/a/2605861
type: Question
has answer: http://stackoverflow.com/a/2606036
has body: I have a couple of sql views with composite primary keys that I want to query, and since Hibernate makes it a pain to work with composite keyes, I'm using createSQLQuery. The problem is that this method can only return a List, and I need to refer to the colums by their index. Any chance I could do something like jdbc and refer to the columns by their sql name instead of their index?
answer count: 3
has title: Using sql column names in hibernate createSQlquery result
tagged with: sql
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/2606036

http://stackoverflow.com/comment/2790229
has text: @Trevor Tippins Why did you delete your answer? It's fully legitimate.
type: Comment
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/2758468

http://stackoverflow.com/comment/2751046
type: Comment
has text: Thanks for advice aioobe. I had a look at OneJar but couldn't quite get my head around wrapping the Main in a jar itself. I took the easy root in the end and extracted the JAR then put them in a lib folder and added that. Works now. Think I'll spend some more time on a few tutorials.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2721102

http://stackoverflow.com/q/2746488
score: 2
type: AnsweredQuestion
has body: I created a stored procedure in a sql express 2008 and I'm getting the following error when calling the procedure from a Java method: Index 36 is out of range. com.microsoft.sqlserver.jdbc.SQLServerException:Index 36 is out of range. at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:170) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setterGetParam(SQLServerPreparedStatement.java:698) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setValue(SQLServerPreparedStatement.java:707) at com.microsoft.sqlserver.jdbc.SQLServerCallableStatement.setString(SQLServerCallableStatement.java:1504) at fr.alti.ccm.middleware.Reporting.initReporting(Reporting.java:227) at fr.alti.ccm.middleware.Reporting.main(Reporting.java:396) I cannot figure out where it is coming from... >_&lt; Any help would be appreciated. Regards, BS_C3 Here's some source code: public ArrayList&lt;ReportingTableMapping&gt; initReporting( String division, String shop, String startDate, String endDate) { ArrayList&lt;ReportingTableMapping&gt; rTable = new ArrayList&lt;ReportingTableMapping&gt;(); ManagerDB db = new ManagerDB(); CallableStatement callStmt = null; ResultSet rs = null; try { callStmt = db.getConnexion().prepareCall("{call getInfoReporting(?,...,?)}"); callStmt.setString("CODE_DIVISION", division); . . . callStmt.setString("cancelled", " "); rs = callStmt.executeQuery(); while (rs.next()) { ReportingTableMapping rtm = new ReportingTableMapping( rs.getString("werks"), ... ); rTable.add(rtm); } rs.close(); callStmt.close(); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } finally { if (rs != null) try { rs.close(); } catch (Exception e) { } if (callStmt != null) try { callStmt.close(); } catch (Exception e) { } if (db.getConnexion() != null) try { db.getConnexion().close(); } catch (Exception e) { } } return rTable; }
has answer: http://stackoverflow.com/a/2761496
tagged with: java
tagged with: sql-server-express
has title: Java w/ SQL Server Express 2008 - Index out of range exception
type: Question
upvote count: 2
has comment: http://stackoverflow.com/comment/2775884
downvote count: 0
has answer: http://stackoverflow.com/a/2747945
tagged with: sql-server-2008
tagged with: exception
answer count: 3
favorite count: 0
has answer: http://stackoverflow.com/a/2746972
accepted answer: http://stackoverflow.com/a/2746972
possible better answer: http://stackoverflow.com/a/2747945

http://stackoverflow.com/q/2774252
tagged with: multithreading
has answer: http://stackoverflow.com/a/2778878
has comment: http://stackoverflow.com/comment/2813358
has comment: http://stackoverflow.com/comment/2808240
has comment: http://stackoverflow.com/comment/2808046
has comment: http://stackoverflow.com/comment/2809629
possible better answer: http://stackoverflow.com/a/2778878
tagged with: java
has answer: http://stackoverflow.com/a/2776406
has title: Best way to reuse a Runnable
has comment: http://stackoverflow.com/comment/2808322
has answer: http://stackoverflow.com/a/2774338
tagged with: concurrency
upvote count: 4
answer count: 4
accepted answer: http://stackoverflow.com/a/2776406
type: AnsweredQuestion
has body: I have a class that implements Runnable and am currently using an Executor as my thread pool to run tasks (indexing documents into Lucene). executor.execute(new LuceneDocIndexer(doc, writer)); My issue is that my Runnable class creates many Lucene Field objects and I would rather reuse them then create new ones every call. What's the best way to reuse these objects (Field objects are not thread safe so I cannot simple make them static) - should I create my own ThreadFactory? I notice that after a while the program starts to degrade drastically and the only thing I can think of is it's GC overhead. I am currently trying to profile the project to be sure this is even an issue - but for now lets just assume it is.
downvote count: 0
has comment: http://stackoverflow.com/comment/2808097
tagged with: lucene
type: Question
has answer: http://stackoverflow.com/a/2774704
favorite count: 0
score: 4
has comment: http://stackoverflow.com/comment/2808227

http://stackoverflow.com/a/2684636
type: Answer
score: 0
has comment: http://stackoverflow.com/comment/2704763
answers question: http://stackoverflow.com/q/2684513
has body: As long as your programm isn't sharing an application server with others, shuting down the VM by calling System.exit(0) terminates all threads. From Javadoc System.exit Terminates the currently running Java Virtual Machine) EDIT: If you want to do some clean up code before shutdown, http://java.sun.com/j2se/1.4.2/docs/guide/lang/hook-design.html
has comment: http://stackoverflow.com/comment/2704603

http://stackoverflow.com/comment/2793120
comment on: http://stackoverflow.com/q/2761168
type: QuestionComment
type: Comment
has text: I suggest start with http://en.wikipedia.org/wiki/Terracotta_Cluster, and then coming back with a more specific question.
score: 1

http://stackoverflow.com/comment/2732224
comment on: http://stackoverflow.com/q/2708229
score: 1
has text: By the way, if you are using Apache Commons, you can `IOUtils.closeQuietly(in)`. This utility function checks for `null` and suppresses `IOException` as you are probably not interested in exceptions on closing anyway.
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/2692931
score: 0
type: Comment
has text: Note that Vector is an obsolete data strcture that should be be used anymore.
type: QuestionComment
comment on: http://stackoverflow.com/q/2669248

http://stackoverflow.com/comment/31306225
score: 0
type: AnswerComment
has text: @foo Of course, but it has nothing to do with Java being an OO language. It manifests encapsulation, inheritance, and polymorphism: that's sufficient, by the only formal definition I'm aware of (Wegner 1987).
comment on: http://stackoverflow.com/a/2606673
type: Comment

http://stackoverflow.com/comment/2608563
type: QuestionComment
has text: I guess scala could also do it. But I code for my company, not myself.
comment on: http://stackoverflow.com/q/2599698
score: 0
type: Comment

http://stackoverflow.com/a/2668554
type: Answer
answers question: http://stackoverflow.com/q/2656725
has body: I had the similar need. Ended up testing a whole bunch of scheduling services. Check out cronservice.co.uk/new/, setcronjob.com or mywebcron.com. I ended up using the scheduler.codeeffects.com because of their set of features and the interface. Google for others, there are tons services like this. Most are free or give free stuff. Sorry for the late reply, but I thought this might help.
score: 0

http://stackoverflow.com/comment/26130420
comment on: http://stackoverflow.com/a/17734143
has text: @supercat: you are right - but this is file reading. Writing must flush the decorator (and not rely on close) - _if there is a decorator_. I go through some peculiarities [here](http://stackoverflow.com/questions/16363642/java-6-io-wrapped-streams-closing) - unjustly closed
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/2755957
downvote count: 0
answers question: http://stackoverflow.com/q/2755945
score: 4
has body: Have you tried escaping the dot? like this: String[] words = line.split("\\.");
type: Answer
upvote count: 4

http://stackoverflow.com/comment/2817759
type: Comment
has text: the enum parent class is initialized before the subclasses are instantiated. therefore, the values array is usually invalid within a static block within the main enum class. if this static block is in another class, then there is no problem.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2780170

http://stackoverflow.com/comment/2713255
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/2691927
type: Comment
has text: See also http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.20.2

http://stackoverflow.com/comment/2805852
has text: Fine, so `memmove` then. Although I don't think it makes much difference in context of this question.
score: 5
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2772214

http://stackoverflow.com/comment/133832912
type: Comment
has text: In JDK 14 onwards, you can use records to implement tuples. For example, `public record Pair<X, Y>(X x, Y y) {}`. You get tuple semantics for equality checks and hash code calculations out of the box.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2671052

http://stackoverflow.com/a/24370091
has comment: http://stackoverflow.com/comment/70900630
upvote count: 129
has body: All of the other answers were either deprecated or didn't work for HttpClient 4.3. Here is a way to allow all hostnames when building an http client. CloseableHttpClient httpClient = HttpClients .custom() .setHostnameVerifier(new AllowAllHostnameVerifier()) .build(); Or if you are using version 4.4 or later, the updated call looks like this: CloseableHttpClient httpClient = HttpClients .custom() .setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE) .build();
answers question: http://stackoverflow.com/q/2703161
score: 126
type: Answer
has comment: http://stackoverflow.com/comment/78864189
downvote count: 3
has comment: http://stackoverflow.com/comment/42436757
has comment: http://stackoverflow.com/comment/42486240
has comment: http://stackoverflow.com/comment/78887117

http://stackoverflow.com/comment/2616439
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/2600392
has text: It is not free but you have a 90 days license in the latest SR2 build. Plenty of time to finish your project. No nagscreen, no tag in the code, the uml model is standard and could therefore be open by any tool. Only the graphical editor is under the 90 days evaluation. So not so bad :-)
score: 0

http://stackoverflow.com/q/2650245
accepted answer: http://stackoverflow.com/a/2650275
tagged with: cellular-automata
favorite count: 0
has title: simple Sand Pile code in JAVA
has answer: http://stackoverflow.com/a/2650275
possible better answer: http://stackoverflow.com/a/60153054
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/60153054
downvote count: 0
score: 1
tagged with: java
has body: does anyone know where I could find the source code for the SandPile (cellular Automata)? thanks in advance!
type: Question
answer count: 2
upvote count: 1

http://stackoverflow.com/q/2654752
accepted answer: http://stackoverflow.com/a/2654762
tagged with: limits
favorite count: 0
upvote count: 12
tagged with: c++
has body: How can I get an equivalent of java.lang.Integer.MIN_VALUE on C++?
has title: C++ equivalent of java.lang.Integer.MIN_VALUE
type: AnsweredQuestion
tagged with: java
possible better answer: http://stackoverflow.com/a/2656599
type: Question
score: 12
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/2656599
has answer: http://stackoverflow.com/a/2654762

http://stackoverflow.com/comment/98926140
has text: oh great ... headless service needed a memory boost.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2987082

jtextarea
tags question: http://stackoverflow.com/q/2760690
type: Tag
tags question: http://stackoverflow.com/q/2601074
tags question: http://stackoverflow.com/q/2755156
tags question: http://stackoverflow.com/q/2736665
tags question: http://stackoverflow.com/q/2710712
tags question: http://stackoverflow.com/q/2702513
tags question: http://stackoverflow.com/q/2713863
tag name: jtextarea
tags question: http://stackoverflow.com/q/2616251
tags question: http://stackoverflow.com/q/2646982
tags question: http://stackoverflow.com/q/2687023

http://stackoverflow.com/q/2754452
downvote count: 0
has comment: http://stackoverflow.com/comment/2793673
has comment: http://stackoverflow.com/comment/2793558
has comment: http://stackoverflow.com/comment/2793513
answer count: 1
has comment: http://stackoverflow.com/comment/2796577
favorite count: 0
has comment: http://stackoverflow.com/comment/2793631
has body: im new to hibernate! i have followed the netbeans tutorial on creating a hibernate enabled application. after sucessfully creating a database in mysql workbench i reversed engineered the pojos etc and then tried to run a simple query(from Course) and got the following org.hibernate.MappingException: An association from the table coursemodule refers to an unmapped class: DAL.Module at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1252) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1170) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:324) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286) at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859) heres the generated class for Course package DAL; // Generated 02-May-2010 16:41:16 by Hibernate Tools 3.2.1.GA import java.util.HashSet; import java.util.Set; /** * Course generated by hbm2java */ public class Course implements java.io.Serializable { private int id; private String name; private Set<Module> modules = new HashSet<Module>(0); public Course() { } public Course(int id, String name) { this.id = id; this.name = name; } public Course(int id, String name, Set<Module> modules) { this.id = id; this.name = name; this.modules = modules; } public int getId() { return this.id; } public void setId(int id) { this.id = id; } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public Set<Module> getModules() { return this.modules; } public void setModules(Set<Module> modules) { this.modules = modules; } } and its config file course.hbm.xml <?xml version="1.0"?> <column name="id" /> <generator class="assigned" /> <column name="name" not-null="true" /> <column name="courseId" not-null="true" unique="true" /> <column name="moduleId" not-null="true" unique="true" /> hibernate.reveng.xml <?xml version="1.0" encod…
tagged with: netbeans
accepted answer: http://stackoverflow.com/a/2754617
has title: Hibernate exception
upvote count: 1
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2800469
score: 1
tagged with: java
tagged with: hibernate
has comment: http://stackoverflow.com/comment/2785737
tagged with: orm
tagged with: mysql
type: Question
has comment: http://stackoverflow.com/comment/2796626
has answer: http://stackoverflow.com/a/2754617

http://stackoverflow.com/q/2613596
has answer: http://stackoverflow.com/a/2613743
has answer: http://stackoverflow.com/a/2613663
has answer: http://stackoverflow.com/a/21979224
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2624740
tagged with: constructor
has comment: http://stackoverflow.com/comment/2625053
possible better answer: http://stackoverflow.com/a/2613731
has answer: http://stackoverflow.com/a/2613744
has answer: http://stackoverflow.com/a/2613604
has body: I know abstract fields do not exist in java. I also read this question but the solutions proposed won't solve my problem. Maybe there is no solution, but it's worth asking :) Problem I have an abstract class that does an operation in the constructor depending on the value of one of its fields. The problem is that the value of this field will change depending on the subclass. How can I do so that the operation is done on the value of the field redefined by the subclass ? If I just "override" the field in the subclass the operation is done on the value of the field in the abstract class. I'm open to any solution that would ensure that the operation will be done during the instantiation of the subclass (ie putting the operation in a method called by each subclass in the constructor is not a valid solution, because someone might extend the abstract class and forget to call the method). Also, I don't want to give the value of the field as an argument of the constructor. Is there any solution to do that, or should I just change my design ? Edit: My subclasses are actually some tools used by my main program, so the constructor has to be public and take exactly the arguments with which they will be called: tools[0]=new Hand(this); tools[1]=new Pencil(this); tools[2]=new AddObject(this); (the subclasses are Hand, Pencil and AddObject that all extend the abstract class Tool) That's why I don't want to change the constructor. The solution I'm about to use is to slightly change the above code to: tools[0]=new Hand(this); tools[0].init(); tools[1]=new Pencil(this); tools[1].init(); tools[2]=new AddObject(this); tools[2].init(); and use an abstract getter to acces the field.
has answer: http://stackoverflow.com/a/2613731
has comment: http://stackoverflow.com/comment/2624631
has answer: http://stackoverflow.com/a/2613772
type: Question
answer count: 8
has title: How to create an "abstract field"?
tagged with: java
score: 12
accepted answer: http://stackoverflow.com/a/2613604
upvote count: 12
linked to: http://stackoverflow.com/q/2211002
downvote count: 0
has comment: http://stackoverflow.com/comment/2625838
has answer: http://stackoverflow.com/a/2613600
favorite count: 0
tagged with: abstract-class

http://stackoverflow.com/comment/15364793
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/6378872
has text: I only need to add .PFX Certificate File KeyStore using Android 2.3.3, Which piece of code from above solution will help me? Kindly help me i am working on this from 2 weeks and unable to understand anything.
score: 0

http://stackoverflow.com/comment/99010540
score: 0
has text: this was / is the case under crippled commercial so called operating systems. my bad
comment on: http://stackoverflow.com/q/2704417
type: QuestionComment
type: Comment

http://stackoverflow.com/q/2772701
tagged with: web-applications
has answer: http://stackoverflow.com/a/21428847
tagged with: ip-address
has answer: http://stackoverflow.com/a/10548532
has answer: http://stackoverflow.com/a/17113983
type: AnsweredQuestion
has body: Some times whenever I restart the application, which is built on Java, Struts, Mysql, and Jboss 4.05 Version I get the error as Address already in use: JVM_Bind Only fix that I know is to restart the machine and try again, it will work. Else Some times I do Ctrl-Alt-Del and Stop all the process related to Java, some times this also works. But what is the exact reason and how can we prevent this problem?
has answer: http://stackoverflow.com/a/72040254
tagged with: java
has answer: http://stackoverflow.com/a/68395026
has answer: http://stackoverflow.com/a/77757406
tagged with: jboss
has answer: http://stackoverflow.com/a/51537495
has answer: http://stackoverflow.com/a/2772860
type: Question
has answer: http://stackoverflow.com/a/70640950
accepted answer: http://stackoverflow.com/a/2772758
score: 64
has answer: http://stackoverflow.com/a/2774442
has answer: http://stackoverflow.com/a/67191339
has answer: http://stackoverflow.com/a/44290225
has title: Address already in use: JVM_Bind java
has answer: http://stackoverflow.com/a/49860984
tagged with: struts
has answer: http://stackoverflow.com/a/2772721
has comment: http://stackoverflow.com/comment/37701114
has answer: http://stackoverflow.com/a/36743262
upvote count: 64
has answer: http://stackoverflow.com/a/2773212
downvote count: 0
answer count: 18
favorite count: 0
possible better answer: http://stackoverflow.com/a/28619132
has answer: http://stackoverflow.com/a/2772758
has answer: http://stackoverflow.com/a/28619132

http://stackoverflow.com/a/3388222
has body: I have done some more testing ( reliable testing :-) ), trying to write 100,000 short-named directories in a single directory. The limit was reached at 65,536. The test was done on Nexus One running Android 2.2, but I believe the result holds for any FAT32 SD card.
has comment: http://stackoverflow.com/comment/3527467
upvote count: 6
type: Answer
downvote count: 0
answers question: http://stackoverflow.com/q/2651907
score: 6

http://stackoverflow.com/a/2789275
has body: I suggest you also to consider Wink We are using this framework. It's got a good unit tests package, great examples, and it's easy to deploy.
score: 0
answers question: http://stackoverflow.com/q/2688145
type: Answer

http://stackoverflow.com/q/2783758
has answer: http://stackoverflow.com/a/22692069
answer count: 5
possible better answer: http://stackoverflow.com/a/13508779
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/47200725
tagged with: java
has answer: http://stackoverflow.com/a/13508779
has comment: http://stackoverflow.com/comment/137217561
accepted answer: http://stackoverflow.com/a/2783885
type: Question
has body: How do I use XMLStreamWriter to write exactly what I put in? For instance, if I create script tag and fill it with javascript I don't want all my single quotes coming out as &amp;apos; Here's a small test I wrote that doesn't use any of the abstractions I've got in place, just calls to writeCharacters. public void testWriteCharacters() { StringWriter sw = new StringWriter(); XMLOutputFactory factory = XMLOutputFactory.newInstance(); StringBuffer out = new StringBuffer(); try { XMLStreamWriter writer = factory.createXMLStreamWriter(sw); writer.writeStartElement("script"); writer.writeAttribute("type","text/javascript"); writer.writeCharacters("function hw(){ \n"+ "\t alert('hello world');\n" + "}\n"); writer.writeEndElement(); out.append(sw); } catch (XMLStreamException e) { } finally { try { sw.close(); } catch(IOException e) { e.printStackTrace(); } } System.out.println(out.toString()); } This produces an apos entity for both the single quotes surrounding hello world.
score: 5
has title: XMLStreamWriter writeCharacters without escaping
upvote count: 5
has comment: http://stackoverflow.com/comment/64269978
has answer: http://stackoverflow.com/a/2783885
has answer: http://stackoverflow.com/a/38374931
downvote count: 0
tagged with: http://stackoverflow.com/tag/xml
favorite count: 0
linked to: http://stackoverflow.com/q/19998460

http://stackoverflow.com/comment/2791398
has text: Okay. So I have a set of instances of a given subclass, and I need to maintain a list of all those instances for searching, building drop-downs, etc. Okay, I could create a (non-static) object that holds the list. But it only makes sense for there to be one list. So what's the advantage of that? If I create two objects with different lists, something is badly wrong. How would you solve the problem without a singleton?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2758474

http://stackoverflow.com/comment/2616615
comment on: http://stackoverflow.com/a/2600683
type: AnswerComment
score: 0
type: Comment
has text: "`O(UlogU)` is about as good as `O(U)`" : not to a computer scientist/algorithmist. Also, one is clearly more "efficient" (OP's word) than the other.

http://stackoverflow.com/comment/2689342
has text: I don't know groovy so can't answer your question directly, but why not refactor your code to get rid of your anonymous code blocks? Sounds like a better choice to me.
type: Comment
type: QuestionComment
score: 2
comment on: http://stackoverflow.com/q/2670785

http://stackoverflow.com/q/2606873
has answer: http://stackoverflow.com/a/3201739
downvote count: 0
has comment: http://stackoverflow.com/comment/5688072
tagged with: ssl
has answer: http://stackoverflow.com/a/2631894
possible better answer: http://stackoverflow.com/a/2873561
has body: I'm trying to connect to a webservice over SSL using Apache Commons HttpClient 3.1, using this: String url = "https://archprod.service.eogs.dk/cvronline/esb/LegalUnitGetSSLServicePort"; HttpClient client = new HttpClient(); PostMethod post = new PostMethod(url); StringRequestEntity entity = new StringRequestEntity(requestXml, "application/soap+xml", "utf-8"); post.setRequestEntity(entity); client.executeMethod(post); String response = post.getResponseBodyAsString(); And I get this exception: javax.net.ssl.SSLException: HelloRequest followed by an unexpected handshake message at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:190) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1623) at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:198) at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:188) at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverHelloRequest(ClientHandshaker.java:286) at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:114) at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:525) at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:465) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:884) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:746) at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:75) at java.io.BufferedInputStream.fill(BufferedInputStream.java:218) at java.io.BufferedInputStream.read(BufferedInputStream.java:237) at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:78) at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:106) at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1116) at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1973) at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735) a…
has answer: http://stackoverflow.com/a/2873561
favorite count: 0
has comment: http://stackoverflow.com/comment/5688073
has answer: http://stackoverflow.com/a/10537945
accepted answer: http://stackoverflow.com/a/2631894
score: 11
has title: SSLException: HelloRequest followed by an unexpected handshake message
answer count: 4
upvote count: 11
type: AnsweredQuestion
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/5688059

sql-server
tags question: http://stackoverflow.com/q/2709038
tags question: http://stackoverflow.com/q/2718676
type: Tag
tag name: sql-server
tags question: http://stackoverflow.com/q/2766039
tags question: http://stackoverflow.com/q/2630466
tags question: http://stackoverflow.com/q/2774816

http://stackoverflow.com/comment/2723414
type: AnswerComment
has text: @BalusC - I have run into a new problem, when I try to edit the user entity in my userEdit page, even though it is displaying properly, I get an error that the entity is null. I am using value binding if it makes a difference. Do you have any reason why this would be?
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2699600

http://stackoverflow.com/q/2773595
tagged with: jpa
answer count: 2
score: 2
has body: I want the first to be generated: @Id @Column(name = "PRODUCT_ID", unique = true, nullable = false, precision = 12, scale = 0) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PROD_GEN") @BusinessKey public Long getAId() { return this.aId; } I want the bId to be initially exactly as the aId. One approach is to insert the entity, then get the aId generated by the DB (2nd query) and then update the entity, setting the bId to be equal to aId (3rd query). Is there a way to get the bId to get the same generated value as aId? Note that afterwards, I want to be able to update bId from my gui. If the solution is JPA, even better.
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2777883
has answer: http://stackoverflow.com/a/2773637
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2777883
upvote count: 2
tagged with: java
tagged with: hibernate
tagged with: orm
possible better answer: http://stackoverflow.com/a/2773637
type: Question
has title: Hibernate: same generated value in two properties

http://stackoverflow.com/q/2735458
favorite count: 0
tagged with: compiler-construction
has answer: http://stackoverflow.com/a/2751278
tagged with: parsing
type: AnsweredQuestion
upvote count: 1
type: Question
score: 1
tagged with: java
accepted answer: http://stackoverflow.com/a/2751278
has body: I am using an Compiler called Polyglot which is a highly extendable compiler for Java. I seem to have run into this Exception while trying to compile some test code: "Invalid action number found in internal parse table." How can I make a valid action number for the parse table? EDIT: I solved the problem by just fixing my grammar a bit... I had an issue with calling methods without types. (It is late I'm sorry) Now I am more curious to when the Exception above is thrown? And what is an action number?
answer count: 1
downvote count: 0
has title: Exception: "Invalid action number found in internal parse table." Polyglot Exception
tagged with: polyglot

http://stackoverflow.com/q/2619644
has comment: http://stackoverflow.com/comment/2633020
has comment: http://stackoverflow.com/comment/2650913
has comment: http://stackoverflow.com/comment/2631859
answer count: 0
downvote count: 0
has title: Calculation with RESTful web service with MySQL database
tagged with: rest
type: Question
score: 1
favorite count: 0
tagged with: netbeans
has comment: http://stackoverflow.com/comment/2632390
upvote count: 1
has comment: http://stackoverflow.com/comment/2631906
has body: I am now making some RESTful web services with MySQL database. I used NetBeans to create the resources of RESTful service with MySQL, and now I can now use GET and POST/PUT to list and add/modify data entities in the MySQL server. Currently, I wish to make some calculations right after a client makes the POST activities, then the posted data with calculated results will be inserted into the MySQL database. I am very new to this, I guess I need to add some functions and call them to calculate but I don't know where and how to do that : ( Could any one help me on this issue? Thanks a lot in advance! : )
tagged with: java
tagged with: mysql
type: UnansweredQuestion

http://stackoverflow.com/a/2671856
has comment: http://stackoverflow.com/comment/2743770
type: Answer
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/2735192
has comment: http://stackoverflow.com/comment/2735210
accepted answer of: http://stackoverflow.com/q/2664807
upvote count: 2
has comment: http://stackoverflow.com/comment/2690742
answers question: http://stackoverflow.com/q/2664807
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2690819
has body: There are 2 ways. Either have a Map class which is the main JPanel, to maintain the collection of units, but keep the Unit class as non-Swing. When the Map's paint() method is called, ask each Unit to redraw itself by calling a method in each visible Unit. The Unit could be inherited from any base class, for example Rectangle, or some other data structure you use in the program. In this case, the Unit class handles painting and calculations, but the Map handles the clicks and events for each Unit. It could pass the message on to the Unit if needed; however, if the unit itself doesn't need to know about these things, this method works well. The Unit class is light and economical. You can also decide whether the Unit knows its position in the Map or not. Or have each unit as a JComponent, and handle its own events separately. The disadvantage is that each instance of a Unit creates a pile of data for drawing it as well. So if you have hundreds of units, only a couple of which are drawn, this way is not efficient. The advantage is each unit can handle its own GUI events without translation etc. This assumes also a 1:1 mapping of actual units in the game and graphical units on the screen. Also it is trickier to implement certain event handlers in the Unit, if a Unit needs to know about what other Units are around! A third and arguably better way is to have a purely data Unit class, containing the game information about the unit, as in (1), but which has a method to create the JComponent when needed. The JComponent could, for example, be an inner class in the Unit - it could then access the Unit data. This is great if a unit may need to be displayed in 2 places (e.g. on 2 screens or views). -- Addendum to address comments That is correct, in (1) the Map (main JPanel) implements the mouse handler, and asks each unit in turn if it is 'hit'. This allows you to do more complex things, such as have 2 units overlapping/on top of each other, and both could respond to the click.…

http://stackoverflow.com/q/2657515
tagged with: url-encoding
score: 7
tagged with: character-encoding
answer count: 2
downvote count: 0
has title: Detect the URI encoding automatically in Tomcat
tagged with: tomcat
has answer: http://stackoverflow.com/a/2657902
favorite count: 0
tagged with: servlet-filters
possible better answer: http://stackoverflow.com/a/21172934
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/21172934
has body: I have an instance of Apache Tomcat 6.x running, and I want it to interpret the character set of incoming URLs a little more intelligent than the default behavior. In particular, I want to achieve the following mapping: So%DFe =&gt; Soße So%C3%9Fe =&gt; Soße So%DF%C3%9F =&gt; (error) The bevavior I want could be described as "try to decode the byte stream as UTF-8, and if it doesn't work assume ISO-8859-1". Simply using the URIEncoding configuration doesn't work in that case. So how can I configure Tomcat to encode the request the way I want? I might have to write a Filter that takes the request (especially the query string) and re-encodes it into the parameters. Would that be the natural way?
tagged with: java
accepted answer: http://stackoverflow.com/a/2657902
upvote count: 7
type: Question

http://stackoverflow.com/comment/2756323
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2725542
score: 1
has text: @Lucass, generators can be implemented using Java threads with two `BlockingQueue`s. Yield is implemented as a push onto the first queue followed by a get on the second queue. The next and send methods of Python's generator objects are implemented by doing a get on the first queue followed by a push on the second queue. There is obviously quite a bit more detail to sort out, but that's the essence of it.

http://stackoverflow.com/comment/2609099
comment on: http://stackoverflow.com/a/2599292
score: 0
type: AnswerComment
type: Comment
has text: So you want the results grouped by rs?

opencv
type: Tag
tag name: opencv
tags question: http://stackoverflow.com/q/2612478

http://stackoverflow.com/q/2689667
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2689686
has answer: http://stackoverflow.com/a/2689700
has answer: http://stackoverflow.com/a/2689686
tagged with: java
has title: find substrings inside string
type: Question
has answer: http://stackoverflow.com/a/40117311
has body: How can i find substrings inside string and then remember and delete it when i found it. EXAMPLE: select * from (select a.iid_organizacijske_enote, a.sifra_organizacijske_enote "Sifra OE", a.naziv_organizacijske_enote "Naziv OE", a.tip_organizacijske_enote "Tip OE" I would like to get all word inside " ", so Sifra OE Naziv OE TIP OE and return select * from (select a.iid_organizacijske_enote, a.sifra_organizacijske_enote, a.naziv_organizacijske_enote, a.tip_organizacijske_enote i try with regex, indexOf() but no one works ok
accepted answer: http://stackoverflow.com/a/2689700
score: 0
has comment: http://stackoverflow.com/comment/2710552
has answer: http://stackoverflow.com/a/2689917
answer count: 4

http://stackoverflow.com/a/19751378
answers question: http://stackoverflow.com/q/2711231
downvote count: 0
type: Answer
score: 2
upvote count: 2
has body: The datatypes supported by Datastore are listed in Datastore &gt; Entities, Properties, and Keys &gt; Properties and value types

http://stackoverflow.com/q/2784772
favorite count: 0
linked to: http://stackoverflow.com/q/992019
tagged with: static
has body: i am doing a class with static methods to encrypt and decrypt a message using javax.crypto. I have 2 static methods that use ecipher and dcipher in order to do what they are supossed to do i need to initialize some variables (which are static also). But when i try to use it i get InvalidKeyException with the parameters i give to ecipher.init(...). I can't find why. Here is the code: private static byte[] raw = {-31, 17, 7, -34, 59, -61, -60, -16, 26, 87, -35, 114, 0, -53, 99, -116, -82, -122, 68, 47, -3, -17, -21, -82, -50, 126, 119, -106, -119, -5, 109, 98}; private static SecretKeySpec skeySpec; private static Cipher ecipher; private static Cipher dcipher; static { try { skeySpec = new SecretKeySpec(raw, "AES"); // Instantiate the cipher ecipher = Cipher.getInstance("AES"); dcipher = Cipher.getInstance("AES"); ecipher.init(Cipher.ENCRYPT_MODE, skeySpec); dcipher.init(Cipher.DECRYPT_MODE, skeySpec); } catch (NoSuchAlgorithmException e) { throw new UnhandledException("No existe el algoritmo deseado", e); } catch (NoSuchPaddingException e) { throw new UnhandledException("No existe el padding deseado", e); } catch (InvalidKeyException e) { throw new UnhandledException("Clave invalida", e); } }
upvote count: 2
tagged with: exception
tagged with: encryption
type: AnsweredQuestion
tagged with: java
has title: Java: Cipher package (encrypt and decrypt). invalid key error
has answer: http://stackoverflow.com/a/2784955
type: Question
has comment: http://stackoverflow.com/comment/2820239
downvote count: 0
accepted answer: http://stackoverflow.com/a/2784955
possible better answer: http://stackoverflow.com/a/2784894
answer count: 2
score: 2
has answer: http://stackoverflow.com/a/2784894

http://stackoverflow.com/a/2646354
downvote count: 0
type: Answer
upvote count: 1
has body: URLs under /_ah/ are reserved by App Engine, and will be directed to the appropriate subsystem regardless of what your config says. What makes you think requests are being sent to your handler instead of the blobstore one?
answers question: http://stackoverflow.com/q/2626581
score: 1

http://stackoverflow.com/q/2647139
has answer: http://stackoverflow.com/a/2647219
score: 2
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2647203
downvote count: 0
tagged with: java
possible better answer: http://stackoverflow.com/a/2647219
has title: How do I write a Guice Provider that doesn't explicitly create objects?
type: Question
answer count: 2
tagged with: dependency-injection
tagged with: guice
has body: Say I have a ClassWithManyDependencies. I want to write a Guice Provider for this class, in order to create a fresh instance of the class several times in my program (another class will depend on this Provider and use it at several points to create new instances). One way to achieve this is by having the Provider depend on all the dependencies of ClassWithManyDependencies. This is quite ugly. Is there a better way to achieve this? Note - I certainly don't want the Provider to depend on the injector. Another option I considered is having ClassWithManyDependencies and ClassWithManyDependenciesProvider extend the same base class, but it's butt ugly.
upvote count: 2
favorite count: 0
accepted answer: http://stackoverflow.com/a/2647203

http://stackoverflow.com/comment/2794534
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/2762221
has text: I'm sorry, I did not understood your comment. Isn't arg1 already been changed in the example; it's x and y coordinates have been set to 100.
score: 0

http://stackoverflow.com/q/2604588
has comment: http://stackoverflow.com/comment/2614488
answer count: 2
tagged with: unicode
possible better answer: http://stackoverflow.com/a/2604608
favorite count: 0
has body: I'm writing a webapp, and interfacing with MySQL using Hibernate 3.5. Using "デスクトップ ინგლისური" as my test string, I can input the string and see that it is properly persisted into the database. However, when I later pull the value out of the database and print to the console as a String, I see "?????? ?????????". If I use new OutputStreamWriter(System.out,"UTF-8"); then I get "„Éá„Çπ„ÇØ„Éà„ÉÉ„Éó ·Éò·Éú·Éí·Éö·Éò·É°·É£·É†·Éò"". Why don't I see the original string? These are my hibernate.cfg.xml settings: &lt;property name="hibernate.connection.useUnicode"&gt; true &lt;/property&gt; &lt;property name="hibernate.connection.characterEncoding"&gt; UTF-8 &lt;/property&gt; &lt;property name="hibernate.connection.charSet"&gt; UTF-8 &lt;/property&gt; and this is my database connection string: hibernate.connection.url = jdbc:mysql://localhost/mydatabase?autoReconnect=true&amp;amp;useUnicode=true&amp;amp;characterEncoding=UTF-8
accepted answer: http://stackoverflow.com/a/2604628
has title: Why do Unicode characters show up properly in database, but as ? when printed in Java via Hibernate?
tagged with: utf-8
has answer: http://stackoverflow.com/a/2604628
has answer: http://stackoverflow.com/a/2604608
score: 2
type: AnsweredQuestion
downvote count: 0
tagged with: java
tagged with: hibernate
tagged with: mysql
type: Question
upvote count: 2

http://stackoverflow.com/comment/2790431
has text: Thanks for the idea, but this syntax does not appear to work against views with an instead-of trigger.
comment on: http://stackoverflow.com/a/2754200
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/2643580
type: Comment
has text: @Shervin You can avoid create attribute by using a Expression Language (lookup with option to create). Something like @In("#{componentA}"), Seam creates one if it does not exist.
comment on: http://stackoverflow.com/a/2630027
score: 0
type: AnswerComment

http://stackoverflow.com/comment/2735896
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/2709852
score: 1
has text: It's not as bad as `if loop`. `:P`

http://stackoverflow.com/a/2724270
answers question: http://stackoverflow.com/q/2724222
has comment: http://stackoverflow.com/comment/2750927
upvote count: 1
has body: It's throwing an exception because the pattern didn't match but you tried to get a group from it (m.matches() would be false here); groupCount() will return the number of groups that would be in a match, regardless of if there actually was one. As for why the match isn't working, Java Patterns match on the entire string, not on a substring
has comment: http://stackoverflow.com/comment/2750846
type: Answer
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/2750856

http://stackoverflow.com/comment/2660452
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2645334
has text: And see this article, if you write j2se app: http://java.sun.com/developer/technicalArticles/J2SE/Desktop/persistenceapi/

http://stackoverflow.com/comment/2701271
has text: Related: http://stackoverflow.com/questions/2623180/abstract-class-and-constructor, http://stackoverflow.com/questions/2105783/what-is-the-use-of-creating-a-constructor-for-an-abstract-class-in-java, http://stackoverflow.com/questions/260666/abstract-class-constructor-in-java
score: 1
comment on: http://stackoverflow.com/q/2681568
type: Comment
type: QuestionComment

http://stackoverflow.com/a/2756391
accepted answer of: http://stackoverflow.com/q/2756220
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2756220
type: Answer
has body: I believe this should work: &lt;bean:write name="integer" format="0.000" /&gt;
score: 0

http://stackoverflow.com/comment/2713934
type: Comment
has text: I guess the multiple consumers part of the question is left as an exercise for the reader?
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2691922

http://stackoverflow.com/a/2714975
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2714931
score: 1
has body: If you don't know what classes are available nor what the interface they have is, there is no or very little possibilities for you to use them ( people struggle knowing the interface already ) Generally this "extension" modules are coded to an specific interface, so the new loaded classes will always have certain methods ( ie, a JDBC driver always expect to find a PreparedStatement implementation, a ResultSet etc. etc even when it doesn't know what else is underneath ) In your case and if you want to load and use arbitrarily classes, the only remaining resource I see, is to provide some mechanism to add an scripting language ( such as Groovy, Jython or JRuby ) and code to the discovered interface.
upvote count: 1

http://stackoverflow.com/a/2733389
has body: There's no quicker way. Also note that not every double value will convert to a float - the range of a float is smaller.
type: Answer
answers question: http://stackoverflow.com/q/2733320
score: 3
upvote count: 3
downvote count: 0

http://stackoverflow.com/a/2679403
answers question: http://stackoverflow.com/q/2678997
has body: I would just have my class implement the OnItemSelectedListener interface. That way the onItemSelected() method can stash the string in the current object instance. some really skeletal code: class MyClass extends Activity implements OnItemSelectedListener { private String songtoplay; public void onItemSelected(AdapterView&lt;?&gt; parentView, View selectedItemView, int position, long id) { // ... this.songtoplay = test2; } public void needsSongtoplay(...) { doSomething(this.songtoplay); } }
score: 0
type: Answer

http://stackoverflow.com/a/2598971
has body: You can put your data in JSON format and send it with server request, but I`m not sure does JAVA support working with JSON.
type: Answer
upvote count: 1
has comment: http://stackoverflow.com/comment/2734547
answers question: http://stackoverflow.com/q/2598085
score: 1
downvote count: 0

http://stackoverflow.com/q/2625600
favorite count: 0
score: 19
has body: I have several Java classes with double fields that I am persisting via Hibernate. For example, I have @Entity public class Node ... private double value; When Hibernate's org.hibernate.dialect.Oracle10gDialect creates the DDL for the Node table, it maps the value field to a "double precision" type. create table MDB.Node (... value double precision not null, ... It would appear that in Oracle, "double precision" is an alias for "float". So, when I try to verify the database schema using the org.hibernate.cfg.AnnotationConfiguration.validateSchema() method, Oracle appears to describe the value column as a "float". This causes Hibernate to throw the following Exception org.hibernate.HibernateException: Wrong column type in DBO.ACL_RULE for column value. Found: float, expected: double precision A very similar problem is listed in Hibernate's JIRA database as HHH-1961. I'd like to avoid doing anything that will break MySql, Postgres, and Sql Server support so extending the Oracle10gDialect appears to be the most promising of the workarounds mentioned in HHH-1961. But extending a Dialect is something I've never done before and I'm afraid there may be some nasty gotchas. What is the best workaround for this problem that won't break our compatibility with MySql, Postgres, and Sql Server?
tagged with: oracle-database
accepted answer: http://stackoverflow.com/a/2627361
answer count: 4
has answer: http://stackoverflow.com/a/3668776
has title: What are the best workarounds for known problems with Hibernate's schema validation of floating point columns when using Oracle 10g?
type: AnsweredQuestion
upvote count: 19
has answer: http://stackoverflow.com/a/7205319
tagged with: java
tagged with: hibernate
tagged with: orm
has answer: http://stackoverflow.com/a/2626107
possible better answer: http://stackoverflow.com/a/7205319
type: Question
downvote count: 0
has answer: http://stackoverflow.com/a/2627361

http://stackoverflow.com/q/2781718
favorite count: 0
has answer: http://stackoverflow.com/a/9994305
has answer: http://stackoverflow.com/a/3195920
type: UnansweredQuestion
tagged with: google-app-engine
score: 5
has body: I'm using the GAE datastore for a Java application, and storing some text that will be in numerous languages. In my servlet, I'm first checking to see if there's any data in the data store, and, if not, I'm creating some, similar to the following: ArrayList&lt;Lang&gt; list = new ArrayList&lt;Lang&gt;(); list.add(new Lang("EN", "English", 1)); list.add(new Lang("ES", "Español", 0)); //more languages here... PersistenceManager pm = PMF.get().getPersistenceManager(); for(Lang l : list) { pm.makePersistent(l); } Since this is using JDO, I guess I should include the relevent parts of the Lang class too: @PersistenceCapable public class Lang { @PrimaryKey private String code; @Persistent private String name; @Persistent private int popularity; // getters &amp; setters &amp; constructors... } However, the non-ASCII characters are giving me grief. I've set my Eclipse project to use the UTF-8 encoding instead of the default Cp1252, so I think I'm okay from that perspective, but when I use the App Engine Data Viewer to look at my data, that Español entry becomes EspaÃ±ol, and when I click on it to view it, I get a 500 Server Error. (There are some other entries with right-to-left text that don't even show up in the Data Viewer at all, but one problem at a time...) Is there anything special I can do in my code to set the character encoding, or specify to GAE that the data I'm storing is UTF-8? Or is the problem on the Eclipse side, and is there something I should be doing with my Java code?
answer count: 4
tagged with: java
tagged with: character-encoding
type: Question
has answer: http://stackoverflow.com/a/7282028
tagged with: google-cloud-datastore
has title: Google App Engine datastore encoding?
upvote count: 5
has answer: http://stackoverflow.com/a/2783682
has comment: http://stackoverflow.com/comment/2818092
downvote count: 0

getter-setter
tags question: http://stackoverflow.com/q/2676689
tags question: http://stackoverflow.com/q/2622445
tag name: getter-setter
tags question: http://stackoverflow.com/q/2715611
type: Tag

http://stackoverflow.com/comment/90417248
comment on: http://stackoverflow.com/a/11120538
has text: When the receiving Activity is recreated (eg on screen rotation) `obj` becomes `null`. To avoid this, `obj` should be stored somewhere to get it again. Indeed the Json solution stores object data in Intent.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2683718
comment on: http://stackoverflow.com/q/2665780
type: Comment
type: QuestionComment
has text: Following Thomas' comment, if you give up false values, replace the value type to be Integer and then you have both the qualities and their respective rate in a single map.
score: 1

http://stackoverflow.com/q/2718560
has title: Why is the synchronized keyword in Java called 'synchronized' instead of the more precise 'mutexed'?
linked to: http://stackoverflow.com/q/1085709
upvote count: 12
tagged with: java
has comment: http://stackoverflow.com/comment/2744404
type: Question
has answer: http://stackoverflow.com/a/2718636
score: 10
downvote count: 2
answer count: 3
has answer: http://stackoverflow.com/a/2718991
has answer: http://stackoverflow.com/a/2718649
tagged with: synchronized
favorite count: 0
type: UnansweredQuestion
has body: I've heard that choosing to use the word 'synchronized' to describe mutexed statements is simply a mistake (Edit: 'mistake' was a bad choice of words here. Please see edit) in Java, but I'm wondering if there is actually a reason behind the choice. [Edit] Prodded by Safyan's comments, I would like to add that synchronization is a general term for establishing timing relationships between threads. It can include mutual exclusion and things like rate control (eg. two threads doing something at the same rate). It appears unnecessarily ambiguous to use 'synchronized' to mean mutual exclusion instead of a more specific keyword like 'mutexed'.

http://stackoverflow.com/comment/121730523
score: 0
has text: How about `-1`?
comment on: http://stackoverflow.com/a/12297485
type: AnswerComment
type: Comment

http://stackoverflow.com/q/2655513
has answer: http://stackoverflow.com/a/2655533
answer count: 2
upvote count: 7
has body: How to list all available LookAndFeel themes? I want to show then in a JComboBox for the user to select.
favorite count: 0
accepted answer: http://stackoverflow.com/a/2655528
possible better answer: http://stackoverflow.com/a/2655533
type: AnsweredQuestion
downvote count: 0
has title: How to list all available LookAndFeel themes?
score: 7
tagged with: java
tagged with: look-and-feel
has answer: http://stackoverflow.com/a/2655528
tagged with: swing
type: Question

http://stackoverflow.com/q/2695214
favorite count: 0
score: 38
has comment: http://stackoverflow.com/comment/133863462
has answer: http://stackoverflow.com/a/2695231
answer count: 5
linked to: http://stackoverflow.com/q/15375490
has answer: http://stackoverflow.com/a/46128695
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/9220336
has title: Convert .jar to an OSX executable?
type: Question
accepted answer: http://stackoverflow.com/a/2695231
possible better answer: http://stackoverflow.com/a/37435776
has answer: http://stackoverflow.com/a/37435776
has body: I made a Java application which I would like to distribute on Windows, OSX and Linux without distributing a jar file. I used the great Windows exe wrapper http://launch4j.sourceforge.net/ to create an .exe file complete with my icon that won't scare Windows users. Are there similar wrappers that I can use for OSX/Unix? An important consideration is that I would like to have my own icon on the executable (especially for mac users). Thanks!
downvote count: 0
has answer: http://stackoverflow.com/a/2695519
upvote count: 38

http://stackoverflow.com/comment/63564624
has text: Are you sure that this produces the right result in all situations ? If you run this algorithm on the list 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 3 -> ..., I believe that it would return 4 as the head, whereas you wanted 3.
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/38062319

http://stackoverflow.com/q/2697572
downvote count: 0
accepted answer: http://stackoverflow.com/a/4214608
tagged with: android
possible better answer: http://stackoverflow.com/a/2697983
favorite count: 0
has answer: http://stackoverflow.com/a/2697983
upvote count: 1
has body: I need to develop an application that will check whether the phone is in roaming. If it's in roaming then the application should block internet for all applications except several from white list. In non-roaming mode it should allow all requests. There should be no way for user to kill or suspend the application or turn internet on. I'm not familiar with android much so I really don't know whether it possible to implement without modification of OS. Is there any way to do this?
has answer: http://stackoverflow.com/a/4214608
type: AnsweredQuestion
has title: Is it possible to implement a secure application to block internet on Android in roaming?
score: 1
tagged with: java
tagged with: android-ndk
type: Question
answer count: 2

http://stackoverflow.com/a/2723103
score: 2
type: AcceptedAnswer
downvote count: 0
type: Answer
upvote count: 2
has body: It's not clear how you are formatting the dates now, but setDateFormatOverride in DateAxis allows you to specify a suitable SimpleDateFormat. If not already available, you should be able to override getShortMonths() in DateFormatSymbols for the Roman numerals. Addendum: For correct localization, it may be easier to do something like this: DateAxis axis = (DateAxis) plot.getDomainAxis(); DateFormatSymbols dfs = DateFormatSymbols.getInstance(); // default locale String[] roman = { ... }; dfs.setShortMonths(roman); axis.setDateFormatOverride(new SimpleDateFormat("dd-MMM-yyyy", dfs));
has comment: http://stackoverflow.com/comment/2757470
accepted answer of: http://stackoverflow.com/q/2721536
answers question: http://stackoverflow.com/q/2721536

http://stackoverflow.com/comment/66115348
comment on: http://stackoverflow.com/q/2724725
score: 0
type: Comment
type: QuestionComment
has text: "What you people are using" IS the topic, it is SO annoying that you people decide to just close things because they are "opinion based". Ironic isn't?

http://stackoverflow.com/comment/2779396
comment on: http://stackoverflow.com/a/2747281
type: AnswerComment
score: 0
type: Comment
has text: This does not surprise me. My hopes for malabar, however, are much bigger.

http://stackoverflow.com/a/10473835
downvote count: 1
upvote count: 17
has comment: http://stackoverflow.com/comment/46761717
has comment: http://stackoverflow.com/comment/62499987
has body: Given the following question : Write code to remove the duplicate characters in a string without using any additional buffer. NOTE: One or two additional variables are fine. An extra copy of the array is not. Since one or two additional variables are fine but no buffer is allowed, you can simulate the behaviour of a hashmap by using an integer to store bits instead. This simple solution runs at O(n), which is faster than yours. Also, it isn't conceptually complicated and in-place : public static void removeDuplicates(char[] str) { int map = 0; for (int i = 0; i &lt; str.length; i++) { if ((map &amp; (1 &lt;&lt; (str[i] - 'a'))) &gt; 0) // duplicate detected str[i] = 0; else // add unique char as a bit '1' to the map map |= 1 &lt;&lt; (str[i] - 'a'); } } The drawback is that the duplicates (which are replaced with 0's) will not be placed at the end of the str[] array. However, this can easily be fixed by looping through the array one last time. Also, an integer has the capacity for only regular letters.
type: Answer
has comment: http://stackoverflow.com/comment/22675329
has comment: http://stackoverflow.com/comment/46762629
score: 16
answers question: http://stackoverflow.com/q/2598129

http://stackoverflow.com/comment/3159453
type: QuestionComment
comment on: http://stackoverflow.com/q/2706335
has text: Beware, unless you take precautions, MySQL JDBC Driver will fetch *ALL* requested data into memory and only then will it return the ResultSet. In other words, when your code finally iterates over the ResultSet, all data is already in memory! (See http://dev.mysql.com/doc/refman/5.5/en/connector-j-reference-implementation-notes.html, section about ResultSet)
score: 0
type: Comment

http://stackoverflow.com/comment/12982603
has text: See http://jersey.java.net/nonav/apidocs/1.11/contribs/jersey-guice/com/sun/jersey/guice/spi/container/servlet/package-summary.html for an overview of what goes into web.xml.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/6172474

http://stackoverflow.com/comment/2761331
type: Comment
score: 1
has text: IF "I" is so unacceptable in the Java world than why is "Abstract" seen as okay for Abstract classes?
comment on: http://stackoverflow.com/q/2728093
type: QuestionComment

http://stackoverflow.com/a/4446059
type: Answer
has body: http://download.oracle.com/docs/cd/E17802_01/products/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/operator/MosaicDescriptor.html I think you misunderstood the doc you need to set the minX minY for EACH source image before the operation. northwest.tif should have minX=0 and minY=0, northeast.tif should have minX=5000 and minY=0, southwest.tif should have minX=0, minY=5000 and southeast.tif should have minx=5000 and minY = 5000 In the doc they suggest you deserialize the files directly "moved" by using rendering hint on the deserialization operation. Somehow, mosaic is just a normal compositing operation.
upvote count: 1
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/2768128

http://stackoverflow.com/comment/44432964
type: Comment
has text: How can I effectively handle MaxUploadSizeExceededException in an ajax based context ? I am uploading file by ajax request, so when file uploading failed I want to show a javascript alert in the browser, instead of redirecting to some error page. How can I do this ?
comment on: http://stackoverflow.com/a/3230352
type: AnswerComment
score: 0

http://stackoverflow.com/a/34166698
has body: The @RequestMapping annotation now supports setting the path attribute instead of name or value. With path, you can achieve the mapping desired by this question: @RequestMapping(method=RequestMethod.GET, path="campaigns/{id}") public String getCampaignDetails(Model model, @PathVariable("id") Long id) { @RequestMapping(method=RequestMethod.GET, value="campaigns") public String getCampaignDetails(Model model, @RequestParam("id") Long id) {
type: Answer
score: 2
answers question: http://stackoverflow.com/q/2745471
downvote count: 0
upvote count: 2

http://stackoverflow.com/comment/2633044
type: Comment
score: 0
type: AnswerComment
has text: There is one nice function: Character.isDigit(char)
comment on: http://stackoverflow.com/a/2620751

http://stackoverflow.com/a/2669451
has body: If I annotate the column with a size of 128MB, I feel like I'll be wasting a lot of space for the small and mid-sized objects. Is there a variable length blob type I can use? LOB (CLOB or BLOB) don't have a size (as far as I know in most database). The type is meant to hold information that is clearly larger than "regular" data. Most database will use a different storage scheme for such data, e.g. store them in another segment as the main data of the table. I don't think the size parameter is considered by Hibernate. Will hibernate take care of all of this for me behind the scenes without wasting space? Hibernate can not do much and it's the database that will manage the efficient storage of LOB. LOB have are a bit slower than other types (because of the special storage), but they are still very well managed by databases. the length of the byte[] can vary a lot (from ~10KB all the way up to ~100MB) What's the best way to go about this? 10KB is already big compared to the size of regular data in a row (e.g. a numeric, or a few characters). It would be more problematic if you had for instance strings that can be short (e.g 20 chars), but also very long (e.g. 3000 characters). In this case you would pay the price of the LOB for small strings (which could be stored in the main data of the table). But 10KB is anyway relatively large, so the usage of a LOB is really justified. Notes: You might consider to use a stream (e.g. InputStream) instead of a byte array. This might improve the performance of your application, and you won't be constrained by memory (what happens when you have 20 concurrent users which access a 100MB LOB?). You might also consider asking your DBA how to tune the LOB storage. Most database have parameters for this. Here is for instance the Oracle LOB Performance Guideline.
score: 3
answers question: http://stackoverflow.com/q/2669389
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2669389
has comment: http://stackoverflow.com/comment/2695608
type: Answer
upvote count: 3
has comment: http://stackoverflow.com/comment/2700669

http://stackoverflow.com/comment/2641428
comment on: http://stackoverflow.com/q/2628379
type: Comment
type: QuestionComment
has text: google for "wordlist" and you'll find plenty of lists of English words.
score: 0

http://stackoverflow.com/a/24978979
has body: It is perfectly valid to use JUnit to write acceptance tests. JUnit is just a test execution framework, it is completely irrelevant whether you are actually writing unit tests with it, component tests, integration tests or acceptance tests. As user1704737 already said it is important that you have a readable DSL for writing your tests. To write you tests in JUnit I suggest to give JGiven a try. It is a lightweight framework to make it easy to write acceptance tests in the given-when-then notation in plain Java. It uses JUnit (or TestNG) as a test executor, so that it can easily be integrated into existing test infrastructures. You also get HTML reports for your acceptance tests which you can show business to validate the tests against the requirements. Disclaimer: I am the author of JGiven
score: 5
answers question: http://stackoverflow.com/q/2694529
upvote count: 5
type: Answer
downvote count: 0

web-services
type: Tag
tags question: http://stackoverflow.com/q/2739840
tags question: http://stackoverflow.com/q/2629517
tags question: http://stackoverflow.com/q/2624536
tags question: http://stackoverflow.com/q/2684407
tags question: http://stackoverflow.com/q/2644090
tags question: http://stackoverflow.com/q/2619435
tags question: http://stackoverflow.com/q/2629366
tags question: http://stackoverflow.com/q/2617320
tags question: http://stackoverflow.com/q/2671306
tags question: http://stackoverflow.com/q/2644477
tags question: http://stackoverflow.com/q/2738204
tags question: http://stackoverflow.com/q/2622052
tags question: http://stackoverflow.com/q/2688145
tags question: http://stackoverflow.com/q/2647902
tags question: http://stackoverflow.com/q/2756779
tags question: http://stackoverflow.com/q/2675299
tags question: http://stackoverflow.com/q/2596855
tags question: http://stackoverflow.com/q/2746062
tags question: http://stackoverflow.com/q/2777118
tags question: http://stackoverflow.com/q/2626771
tags question: http://stackoverflow.com/q/2776149
tags question: http://stackoverflow.com/q/2666737
tags question: http://stackoverflow.com/q/2600523
tags question: http://stackoverflow.com/q/2733022
tags question: http://stackoverflow.com/q/2711404
tags question: http://stackoverflow.com/q/2650983
tags question: http://stackoverflow.com/q/2678886
tags question: http://stackoverflow.com/q/2780986
tags question: http://stackoverflow.com/q/2763587
tags question: http://stackoverflow.com/q/2653289
tags question: http://stackoverflow.com/q/2704700
tags question: http://stackoverflow.com/q/2717220
tags question: http://stackoverflow.com/q/2744127
tags question: http://stackoverflow.com/q/2739134
tags question: http://stackoverflow.com/q/2622586
tags question: http://stackoverflow.com/q/2746579
tags question: http://stackoverflow.com/q/2676241
tags question: http://stackoverflow.com/q/2736654
tags question: http://stackoverflow.com/q/2649632
tags question: http://stackoverflow.com/q/2611758
tags question: http://stackoverflow.com/q/2751949
tags question: http://stackoverflow.com/q/2707118
tags question: http://stackoverflow.com/q/2695215
tags question: http://stackoverflow.com/q/2764871
tag name: web-services
tags question: http://stackoverflow.com/q/2703092
tags question: http://stackoverflow.com/q/2688878
tags question: http://stackoverflow.com/q/2728942
tags question: http://stackoverflow.com/q/2725495
tags question: http://stackoverflow.com/q/2719501
tags question: http://stackoverflow.com/q/2675776
tags question: http://stackoverflow.com/q/2664714
tags question: http://stackoverflow.com/q/2719198
tags question: http://stackoverflow.com/q/2653932
tags question: http://stackoverflow.com/q/2765876
tags question: http://stackoverflow.com/q/2689122
tags question: http://stackoverflow.com/q/2749378
tags question: http://stackoverflow.com/q/2667646
tags question: http://stackoverflow.com/q/2760582

http://stackoverflow.com/a/6778191
answers question: http://stackoverflow.com/q/2743177
type: Answer
accepted answer of: http://stackoverflow.com/q/2743177
score: 16
upvote count: 16
has comment: http://stackoverflow.com/comment/20084363
has body: I realize this question was asked over a year ago, but like me, I thought many would stumble across this forum post and be left attempting to make a workaround like that one suggested in the bug report (failed to work for me just fyi). Either way there is a better answer since JDK 1.6. Flowlayout has the following method: public void setAlignOnBaseline(boolean alignOnBaseline) If you use this method on your flowlayout and set it to true, then when flowlayout lays out the components it will check each component's baseline and align the component along this baseline. But that's not all you need to do. The component in question must override the following two methods in this way: @Override public Component.BaselineResizeBehavior getBaselineResizeBehavior() { return Component.BaselineResizeBehavior.CONSTANT_ASCENT; } @Override public int getBaseline(int width, int height) { return 0; } They are methods in JComponent and layouts and layoutmanagers use these methods to determine how to layout the component. If you take the steps mentioned above all the components will align themselves along the top of each row. Of course if you just want to use a component like JButton you will obviously have to extend it in order to achieve your desired goal... but it's not as much work as overriding layoutcontainer with a workaround that you have to debug. At least I think so. Good luck, -Asaf
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/7521819
has text: OK. I would embed it anyway, if I have enought space, and where it matters, in case a new version of the font will show different rendering behaviour.
comment on: http://stackoverflow.com/a/2775746
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/2758878
score: 0
type: Comment
has text: Ahhhh, thank you so, so so much =] I knew I might be missing some code =] -Testing it shortly...
comment on: http://stackoverflow.com/a/2722774
type: AnswerComment

http://stackoverflow.com/comment/2779785
type: AnswerComment
has text: How does `BigDecimal` detect infinite recurring decimal? It must keep track of and detect a cycle in the dividend. It COULD HAVE chosen to handle this another way, by marking where the recurring portion is, etc.
comment on: http://stackoverflow.com/a/2749636
type: Comment
score: 0

swank
tags question: http://stackoverflow.com/q/2661025
tag name: swank
type: Tag

http://stackoverflow.com/a/55621768
upvote count: 2
score: 1
downvote count: 1
answers question: http://stackoverflow.com/q/2631596
has comment: http://stackoverflow.com/comment/129535474
has body: You can accomplish this by passing an ArgumentCaptor capture and then retrieving the varargs as a list using "getAllValues", see: https://stackoverflow.com/a/55621731/11342928
type: Answer

http://stackoverflow.com/a/11080603
has comment: http://stackoverflow.com/comment/31195327
type: Answer
has body: Note that Apache Commons Math also contains Michael Powell's direct search BOBYQA algorithm. This algorithm generally converges in substantially fewer iterations than the classical Nelder-Mead method, plus it also supports bounds on the variables.
score: 3
upvote count: 3
downvote count: 0
has comment: http://stackoverflow.com/comment/31196546
answers question: http://stackoverflow.com/q/2717868

http://stackoverflow.com/comment/2660275
has text: I've tagged it android and java as googling the methods android came up for all of them, also makes sens in that it's SMS.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2645131
score: 0

struts2
tags question: http://stackoverflow.com/q/2607842
tags question: http://stackoverflow.com/q/2742880
tags question: http://stackoverflow.com/q/2644292
tags question: http://stackoverflow.com/q/2639464
tags question: http://stackoverflow.com/q/2757690
tags question: http://stackoverflow.com/q/2736628
tag name: struts2
tags question: http://stackoverflow.com/q/2778957
tags question: http://stackoverflow.com/q/2736787
tags question: http://stackoverflow.com/q/2634004
tags question: http://stackoverflow.com/q/2699327
tags question: http://stackoverflow.com/q/2647594
tags question: http://stackoverflow.com/q/2676451
type: Tag
tags question: http://stackoverflow.com/q/2737901

http://stackoverflow.com/q/2699580
has answer: http://stackoverflow.com/a/20648221
has answer: http://stackoverflow.com/a/2699656
linked to: http://stackoverflow.com/q/2693329
type: Question
has answer: http://stackoverflow.com/a/14552905
has answer: http://stackoverflow.com/a/2699834
has comment: http://stackoverflow.com/comment/2722841
has comment: http://stackoverflow.com/comment/2722480
has comment: http://stackoverflow.com/comment/2722183
has answer: http://stackoverflow.com/a/27764065
has answer: http://stackoverflow.com/a/71921338
has answer: http://stackoverflow.com/a/2700131
upvote count: 35
has answer: http://stackoverflow.com/a/2699644
has answer: http://stackoverflow.com/a/2699651
downvote count: 0
linked to: http://stackoverflow.com/q/6115896
tagged with: unchecked-exception
favorite count: 0
has title: Difference between Unchecked exception or runtime exception
answer count: 9
score: 35
has body: This was an interview question. What is the main difference between unchecked exception and error as both are not caught? They will terminate the program.
tagged with: exception
type: UnansweredQuestion
tagged with: java

http://stackoverflow.com/q/2645039
tagged with: gwt
type: AnsweredQuestion
score: 3
upvote count: 3
tagged with: java
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/2681294
has title: In GWT, how to known from a SelectionEvent in a Tree if the Shift button is pressed
possible better answer: http://stackoverflow.com/a/2653837
downvote count: 0
tagged with: event-handling
has answer: http://stackoverflow.com/a/2653837
has body: I try in GWT to create a Tree with multiple selection for the nodes and ran into a problem similar to this question Shift Key in GWT?. When a selectionEvent is raised from the Tree, I would like to know if the Shift key is pressed or not. SelectionHandler&lt;TreeItem&gt; getSelectionHandler() { return new SelectionHandler&lt;TreeItem&gt;(){ @Override public void onSelection(SelectionEvent&lt;TreeItem&gt; event) { // is shift key pressed ? } }; } The solution in the question above cannot apply in this case as the SelectionHandler class does not inherit from DOMEvent and then does not have a getNativeEvent() function. I tried a dirty solution by adding keyDownEventHandler and keyUpEventHandler to the Tree with a boolean flag but the handlers are only called when the focus is on the tree so this doesn't work. Is there a simple solution (or just a solution even if it's not simple) ? Thanks. Edit on aem response : The solution can work by enclosing the components in a FocusPanel with a keyUp/DownHandler but then I can't add any component needing keyboard input such as TextArea as the "global" handler takes the priority... So it don't really solve my problem.
favorite count: 0
linked to: http://stackoverflow.com/q/1411752
accepted answer: http://stackoverflow.com/a/2681294

http://stackoverflow.com/q/2719650
type: Question
answer count: 2
has title: Can I find out which thread is running using Eclipse?
downvote count: 0
has comment: http://stackoverflow.com/comment/2745693
favorite count: 0
upvote count: 2
type: UnansweredQuestion
tagged with: multithreading
has answer: http://stackoverflow.com/a/2719694
has answer: http://stackoverflow.com/a/2719814
score: 2
tagged with: java
has body: I close my application by pressing a "Close" button. But in the Eclipse I see a red square indicating that something is still running. When I press this red square, I kill my application completely. Is it possible to find out what is still running (which method, which loop) using Eclipse? P.S. I am a newbie. So, it would be nice to have a simple solution. I also might not understand your answer if you use "technical" words which I do not know. ADDED: I cannot use System.exit since it will kill not only my software but also an "external" software which calls my software.
has comment: http://stackoverflow.com/comment/2745852
tagged with: eclipse

http://stackoverflow.com/q/2683324
upvote count: 15
type: UnansweredQuestion
has title: Java char array to int
has answer: http://stackoverflow.com/a/2683341
downvote count: 1
score: 14
has answer: http://stackoverflow.com/a/34494838
has answer: http://stackoverflow.com/a/13988449
tagged with: java
answer count: 6
has answer: http://stackoverflow.com/a/12297485
type: Question
has answer: http://stackoverflow.com/a/51239193
has answer: http://stackoverflow.com/a/10578427
has body: Is it possible to convert a char[] array containing numbers into an int?
favorite count: 0

http://stackoverflow.com/comment/36528511
comment on: http://stackoverflow.com/a/2617380
type: AnswerComment
score: 0
type: Comment
has text: This sure was my problem. Regenerated equals and hashCode then things started working again. Thanks :-)

http://stackoverflow.com/a/2639250
has body: It seems to work for me: org.testng.TestException: The exception was thrown with the wrong message: expected "incorrect argument" but got "val1 is incorrect" Can you post a simple class showing the problem? (either here or on the testng-users mailing-list)
answers question: http://stackoverflow.com/q/2638694
upvote count: 5
type: Answer
downvote count: 0
score: 5

http://stackoverflow.com/comment/2704259
type: Comment
score: 2
comment on: http://stackoverflow.com/a/2684089
type: AnswerComment
has text: Well, one could consider user input and data store as part of the "Environment", in that they are external to the logic of the code itself.

http://stackoverflow.com/q/2614890
has answer: http://stackoverflow.com/a/2614924
has title: How can two programs talk to each other in Java?
favorite count: 0
answer count: 6
has answer: http://stackoverflow.com/a/2614926
has answer: http://stackoverflow.com/a/2618219
score: 4
type: Question
accepted answer: http://stackoverflow.com/a/2614922
has answer: http://stackoverflow.com/a/2614918
tagged with: java
has body: I want to ‪reduce‬ the CPU usage/ROM usage/RAM usage - generally‬, all system resources that my app uses - who doesn't? :) For this reason I want to split the preferences window from the rest of the application, and let the preferences window to run as ‪independent‬ program. The preferences program ‪should‬ write to a Property file(not a problem at all) and to send a "update signal" to the main program - which means it should call the update method (that i wrote) that found in the Main class. How can I call the update method in the Main program from the preferences program? To put it another way, is a way to build preferences window that take system resources just when the window appears? Is this approach - of separating programs and let them talk to each other (somehow) - the right approach for speeding up my programs?
upvote count: 4
tagged with: user-interface
downvote count: 0
has comment: http://stackoverflow.com/comment/2626390
has answer: http://stackoverflow.com/a/2614922
has answer: http://stackoverflow.com/a/2615959
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2614924

http://stackoverflow.com/q/2671295
has answer: http://stackoverflow.com/a/10559278
has answer: http://stackoverflow.com/a/2988094
tagged with: spring-security
favorite count: 0
upvote count: 5
has body: I currently have my ldap authentication context set up like this: <ldap-server url="ldap://host/dn" manager-dn="cn=someuser" manager-password="somepass" /> <authentication-manager> <ldap-authentication-provider user-search-filter="(samaccountname={0})"/> </authentication-manager> Now, I need to be able to set up a custom authorities mapper (it uses a different ldap server) - so I am assuming I need to set up my ldap-server similar to (http://static.springsource.org/spring-security/site/docs/2.0.x/reference/ldap.html): uid={0},ou=people But, how do I reference that 'ldapAuthProvider' to the ldap-server in the security context? I am also using spring-security 3, so '' does not exist...
has comment: http://stackoverflow.com/comment/71537560
has title: Spring security custom ldap authentication provider
downvote count: 0
type: UnansweredQuestion
tagged with: authentication
type: Question
has answer: http://stackoverflow.com/a/16609171
score: 5
tagged with: java
answer count: 3
linked to: http://stackoverflow.com/q/34658534

header
type: Tag
tag name: header
tags question: http://stackoverflow.com/q/2656478
tags question: http://stackoverflow.com/q/2596724

http://stackoverflow.com/a/25780761
score: 0
type: Answer
answers question: http://stackoverflow.com/q/2748910
has body: When we compile C source data, it generate native code which can be understood by current operating system. When we move this source code to the other operating system, it can't be understood by operating system because of native code that means representation is change from O.S to O.S. So C or C++ are platform dependent . Now in case of java, after compilation we get byte code instead of native code. When we will run the byte code, it is converted into native code with the help of JVM and then it will be executed. So Java is platform independent and C or C++ is not platform independent.

http://stackoverflow.com/a/2656094
has comment: http://stackoverflow.com/comment/3988766
answers question: http://stackoverflow.com/q/2655929
has comment: http://stackoverflow.com/comment/2672752
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2655929
score: 2
has body: You shouldn't change the look and feel once a component is rendered. It must be done before initialization of a component. From here: Note: If you are going to set the L&amp;F, you should do it as the very first step in your application. Otherwise you run the risk of initializing the Java L&amp;F regardless of what L&amp;F you've requested. This can happen inadvertently when a static field references a Swing class, which causes the L&amp;F to be loaded. If no L&amp;F has yet been specified, the default L&amp;F for the JRE is loaded. For Sun's JRE the default is the Java L&amp;F, for Apple's JRE the Apple L&amp;F, and so forth.
type: Answer
has comment: http://stackoverflow.com/comment/2685762
upvote count: 3
downvote count: 1

http://stackoverflow.com/comment/71522260
type: AnswerComment
comment on: http://stackoverflow.com/a/41780174
has text: Using Uri.Builder only works for absolute URIs, in the form of: `<scheme>://<authority><absolute path>?<query>#<fragment>`, not opaque URIs `<scheme>:<opaque part>#<fragment>`. The above code yields the following URI: `geo:/0%2C0?Eiffel%20Tower` which causes the Google Maps app to crash. Even [the official documentation](https://developers.google.com/maps/documentation/android-api/intents) uses raw/opaque URIs for this very reason. The correct code would then be: `Uri.parse("geo:0,0?q=" + Uri.encode("Eiffel Tower"))`
type: Comment
score: 1

http://stackoverflow.com/comment/2693693
comment on: http://stackoverflow.com/q/2674707
type: Comment
type: QuestionComment
score: 4
has text: Use Horner-Scheme: ((((a * 10 + b) * 10 + c) * 10 + d) * 10 + e. Why do you lose b, when you add them up?

http://stackoverflow.com/comment/57191426
type: AnswerComment
comment on: http://stackoverflow.com/a/31238479
has text: This will only work for periodic firings. What happens when there's no `subsequentNextValidTime` or when firings are irregular (e.g. fire at minutes 10, 12, 11, 17, 37)?
type: Comment
score: 1

http://stackoverflow.com/comment/2685664
type: Comment
score: 3
has text: I would suspect that the post method is being called a lot, and the problem isn't local to this code. The program stops responding because it is spawning many threads (not all of which have a status of serviceResolved)
comment on: http://stackoverflow.com/q/2667499
type: QuestionComment

http://stackoverflow.com/a/2622227
answers question: http://stackoverflow.com/q/2622206
has body: How about this: new RandomAccessFile(fileName).setLength(0);
score: 14
type: AcceptedAnswer
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/2622206
upvote count: 14

http://stackoverflow.com/a/2657608
type: AcceptedAnswer
downvote count: 0
has body: How can I store this aliases field through JPA? JPA 1.0 doesn't support collections of basic types so you'll have to either: Introduce an entity and map it as a @OneToMany ~or~ Get your Set stored in a BLOB (as a Serializable) ~or~ Mark it @Transient and use another getter/setter to store it using a custom string representation (using a seperator) ~or~ Use an extension of your JPA provider supporting collection of basic types (e.g. Hibernate has the @CollectionOfElements annotation). Solution #1 would be the cleanest portable solution. Solution #2 can lead to some troubles on upgrades. Solution #3 is a ugly workaround for #2. Solution #4 is clean but non portable. In JPA 2.0, there is the @ElementCollection annotation for this use case (this is of course the ideal solution). How this field get stored in database Depending on the chosen implementation, it may be in a BLOB, in a VARCHAR, in another table.
type: Answer
accepted answer of: http://stackoverflow.com/q/2657554
answers question: http://stackoverflow.com/q/2657554
upvote count: 7
score: 7

http://stackoverflow.com/q/2607858
possible better answer: http://stackoverflow.com/a/2607931
linked to: http://stackoverflow.com/q/2050263
has answer: http://stackoverflow.com/a/66447614
downvote count: 0
linked to: http://stackoverflow.com/q/15366403
has comment: http://stackoverflow.com/comment/37252504
has answer: http://stackoverflow.com/a/44163214
has title: Android - Barcode Scanning, Options? Zxing?
tagged with: android
accepted answer: http://stackoverflow.com/a/2614046
answer count: 7
has answer: http://stackoverflow.com/a/2608179
linked to: http://stackoverflow.com/q/41392426
favorite count: 0
has body: I want to create an application for Android that will be able to scan barcodes, get the information contained within the barcode and then be able to use that information in some way. I have no idea how to create a barcode scanner so I went Googling and it seems Zxing is the most commonly used way to implement a barcode scanner in an app. Some Links: http://code.google.com/p/zxing/ http://awalkingcity.com/blog/2008/08/25/qr-codes-made-easy-in-android/ Using ZXing to create an android barcode scanning app However the samples I found on zxing involved having to prompt the user to go to the market and install the zxing barcode scanner so that my app can then call the barcode scanner when its needed and the barcode scanner will then return the info to my app. While this would be a good starting point for me I was wondering is there any other options that would allow me to have a barcode scanner embedded in my own application without having to prompt the user to download a secondary application?
has comment: http://stackoverflow.com/comment/103780111
has answer: http://stackoverflow.com/a/33891524
has comment: http://stackoverflow.com/comment/10519782
has comment: http://stackoverflow.com/comment/2625230
type: AnsweredQuestion
score: 21
tagged with: java
has answer: http://stackoverflow.com/a/32021172
has answer: http://stackoverflow.com/a/2607931
upvote count: 21
tagged with: zxing
has answer: http://stackoverflow.com/a/2614046
type: Question
tagged with: barcode-scanner

http://stackoverflow.com/comment/30346303
type: Comment
score: 0
has text: Nevermind, it won't work for empty folders in `scr\main\webapp\`. See https://jira.codehaus.org/browse/MWAR-128 for solution / workaround
comment on: http://stackoverflow.com/a/2605769
type: AnswerComment

http://stackoverflow.com/comment/2804987
has text: What I don't really get is in a situation like this, what is the upshot of the variable not being final? Is there a possibility that the JVM will throw an Exception of some sort if two threads try to access the variable at exactly the same nanosecond or what?
comment on: http://stackoverflow.com/a/2771387
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2790382
type: AnswerComment
score: 0
has text: @Bozho: wouldn't this be analogous to doing `aList instanceof List<String>`? Which you can't do in Java?
type: Comment
comment on: http://stackoverflow.com/a/2758596

http://stackoverflow.com/comment/2804777
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2771387
type: Comment
has text: In what way is it not thread safe though, what are the consequences in this situation? I am trying to gain a deeper understanding of the mechanics of concurrency in Java. I know all the different ways I could make this thread safe.

http://stackoverflow.com/a/4818714
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2618573
score: 43
has comment: http://stackoverflow.com/comment/13195933
type: Answer
has comment: http://stackoverflow.com/comment/34091065
has comment: http://stackoverflow.com/comment/34114938
has body: The copy of HttpClient in Android does not actually match any of the released versions, as this mailing list trail shows. Google seem to have taken an arbitrary snapshot of the development code base and used that. The closest matches seem to be: httpcore-4.0-beta2.jar httpclient-4.0-beta1.jar Seems like a colossal cock-up to me.
accepted answer of: http://stackoverflow.com/q/2618573
upvote count: 43

http://stackoverflow.com/a/28647721
downvote count: 0
type: Answer
score: 2
has body: import java.util.Scanner; class bigest { public static void main (String[] args) { Scanner input = new Scanner(System.in); System.out.println ("how many number you want to put in the pot?"); int num = input.nextInt(); int numbers[] = new int[num]; for (int i = 0; i &lt; num; i++) { System.out.println ("number" + i + ":"); numbers[i] = input.nextInt(); } for (int temp : numbers){ System.out.print (temp + "\t"); } input.close(); } }
upvote count: 2
answers question: http://stackoverflow.com/q/2622725

http://stackoverflow.com/comment/2687891
comment on: http://stackoverflow.com/a/2669555
type: Comment
has text: do we need to purchase any licence for that? or is it free?
score: 0
type: AnswerComment

http://stackoverflow.com/q/2757152
downvote count: 0
answer count: 1
tagged with: branch
has body: I am having problems using IvyDE when I have different workspaces for different branches. I have "Resolve dependencies in workspace" switched on. But everytime I change to a different workspace I have to remember to manually clean the caches out. This is because IvyDE always uses the default cache for resolving dependencies within a workspace, so when switching between workspaces the cache can be polluted by different versions. It would seem that it is impossible to work with two different workspaces at the same time. I cannot find a way to configure the location that IvyDE uses to cache the project dependencies. It does not appear to use the caches defined in the ivysettings.xml
favorite count: 0
upvote count: 2
type: AnsweredQuestion
tagged with: java
tagged with: ivy
has title: Using IvyDE with different workspaces on different branches
type: Question
has answer: http://stackoverflow.com/a/5263560
tagged with: eclipse
tagged with: caching
accepted answer: http://stackoverflow.com/a/5263560
score: 2

http://stackoverflow.com/comment/2766854
has text: @jesper: I stand corrected. Especially with Joachim Sauer's suggestion, this looks like a winner.
comment on: http://stackoverflow.com/a/2738259
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2784859
type: Comment
score: 1
comment on: http://stackoverflow.com/a/2753914
type: AnswerComment
has text: You'll need to change your `while` statement to break on an empty new line. Check the methods provided by `Scanner`. Or consult your course materials, tutor and/or classmates. There they are for.

http://stackoverflow.com/comment/22094656
type: Comment
score: 2
type: AnswerComment
comment on: http://stackoverflow.com/a/2745239
has text: If I want to center align it, how to do it?

http://stackoverflow.com/q/2689101
downvote count: 0
has title: Thread runs only once
has answer: http://stackoverflow.com/a/2689162
has answer: http://stackoverflow.com/a/19620476
favorite count: 0
accepted answer: http://stackoverflow.com/a/2689137
type: Question
tagged with: exception
score: 5
possible better answer: http://stackoverflow.com/a/2689162
has answer: http://stackoverflow.com/a/2689144
tagged with: java
tagged with: multithreading
has answer: http://stackoverflow.com/a/2689137
upvote count: 5
has body: When a Thread is finished, you cannot run it once more, using start() method: it throws an Exception. Could anyone explain, why? What stands behind such an architectural decision?
answer count: 5
has answer: http://stackoverflow.com/a/2689117
type: AnsweredQuestion

http://stackoverflow.com/q/2607842
has body: I have a Struts2 webapp, in which I compiled using the Tomcat 5.5 libraries. If I deploy this webapp on a Tomcat 6 server, should it still work without a hitch?
type: Question
accepted answer: http://stackoverflow.com/a/2608075
downvote count: 0
answer count: 1
tagged with: tomcat
tagged with: struts2
score: 1
favorite count: 0
has title: Compiling a webapp against Tomcat 5.5 libraries and deploying on Tomcat 6
has answer: http://stackoverflow.com/a/2608075
upvote count: 1
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/q/2768087
downvote count: 0
favorite count: 0
upvote count: 90
tagged with: jmx
accepted answer: http://stackoverflow.com/a/7098871
score: 90
has comment: http://stackoverflow.com/comment/12615656
type: AnsweredQuestion
tagged with: java
has body: I am trying to understand a JMX service URL. service:jmx:rmi://192.168.30.10:1234/jndi/rmi://192.168.30.10:2344/jmxrmi It would be great, if someone can help me understand this. Thanks
type: Question
has answer: http://stackoverflow.com/a/2768378
has title: Explain JMX URL
has answer: http://stackoverflow.com/a/7098871
possible better answer: http://stackoverflow.com/a/39014805
linked to: http://stackoverflow.com/q/743343
has answer: http://stackoverflow.com/a/39014805
answer count: 3

http://stackoverflow.com/q/2602696
tagged with: jfreechart
type: Question
score: 4
has answer: http://stackoverflow.com/a/2603723
upvote count: 4
answer count: 1
downvote count: 0
has title: Creating a time series with jfreechart
favorite count: 0
has body: Right now I want to create a time series graph in jfreechart. However the examples online only have charts using classes like "Day", "Month", and so on. So I want to essentially create a XY line chart. However the problem I'm having is that Jfreechart doesn't connect the data points in the order in which they were added. Also it doesn't connect the points in the order of the "X Values". So basically I get a "Z" in my jfreechart. So my question is, is there a way to change the setting for the jfreechart so that it connects the data points based on the "X values"?
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/2612146
tagged with: java
has comment: http://stackoverflow.com/comment/2612640

http://stackoverflow.com/a/2623793
accepted answer of: http://stackoverflow.com/q/2622911
has comment: http://stackoverflow.com/comment/2637141
type: AcceptedAnswer
downvote count: 0
has body: As there seems to be some confusion on whether this is possible or not I think I'll need to provide an extensive example. The question claims that the (initial) input is a byte[] that contains Windows-1252 encoded data. I'll call that byte[] ib (for "initial bytes"). For this example I'll choose the German word "Bär" (meaning bear) as the input: byte[] ib = new byte[] { (byte) 0x42, (byte) 0xE4, (byte) 0x72 }; String correctString = new String(ib, "Windows-1252"); assert correctString.charAt(1) == '\u00E4'; //verify that the character was correctly decoded. (If your JVM doesn't support that encoding, then you can use ISO-8859-1 instead, because those three letters (and most others) are at the same position in those two encodings). The question goes on to state that some other code (that is outside of our influence) already converted that byte[] to a String using the UTF-8 encoding (I'll call that String is for "input String"). That String is the only input that is available to achieve our goal (if ib were available, it would be trivial): String is = new String(ib, "UTF-8"); System.out.println(is); This obviously produces the incorrect output "B�". The goal would be to produce ib (or the correct decoding of that byte[]) with only is available. Now some people claim that getting the UTF-8 encoded bytes from that is will return an array with the same values as the initial array: byte[] utf8Again = is.getBytes("UTF-8"); But that returns the UTF-8 encoding of the two characters B and � and definitely returns the wrong result when re-interpreted as Windows-1252: System.out.println(new String(utf8Again, "Windows-1252"); This line produces the output "Bï¿½", which is totally wrong (it is also the same output that would be the result if the initial array contained the non-word "Bür" instead). So in this case you can't undo the operation, because some information was lost. There are in fact cases where such mis-encodings can be undone. It's more likely to work, when all possi…
type: Answer
has comment: http://stackoverflow.com/comment/68411778
score: 31
upvote count: 31
answers question: http://stackoverflow.com/q/2622911

http://stackoverflow.com/a/2717197
upvote count: 1
answers question: http://stackoverflow.com/q/2712232
score: 1
has body: I also wonder if you could try more than 8 threads. If your CPU supports HyperThreading then (at least in theory) you can squeeze 2 threads per core and see what comes out of it.
downvote count: 0
type: Answer

model-view-controller
tags question: http://stackoverflow.com/q/2674120
tags question: http://stackoverflow.com/q/2662043
tag name: model-view-controller
tags question: http://stackoverflow.com/q/2605801
tags question: http://stackoverflow.com/q/2695401
tags question: http://stackoverflow.com/q/2687345
tags question: http://stackoverflow.com/q/2739821
tags question: http://stackoverflow.com/q/2631753
type: Tag
tags question: http://stackoverflow.com/q/2780119
tags question: http://stackoverflow.com/q/2762936
tags question: http://stackoverflow.com/q/2708725

http://stackoverflow.com/comment/2755414
score: 1
has text: To say that well known acronyms are not in wide spread use is nonsense. The example, although a little contrived is valid. IPSec is very well known, I.P address, ever hear of it? IPSec I.P Security?
type: AnswerComment
comment on: http://stackoverflow.com/a/2728140
type: Comment

http://stackoverflow.com/q/2612170
accepted answer: http://stackoverflow.com/a/2612181
has comment: http://stackoverflow.com/comment/2622977
type: AnsweredQuestion
has title: Throw of a die in Java
tagged with: java
has body: The throw of a die is a popular program in Java, public class Die { /* This program simulates rolling a die */ public static void main(String[] args) { int die; // The number on the die. die = (int)(Math.random()*6 + 1); System.out.println (die); } // end main() } // end class What I wish to do is make it repeat, 500 times. I have not been able to put this program into a loop of 500. I usually program in Python, thus I guess my Java has rusted ! Any help is most welcome !
upvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/2622962
possible better answer: http://stackoverflow.com/a/2612182
has answer: http://stackoverflow.com/a/2612182
has comment: http://stackoverflow.com/comment/2623080
has answer: http://stackoverflow.com/a/2612181
linked to: http://stackoverflow.com/q/738629
answer count: 3
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/2622955
favorite count: 0
has answer: http://stackoverflow.com/a/2612207

http://stackoverflow.com/q/2736665
has body: I'm currently working in Swing UI Assignment. This work involves showing large file content in JTextArea. The file size can be as large as 2 GB. My initial idea is to lazily load content from the file, say 1 MB of content will be shown to the user. As the user scrolls i will retrieve the next 1 MB of content to be shown. All these operation will be happening in background thread (Swing Worker). I looked at the JTextArea API, the method insert takes String and int(position of the insert) as the parameter. This will suffice, but i'm worried about performance, because the content (1 MB at a time) retrieved will have to be converted to String object. Is there any other work around or any other alternative/better solution for this.
score: 3
tagged with: java
type: Question
has title: Displaying large file in JTextArea
tagged with: jtextarea
has answer: http://stackoverflow.com/a/2737143
upvote count: 3
answer count: 1
downvote count: 0
favorite count: 0
type: UnansweredQuestion
tagged with: swing

http://stackoverflow.com/a/2657998
upvote count: 7
has body: The ExecutorService does all that work for you. If all of the threads are currently being used by other tasks, the new tasks will be placed into a queue and processed at some later time. Your main thread will not block when submitting a new task even if all the threads are currently being used. ExecutorService executor = Executors.newFixedThreadPool(N); ResultSet results; while( true ) { results = getWaitingTasksStmt.executeQuery(); while( results.next() ) { // If all threads are in use, the new task will be queued executor.submit( new runnableInheritedClass(results) ); }
type: Answer
downvote count: 0
score: 7
answers question: http://stackoverflow.com/q/2657971

http://stackoverflow.com/q/2739147
upvote count: 1
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2739307
tagged with: java
has comment: http://stackoverflow.com/comment/2767645
type: Question
answer count: 2
downvote count: 0
tagged with: icons
favorite count: 0
tagged with: jlabel
has answer: http://stackoverflow.com/a/3685096
has body: in Netbeans, I am using Jlabels to display images and text within a JFrame. The Jlabels display correctly in the IDE, but when I run or build the project, some of the Jlabels don't show up(Labels that are added later on after the first few). To fix this problem I have to start all over again and add the images all at once. This sucks cause I went from 4 to 8 and now I need to add 20 more images. I really don't want to start all over again. private void initComponents() { mainPanel = new javax.swing.JPanel(); javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator(); jButton2 = new javax.swing.JButton(); menuBar = new javax.swing.JMenuBar(); javax.swing.JMenu fileMenu = new javax.swing.JMenu(); javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem(); javax.swing.JMenu helpMenu = new javax.swing.JMenu(); javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem(); statusPanel = new javax.swing.JPanel(); statusMessageLabel = new javax.swing.JLabel(); statusAnimationLabel = new javax.swing.JLabel(); progressBar = new javax.swing.JProgressBar(); jLabel1 = new javax.swing.JLabel(); jFrame1 = new javax.swing.JFrame(); jLayeredPane2 = new javax.swing.JLayeredPane(); jLabel2 = new javax.swing.JLabel(); PC = new javax.swing.JLabel(); ALU = new javax.swing.JLabel(); BC = new javax.swing.JLabel(); DR = new javax.swing.JLabel(); MUXB = new javax.swing.JLabel(); MUXD = new javax.swing.JLabel(); RF = new javax.swing.JLabel(); IR = new javax.swing.JLabel(); ID = new javax.swing.JLabel(); bg = new javax.swing.JLabel(); mainPanel.setMaximumSize(new java.awt.Dimension(1000, 1000)); mainPanel.setMinimumSize(new java.awt.Dimension(800, 800)); mainPanel.setName("mainPanel"); // NOI18N mainPanel.setPreferredSize(new java.awt.Dimension(900, 900)); statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(honors231.Honors231App.class).getContext().getReso…
has answer: http://stackoverflow.com/a/2739307
possible better answer: http://stackoverflow.com/a/3685096
tagged with: netbeans
has title: Netbeans JLabel Icon/Text Does not Display when Project is Built
score: 1

http://stackoverflow.com/a/2666927
has comment: http://stackoverflow.com/comment/2684976
score: 28
type: Answer
has comment: http://stackoverflow.com/comment/2684965
downvote count: 0
answers question: http://stackoverflow.com/q/2666875
has body: The Java IO API relies on the local disk file system, not on the classpath. Besides, using relative paths in Java IO stuff is recipe for portability trouble, don't rely on it. To allocate resources in the classpath you would normally use ClassLoader#getResource() or ClassLoader#getResourceAsStream(). ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); InputStream input = classLoader.getResourceAsStream("src/main/resources/ids.txt"); That said, you don't need that DataInputStream line. You're actually not taking any benefit from it. Update: if that doesn't work, then either the resource name is simply invalid or the file is actually not there in the classpath where you expect it to be. My cents on that the src folder is actually the root of the classpath and not part of a package. Remove it from the name. Update 2: to get all root disk file system paths which are covered by the runtime classpath do: for (URL root : Collections.list(Thread.currentThread().getContextClassLoader().getResources(""))) { System.out.println(root); } The resource name needs to be relative to either of them. That it is been placed in /WEB-INF/classes during the build is normal. It is covered by the classpath. Your problem lies somewhere else. Are you sure that the resource name is correct? Are you sure that you're running the code you think you are running?
upvote count: 28
accepted answer of: http://stackoverflow.com/q/2666875
has comment: http://stackoverflow.com/comment/2685023
type: AcceptedAnswer

http://stackoverflow.com/a/13953441
answers question: http://stackoverflow.com/q/2597271
type: Answer
score: 77
has body: If you need to actually get a File object, you could do the following: URL url = this.getClass().getResource("/test.wsdl"); File testWsdl = new File(url.getFile()); Which has the benefit of working cross platform, as described in this blog post.
downvote count: 0
upvote count: 77

http://stackoverflow.com/comment/81480015
type: AnswerComment
score: 0
type: Comment
has text: Yes, it can be modified. `Collection<? extends E>` already handles that behavior correctly though, unless you use it in a way that is not type-safe (e.g. casting it to something else). The only advantage I see there is, when you call the `add` operation, it throws an exception even if you casted it.
comment on: http://stackoverflow.com/a/27482801

http://stackoverflow.com/q/2735343
answer count: 1
tagged with: jogl
has title: Jogl - set 'cliping area'
has answer: http://stackoverflow.com/a/2739744
type: AnsweredQuestion
tagged with: java
has body: Is it possible to set 'clipping bounds' in JOGL? Like in Java/Swing i would like to set clipping bounds and all drawing/rendering outside those bounds would be ignored.
type: Question
score: 0
accepted answer: http://stackoverflow.com/a/2739744

http://stackoverflow.com/comment/2787187
type: Comment
score: 1
has text: You want to limit which scope? Constructor's? Class'? If you want a private constructor, you won't be able to instantiate the class outside itself. Usually, the only scenario where you'd like a private constructor is a Factory class.
type: AnswerComment
comment on: http://stackoverflow.com/a/2755820

http://stackoverflow.com/comment/12384599
type: AnswerComment
comment on: http://stackoverflow.com/a/9280568
type: Comment
score: 0
has text: If you look at Eclipse help it appears they also suggest this way.

http://stackoverflow.com/q/2749275
favorite count: 0
has answer: http://stackoverflow.com/a/2750629
has title: how to show integer values in JComboBox?
upvote count: 1
possible better answer: http://stackoverflow.com/a/2750629
has comment: http://stackoverflow.com/comment/2779379
has body: I would like to know how to set a JComboBox that contain integers values that I could save. Here is the definitions of values: public class Item { private String itemDesc; private int itemType; public static int ENTREE=0; public static int MAIN_MEAL=1; public static int DESSERT=2; public static int DRINK=3; private float price; int[] itemTypeArray = { ENTREE, MAIN_MEAL, DESSERT, DRINK }; Object[][] data = {{itemDesc, new Integer(itemType), new Float(price)}}; . . . } Now, I want the add a JComboBox that the user will choose 1 of the items (ENTREE, MAIN_MEAL...) and then I could set the number as an Integer. I know that JComboBox need to be something like that: JComboBox combo = new JComboBox(itemTypeArray.values()); JOptionPane.showMessageDialog( null, combo,"Please Enter Item Type", `JOptionPane.QUESTION_MESSAGE);` What am I doing wrong?
tagged with: jcombobox
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2749376
score: 1
tagged with: java
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/2749376
downvote count: 0

http://stackoverflow.com/a/2598098
score: 0
has body: You need to create a web service in your app engine app that would take post data and consume it. Preferably Use a web service framework otherwise you will have to do a lot of xml parsin yourself, which is baaed. mmmkay Now I dont know if ur using py or java, but do look for a web service framework in ur language. mmkay
type: Answer
answers question: http://stackoverflow.com/q/2598085

http://stackoverflow.com/comment/2619739
comment on: http://stackoverflow.com/q/2609236
has text: @Robert: That would lead to infinite recursion?
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/a/2733862
type: Answer
has comment: http://stackoverflow.com/comment/2761972
upvote count: 3
score: 3
answers question: http://stackoverflow.com/q/2733735
downvote count: 0
has body: I don't see any issues with the code. It could be that your platform has an intermittent bug, or that the website is causing the connection to hang. Changing connection parameters, such as keep alive, may help. But, even with a timeout set, Sockets can hang indefinitely - a friend aptly demonstrated this to me some years ago by pulling out the network cable - my program just hung there forever, even with a SO_TIMEOUT set to 30 seconds. As a "best practice", you can avoid hanging your application by moving all network communication to a separate thread. If you wrap up each request as a Runnable and queue these for exeuction, you maintain control over timeouts (synchronization is still in java, rather than a blocking native I/O call). You can interrupt your waiting thread after (say) 30s to avoid stalling your app. You could then either inform the user, or retry the request. Because the request is a Runnable, you can remove it from the stalled thread's queue and schedule it to execute on another thread.

http://stackoverflow.com/q/2616448
favorite count: 0
has comment: http://stackoverflow.com/comment/2629543
upvote count: 21
answer count: 10
linked to: http://stackoverflow.com/q/2248342
downvote count: 0
has answer: http://stackoverflow.com/a/2617043
has title: I'm tired of JButtons, how can I make a nicer GUI in java?
has answer: http://stackoverflow.com/a/2616463
tagged with: swing
has answer: http://stackoverflow.com/a/2616479
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2616670
has answer: http://stackoverflow.com/a/2616462
has comment: http://stackoverflow.com/comment/2628817
score: 21
tagged with: java
has answer: http://stackoverflow.com/a/2617163
has answer: http://stackoverflow.com/a/2616473
type: Question
has body: So far I've only built "small" graphical applications, using swing and JComponents as I learned at school. Yet I can't bear ugly JButtons anymore. I've tried to play with the different JButton methods, like changing colors, putting icons etc. but I'm still not satisfied. How do you make a nicer GUI in java ? I'm looking for not-too-heavy alternatives (like, without big frameworks or too complicated libraries).
has answer: http://stackoverflow.com/a/2616972
tagged with: user-interface
has answer: http://stackoverflow.com/a/2616711
possible better answer: http://stackoverflow.com/a/2616473
has answer: http://stackoverflow.com/a/2616485
has comment: http://stackoverflow.com/comment/2629539
accepted answer: http://stackoverflow.com/a/2616485

http://stackoverflow.com/comment/24317532
score: 3
has text: I too feel, the question adds value. There might be a few plugin I don't know and hence find other ways (usually through coding) to overcome it. If people share best plugins available, it will serve the SO purpose.
type: Comment
comment on: http://stackoverflow.com/q/2616397
type: QuestionComment

http://stackoverflow.com/q/2693740
possible better answer: http://stackoverflow.com/a/2693971
tagged with: java
type: Question
has title: How to use mkdir and rmdir commands in a java program
downvote count: 0
tagged with: cmd
accepted answer: http://stackoverflow.com/a/2693754
favorite count: 0
answer count: 5
upvote count: 6
tagged with: command-line
has answer: http://stackoverflow.com/a/7701729
has answer: http://stackoverflow.com/a/2693971
has answer: http://stackoverflow.com/a/2693770
score: 6
has answer: http://stackoverflow.com/a/2693754
has answer: http://stackoverflow.com/a/9568696
has body: I want to use system commands like mkdir and rmdir while running a java program. How can I do that?
type: AnsweredQuestion

http://stackoverflow.com/q/2632003
has answer: http://stackoverflow.com/a/2632050
has comment: http://stackoverflow.com/comment/2645377
accepted answer: http://stackoverflow.com/a/2632050
downvote count: 0
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2632051
tagged with: hashmap
score: 1
tagged with: java
type: Question
answer count: 2
has body: i have a hashmap where every key has many values(stored in a arraylist). How to display the arraylist i.e the values for a particular key in a hashmap in java??
upvote count: 1
has comment: http://stackoverflow.com/comment/2645383
has title: Given a key, how to display the ArrayList stored as the value?
favorite count: 0
has answer: http://stackoverflow.com/a/2632051

http://stackoverflow.com/a/2712504
type: Answer
answers question: http://stackoverflow.com/q/2712414
downvote count: 0
score: 7
has body: easy just have one method return an array or some collection of JLabels and add all of them to your JComponent (e.g. a JPanel) class MyPanel extends JPanel{ public MyPanel(){ super(); showGUI(); } private JLabel[] createLabels(){ JLabel[] labels=new JLabel[10] for (int i=0;i&lt;10;i++){ labels[i]=new JLabel("message" + i); } return labels; } private void showGUI(){ JLabel[] labels=createLabels(); for (int i=0;i&lt;labels.length();i++){ this.add(labels[i]); } } }
upvote count: 7

http://stackoverflow.com/comment/2630179
comment on: http://stackoverflow.com/a/2615201
has text: Exactly. The major issue is that when moving from one environment to another is that the test data used in environment A is not available in environment B.In addition the data within each environment is transient; it may be purged after a couple of months. So what I essentially would like to be doing is have the tests describe the type of data it needs and have some other component find data to match and provide it. For example I need an account with a login to the website with branding for partner abc. I’m only describing what I need and not hard-coding data. I think aop addresses this nicely
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/2754914
score: 4
has text: If you're working with dates a lot, I find Joda Time to be far better than Java's Date and Calendar classes: http://joda-time.sourceforge.net/
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/2727698

http://stackoverflow.com/comment/2727997
type: Comment
has text: Moreover, it may be that Go programs in The Computer Language Benchmarks Game are not that optimized as C and Java ones are.
comment on: http://stackoverflow.com/a/2704455
type: AnswerComment
score: 7

http://stackoverflow.com/q/2641338
tagged with: tomcat
has answer: http://stackoverflow.com/a/29932010
tagged with: wicket
upvote count: 40
tagged with: deployment
answer count: 4
accepted answer: http://stackoverflow.com/a/2641393
favorite count: 0
linked to: http://stackoverflow.com/q/24336386
has body: I've deployed an Apache Wicket web-application that uses Spring and Hibernate to my Tomcat 5.5 instance. When I navigate to the Tomcat Manager interface I see that the web-application I deployed is not running. When I press 'Start' I get the following error message; "FAIL - Application at context path /spaghetti could not be started". My catalina.log contains the following: Apr 15, 2010 1:51:22 AM org.apache.catalina.loader.WebappClassLoader validateJarFile INFO: validateJarFile(/var/lib/tomcat5.5/webapps/spaghetti/WEB-INF/lib/jsp-api-6.0.16.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/jsp/JspPage.class Apr 15, 2010 1:51:22 AM org.apache.catalina.loader.WebappClassLoader validateJarFile INFO: validateJarFile(/var/lib/tomcat5.5/webapps/spaghetti/WEB-INF/lib/servlet-api-6.0.16.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class Apr 15, 2010 1:51:24 AM org.apache.catalina.core.StandardContext start SEVERE: Error listenerStart Apr 15, 2010 1:51:24 AM org.apache.catalina.core.StandardContext start SEVERE: Context [/spaghetti] startup failed due to previous errors Excerpt from web.xml: &lt;listener> &lt;listener-class> org.springframework.web.context.ContextLoaderListener &lt;/listener-class> &lt;/listener> Any help is greatly appreciated.
tagged with: spring
has answer: http://stackoverflow.com/a/27693579
has answer: http://stackoverflow.com/a/2641393
type: AnsweredQuestion
downvote count: 0
tagged with: java
possible better answer: http://stackoverflow.com/a/14494410
score: 40
has answer: http://stackoverflow.com/a/14494410
type: Question
has title: How to resolve Error listenerStart when deploying web-app in Tomcat 5.5?
has comment: http://stackoverflow.com/comment/55131626

http://stackoverflow.com/a/6971241
answers question: http://stackoverflow.com/q/2773824
has comment: http://stackoverflow.com/comment/63626162
downvote count: 1
has body: Basically in HashMap, user has to provide both Key and Value, whereas in HashSet you provide only Value, the Key is derived automatically from Value by using hash function. So after having both Key and Value, HashSet can be stored as HashMap internally.
score: -1
upvote count: 0
type: Answer

http://stackoverflow.com/q/2631617
tagged with: java
has answer: http://stackoverflow.com/a/2632422
tagged with: integration-testing
has title: Is there a Java Package for testing RESTful APIs?
has answer: http://stackoverflow.com/a/2634554
type: Question
tagged with: testing
score: 5
accepted answer: http://stackoverflow.com/a/2632422
upvote count: 5
answer count: 6
has body: I'm getting ready to dive into testing of a RESTful service. The majority of our systems are built in Java and Eclipse, so I'm hoping to stay there. I've already found rest-client (http://code.google.com/p/rest-client/) for doing manual and exploratory testing, but is there a stack of java classes that may make my life easier? I'm using testNG for the test platform, but would love helper libraries that can save me time. I've found http4e (http://www.ywebb.com/) but I'd really like something FOSS.
downvote count: 0
tagged with: testng
favorite count: 0
possible better answer: http://stackoverflow.com/a/6112748
has answer: http://stackoverflow.com/a/2637944
has answer: http://stackoverflow.com/a/6112748
has answer: http://stackoverflow.com/a/27085283
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/12463439

http://stackoverflow.com/a/2616310
answers question: http://stackoverflow.com/q/2616227
has body: Check out java.lang.ThreadLocal class.
type: Answer
score: 0

http://stackoverflow.com/q/2744684
has answer: http://stackoverflow.com/a/2744784
accepted answer: http://stackoverflow.com/a/2744784
has answer: http://stackoverflow.com/a/2745657
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2773918
upvote count: 3
tagged with: java
has comment: http://stackoverflow.com/comment/2773862
tagged with: swing
type: Question
has title: can't show JTable
score: 3
tagged with: jtable
has body: I'm having small problem (I guess) of showing the JTable panel. I have class contains Object array with: public class Item { String itemDesc = ""; float price = 0; private itemType enmItemType; Object[][] data = {{itemDesc, enmItemType , new Float(price)}}; . . . . } here is the Table class contains the JTable: class Table extends JFrame { // Instance attributes used in this example private JPanel topPanel; private JTable table; private JScrollPane scrollPane; private JButton update_Button; // Constructor of main frame public Table() { // Set the frame characteristics setTitle("Add new item" ); setSize(300, 200); setBackground( Color.gray ); // Create a panel to hold all other components topPanel = new JPanel(); topPanel.setLayout( new BorderLayout() ); getContentPane().add( topPanel ); // Create columns names String columnNames[] = {"Item Description", "Item Type", "Item Price"}; // Create some data Object dataValues[][] ; Item itm = new Item(); dataValues = itm.data; // Create a new table instance table = new JTable( dataValues, columnNames ); //////////////////////////// JComboBox itemTypeCombobox = new JComboBox(); TableColumn column1 = table.getColumnModel().getColumn(1); column1.setCellEditor(new DefaultCellEditor(itemTypeCombobox)); //////////////////////////// // Add the table to a scrolling pane scrollPane = new JScrollPane( table ); topPanel.add( scrollPane, BorderLayout.CENTER ); JButton button = new JButton("Add Item"); topPanel.add( button, BorderLayout.SOUTH ); } } The main program is: public static void main(String[] args) { Menu m = new Menu(); m.chooseMenu(); // Create an instance of the test application Table mainFrame = new Table(); mainFrame.setVisible( true ); } I did not receive any error/warning, but still, I don't see any table. Can someone direct me what causing the problem? Thanks.
possible better answer: http://stackoverflow.com/a/2745657
answer count: 2
downvote count: 0
favorite count: 0

http://stackoverflow.com/comment/18158861
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/13292073
type: Comment
has text: I could see an alternative of creating a CagedAnimal inteface that extends the Animal interface. You could then create a CagedDog that implements CagedAnimal and extends Dog. This would present some ickyness on type checking (you can't just accept an Animal type, you have to accept a CagedAnimal), but it is a doable solution. I still don't think it is worth it though. A factory that uses instanceof seems like the simplest solution.

http://stackoverflow.com/a/2707545
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2707541
has body: Because HashMap/Hashtable will lookup object by hashCode() first. If they are not the same, hashmap will assert object are not the same and return not exists in the map.
upvote count: 12
score: 12

http://stackoverflow.com/comment/2780904
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2750612
score: 0
has text: Is this a corporate web site ? If so you could simply deploy the new version and point your DNS to the new one or the old one.

http://stackoverflow.com/comment/2660686
has text: That is true... but it makes it difficult to discern which are not progressing due to stability, vs which no longer receive any bug fixes or support for new extensions.
type: AnswerComment
score: 1
type: Comment
comment on: http://stackoverflow.com/a/2641267

http://stackoverflow.com/a/2640416
type: Answer
score: 2
has body: The question is a bit broad and there are several ways to implement this but I would: Use Spring to inject Hibernate SessionFactory into DAOs objects. Use Spring to inject DAOs in a service object and call them inside a business method. Use Spring declarative transaction management at the business method level (either with Spring AOP or @Transactional). Something like this: @Transactional public void doSomething() { dao1.foo(); dao2.bar(); } For more details on the configuration, check the Chapter 9. Transaction management of the Spring documentation.
downvote count: 0
upvote count: 2
answers question: http://stackoverflow.com/q/2639729

http://stackoverflow.com/a/2644257
type: Answer
accepted answer of: http://stackoverflow.com/q/2644167
has comment: http://stackoverflow.com/comment/2659269
answers question: http://stackoverflow.com/q/2644167
has body: Why don't you use JNA? It's much simpler compared to JNI.
score: 0
type: AcceptedAnswer

http://stackoverflow.com/q/2666865
tagged with: stream
type: AnsweredQuestion
tagged with: java
tagged with: h2
tagged with: database
type: Question
upvote count: 2
answer count: 2
possible better answer: http://stackoverflow.com/a/2668977
has title: How to get stream to "in-memory" database created via H2DB?
has answer: http://stackoverflow.com/a/2668977
favorite count: 0
score: 2
has answer: http://stackoverflow.com/a/3763788
accepted answer: http://stackoverflow.com/a/3763788
downvote count: 0
has body: I have to create such a mechanism: Create in-memory (H2DB) database; Create tables and fill them using some data; Get stream to that database; Send that stream via WebDAV or something else; I know everything except that "How to get stream to "in-memory" database created via H2DB"? And some explanations: I can't create file because of some server restrictions; I need that stream to create a file;

http://stackoverflow.com/comment/2729777
has text: How could we know if there is a simpler way if you don't show us some of your code?
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2706054

http://stackoverflow.com/a/2739605
score: 9
upvote count: 9
downvote count: 0
answers question: http://stackoverflow.com/q/2739539
has comment: http://stackoverflow.com/comment/2769089
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2739539
has comment: http://stackoverflow.com/comment/2768276
has body: The -Xmx argument defines the max memory size that the heap can reach for the JVM. You must know your program well and see how it performs under load and set this parameter accordingly. A low value can cause an OutOfMemoryException or very poor performance if your program's heap memory is reaching the maximum heap size. If your program is running on a dedicated server you can set this parameter higher because it wont affect other programs. The -Xms argument sets the initial and minimum heap memory size for the JVM. This means that when you start your program the JVM will allocate this amount of memory instantly. This is useful if your program will consume a large amount of heap memory right from the start. This avoids the JVM needing to regularly increase the heap size and so you can gain some performance there. If you don't know if this parameter is going to help you, don't use it. It is good practice with server-side Java applications like Resin to set the minimum -Xms and maximum -Xmx heap sizes to the same value. You can set to 256 or 512Mb.
type: Answer
has comment: http://stackoverflow.com/comment/2768465
has comment: http://stackoverflow.com/comment/2771184

http://stackoverflow.com/a/2752234
has comment: http://stackoverflow.com/comment/2782817
downvote count: 0
answers question: http://stackoverflow.com/q/2752226
score: 1
upvote count: 1
has body: No, unfortunately, for the same reason why you cannot enumerate regular classes in a package. Inner classes are really just ordinary classes at runtime. The compiler does some tweaking to get around the usual access rules, For example, the inner class appears to be able to access private fields and methods of the enclosing class - it can do this because the compiler creates a non-private accessor function that is used by the inner class. See Java in a Nutshell - how inner classes work for details. Inner classes are regular classes, and these can't be reliably enumerated, so the general answer is no, not possible. However, it can be solved in specific cases. If you know the JARs you are using, then you can iterate across all files in the JAR, looking for files of the pattern yourpakage.YourClass$&lt;something&gt;.class where &lt;something&gt; is one or more characters. EDIT: There are various types of inner class: declared members, such as interfaces and classes Anonymous classes and local classes If you only care about the first case, then BalusC's answer using getDeclaredClasses is the correct one. If you want all inner classes, then getDeclaredClasses unfortunately won't work. See SDN Bug 4191731. In that case, you might try one of the class enumeation methods proposed in the link (such as scanning the JAR file.)
has comment: http://stackoverflow.com/comment/2782812
type: Answer

http://stackoverflow.com/comment/2622269
type: QuestionComment
comment on: http://stackoverflow.com/q/2611573
type: Comment
has text: See http://stackoverflow.com/questions/2611573#2611589 why recursion is plain wrong for this problem.
score: 1

http://stackoverflow.com/comment/2640425
score: 2
type: Comment
has text: JavaScript is supported by lots of web browsers. That doesn't stop it being a perfectly capable server side language. http://en.wikipedia.org/wiki/Server-side_JavaScript
type: QuestionComment
comment on: http://stackoverflow.com/q/2627237

http://stackoverflow.com/a/2770302
answers question: http://stackoverflow.com/q/2768086
upvote count: 1
score: 1
has body: You can add them to classpath with -cp e.g. groovysh -cp some.jar:another.jar
downvote count: 0
type: Answer

http://stackoverflow.com/comment/2698767
type: Comment
comment on: http://stackoverflow.com/a/2679164
score: 0
type: AnswerComment
has text: Ah! The return null was the part I was missing! I've done that, and indeed it is no longer entering the infinite loop. However, DriverManager is failing to find a driver capable of handling the mysql connection. Do I need to require users to include Class.forName("com.mysql.jdbc.Driver").newInstance(); before calling my driver?

http://stackoverflow.com/q/2666734
score: 1
has title: Generating a Call Hierarchy for dynamicly invoked method
tagged with: java
upvote count: 1
type: Question
tagged with: dynamic-invoke
tagged with: profiler
tagged with: ctags
has answer: http://stackoverflow.com/a/2667154
accepted answer: http://stackoverflow.com/a/2667154
answer count: 1
downvote count: 0
has body: Today's world of dynamic invoke, reflection and runtime injection just doesn't play well with traditional tools such as ctags, doxygen and CDOC. I am searching for a method call hierarchy visualization tool that can display both static and dynamic method invocations. It should be easy to use, light during execution and provide helpful detailed information about the recorded runtime session. Now I guess Callgrind could be considered a valid solution for the family C. What tool / technique could you suggest to create a call graph for both static and dynamic method invocation for JVM based bytecode? The intended end result is a graphical display (preferably interactive) which can show path from main() to each method that was invoked. During research for this post I stumbled upon javashot, it seems that this is the kind of approach I'm aiming at, I would prefer that this would be integrated into a kind of profiler or alike which than can be used from within my IDE (Eclipse, IntelliJ, Netbeans and alike). Thank you, Maxim.
favorite count: 0
type: AnsweredQuestion

http://stackoverflow.com/a/4806860
downvote count: 0
has body: Just for the record you may try this approach: declare the reloadableResourceBundle bean with basename='messages' .properties extension is assumed and not required inject this as reference into your bean create messages.properties file and place your stuff in it copy messages.properties into yourProject/web/messages.properties lay back and enjoy Explanation: Spring reloadable message bundle doesn't use class path as it get's cached by app servers. You may circumvent this by classpath:your.properies but then again you may as well use the non reloadable version which is a few ticks faster. In other words the trick is to use the webApp directory which doesn't get cached. You may place your files under yourProject/web or anywhere below as long as you let the loader know. place this in webapp-config.xml &lt;bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"&gt; &lt;property name="basename" value="message"/&gt; &lt;property name="cacheSeconds" value="1"/&gt; &lt;/bean&gt; and this is your bean: public class YouBeanWithMsgReloadableResourceBundle { public void yourMethod(){ String msg = ms.getMessage("your.memo.nic", null, "your default message", Locale.CANADA); } @Autowired MessageSource ms;} And since JSF2 is really cool stuff you may want to use this in a faces context then: public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException { MessageSource ms = FacesContextUtils.getWebApplicationContext(context).getBean(MessageSource.class); String msg = ms.getMessage("your.memo.nic", null, "your default message", Locale.CANADA); }
has comment: http://stackoverflow.com/comment/38198931
has comment: http://stackoverflow.com/comment/5350153
upvote count: 2
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2732280
type: Answer
answers question: http://stackoverflow.com/q/2732280
score: 2

http://stackoverflow.com/q/2707541
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/2707554
has comment: http://stackoverflow.com/comment/2731438
has answer: http://stackoverflow.com/a/2707548
tagged with: equals
has body: I have heard from many places and sources that whenever I override the equals() method, I need to override the hashCode() method as well. But consider the following piece of code package test; public class MyCustomObject { int intVal1; int intVal2; public MyCustomObject(int val1, int val2){ intVal1 = val1; intVal2 = val2; } public boolean equals(Object obj){ return (((MyCustomObject)obj).intVal1 == this.intVal1) &amp;&amp; (((MyCustomObject)obj).intVal2 == this.intVal2); } public static void main(String a[]){ MyCustomObject m1 = new MyCustomObject(3,5); MyCustomObject m2 = new MyCustomObject(3,5); MyCustomObject m3 = new MyCustomObject(4,5); System.out.println(m1.equals(m2)); System.out.println(m1.equals(m3)); } } Here the output is true, false exactly the way I want it to be and I dont care of overriding the hashCode() method at all. This means that hashCode() overriding is an option rather being a mandatory one as everyone says.
answer count: 5
has answer: http://stackoverflow.com/a/42878986
type: AnsweredQuestion
tagged with: hashcode
has comment: http://stackoverflow.com/comment/2731515
tagged with: java
score: 36
has answer: http://stackoverflow.com/a/8391336
type: Question
has comment: http://stackoverflow.com/comment/137393452
has answer: http://stackoverflow.com/a/2707554
upvote count: 36
linked to: http://stackoverflow.com/q/371328
possible better answer: http://stackoverflow.com/a/2707545
has title: Why should I override hashCode() when I override equals() method?
has answer: http://stackoverflow.com/a/2707545

http://stackoverflow.com/q/2752171
favorite count: 0
has title: Do the Java platform libraries support https
upvote count: 1
accepted answer: http://stackoverflow.com/a/2752186
type: AnsweredQuestion
tagged with: apache-commons
score: 1
tagged with: java
tagged with: https
type: Question
has comment: http://stackoverflow.com/comment/2782752
possible better answer: http://stackoverflow.com/a/2752181
has answer: http://stackoverflow.com/a/2752186
has body: All I need to to do is to connect via https. Must I use commons client for this?
has answer: http://stackoverflow.com/a/2752181
answer count: 2
downvote count: 0

http://stackoverflow.com/comment/2683725
score: 0
type: AnswerComment
has text: Thank you very much for your valuable insights and the side note on pricing as well! You helped me a lot.
type: Comment
comment on: http://stackoverflow.com/a/2639935

http://stackoverflow.com/q/2620728
favorite count: 0
has comment: http://stackoverflow.com/comment/2633218
tagged with: sql
upvote count: 5
downvote count: 0
accepted answer: http://stackoverflow.com/a/2626030
type: AnsweredQuestion
has title: JPA : Inheritance - Discriminator value not taken into account in generated SQL
tagged with: java
tagged with: hibernate
has answer: http://stackoverflow.com/a/2626030
type: Question
has body: I try to use this mapping : @Entity @Table(name="ecc.\"RATE\"") @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name="DISCRIMINATOR", discriminatorType= DiscriminatorType.STRING) public abstract class Rate extends GenericBusinessObject { ... } @Entity @DiscriminatorValue("E") public class EntranceRate extends Rate { @ManyToOne @JoinColumn(name = "\"RATES_GRID_ID\"") protected RatesGrid ratesGrid; ... } @Entity @Table(name="ecc.\"RATES_GRID\"") public class RatesGrid extends GenericBusinessObject { /** */ @OneToMany(mappedBy = "ratesGrid", targetEntity = EntranceRate.class, fetch=FetchType.LAZY) private List&lt;EntranceRate&gt; entranceRates; } When I try to access my entranceRates list from a ratesGrid object, I get this error : Object with id: 151 was not of the specified subclass: com.ecc.bo.rate.EntranceRate (loaded object was of wrong class class com.ecc.bo.rate.AnnualRate) Looking at the sql generated, I found no trace of "discriminator=" in the where clause. What am I doing wrong ? I use a PostGreSQL database and a Hibernate as JPA provider.
score: 5
tagged with: jpa
answer count: 1
tagged with: inheritance

http://stackoverflow.com/a/2636205
has comment: http://stackoverflow.com/comment/2658179
has comment: http://stackoverflow.com/comment/2658194
type: Answer
score: 3
upvote count: 3
has body: Since it would be misleading as Omry already mentioned, why not use org.lbownik.util.linkset?
downvote count: 0
has comment: http://stackoverflow.com/comment/2658728
answers question: http://stackoverflow.com/q/2636080

http://stackoverflow.com/q/2688099
tagged with: multithreading
tagged with: timestamp
type: Question
tagged with: java
score: 15
answer count: 1
has answer: http://stackoverflow.com/a/2688143
has comment: http://stackoverflow.com/comment/2709596
accepted answer: http://stackoverflow.com/a/2688143
has body: I want to count the time elapsed between two events in nanoseconds. To do that, I can use System.nanoTime() as mentioned here. The problem is that the two events are happening in different threads. Since nanoTime() doesn't return an absolute timestamp but instead can only be used to calculate time differences, I'd like to know if the values I get on the two different threads are consistent with the physical time elapsed between the two events.
favorite count: 0
linked to: http://stackoverflow.com/q/510462
tagged with: nanotime
upvote count: 15
type: AnsweredQuestion
has title: Is System.nanoTime() consistent across threads?
downvote count: 0

log4j
tags question: http://stackoverflow.com/q/2781440
tags question: http://stackoverflow.com/q/2619160
tags question: http://stackoverflow.com/q/2713148
tags question: http://stackoverflow.com/q/2746578
tags question: http://stackoverflow.com/q/2635720
tags question: http://stackoverflow.com/q/2750545
tag name: log4j
tags question: http://stackoverflow.com/q/2619116
tags question: http://stackoverflow.com/q/2716824
tags question: http://stackoverflow.com/q/2732981
tags question: http://stackoverflow.com/q/2763925
tags question: http://stackoverflow.com/q/2621701
tags question: http://stackoverflow.com/q/2724341
tags question: http://stackoverflow.com/q/2763416
tags question: http://stackoverflow.com/q/2645670
tags question: http://stackoverflow.com/q/2763740
tags question: http://stackoverflow.com/q/2770382
type: Tag
tags question: http://stackoverflow.com/q/2656159
tags question: http://stackoverflow.com/q/2739620

http://stackoverflow.com/comment/2814991
type: AnswerComment
type: Comment
has text: @Tom: Surely in 99.9% of the cases it won't be. But it is easy enough to construct cases (e.g. reflecting on the interfaces) where it could break. Taking into account that basically EVERY application uses String somewhere that still might be a reason.
comment on: http://stackoverflow.com/a/2772610
score: 0

http://stackoverflow.com/comment/2758708
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2726328
has text: Hmm, there was no hprof file in the current directory of the process. Since jvisualvm sets a heapdump file name in a different directory, I suppose jconsole does too?
type: AnswerComment

http://stackoverflow.com/comment/2805663
score: 0
comment on: http://stackoverflow.com/a/2771923
type: AnswerComment
has text: Who said he needed it for business logic?
type: Comment

http://stackoverflow.com/comment/112091192
type: Comment
comment on: http://stackoverflow.com/a/51708807
score: 1
type: AnswerComment
has text: This is the best choice I guess, to store the content in a separate file instead of in java source code itself.

http://stackoverflow.com/comment/2610153
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2600648
has text: @OMG Unicorns: Looks like the Z time zone format doesn't support the literal "Z" bizarrely enough. I've set it explicitly...

http://stackoverflow.com/a/2646830
type: Answer
upvote count: 1
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/2646773
has body: Why would you use a regex for that? Just use String.charAt(...) and substring(...)!

http://stackoverflow.com/a/2754309
has comment: http://stackoverflow.com/comment/2785314
type: Answer
answers question: http://stackoverflow.com/q/2754272
downvote count: 0
has body: You'd have JSP enter the info into a form and POST it to a servlet. The servlet would validate the form input, instantiate the bean, add it to session, and redirect the response to the second JSP to display. You need a servlet in-between. JSPs using JSTL are for display; using the servlet this way is called MVC 2. Another way to think of it is the front controller pattern, where a single servlet handles all mapped requests and simply routes them to controllers/handlers.
score: 2
has comment: http://stackoverflow.com/comment/2786352
upvote count: 2

http://stackoverflow.com/comment/2622903
score: 0
comment on: http://stackoverflow.com/a/2612141
type: Comment
has text: Thread 5 will never "find" 4 - its only purpose is to remove all multiples of 5. Once all of the worker threads have finished removing non-primes, the main thread will "find" the remaining numbers.
type: AnswerComment

http://stackoverflow.com/comment/2764096
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2735845
type: AnswerComment
has text: @andy Works the same for objects.

http://stackoverflow.com/comment/2793359
score: 0
comment on: http://stackoverflow.com/a/2761303
type: Comment
has text: Appreciated, but I'm fairly locked into Java and the source code is not my own.
type: AnswerComment

http://stackoverflow.com/a/41024760
type: Answer
score: 0
has body: Proposed solution does not work in Android as it is stuck on Java 7 and so Calendar is buggy. Others solutions also had bugs because they did not take into account TimeZone offset, or have problems with int overflow before they get converted to long. This solution seems to work: public static final long MILLISECONDS_PER_DAY=(1000L * 60L * 60L * 24L); public static long convertDate(Date d) { TimeZone tz = TimeZone.getDefault(); long val = d.getTime() + tz.getOffset(d.getTime()); /*local timezone offset in ms*/ return val / MILLISECONDS_PER_DAY; } public static Date convertDate(long date) { TimeZone tz = TimeZone.getDefault(); Date d=new Date(); d.setTime(date*MILLISECONDS_PER_DAY-tz.getOffset(d.getTime())); return d; }
answers question: http://stackoverflow.com/q/2775411

http://stackoverflow.com/a/2599640
has comment: http://stackoverflow.com/comment/2628278
answers question: http://stackoverflow.com/q/2599499
has comment: http://stackoverflow.com/comment/2608436
has body: Just do iterative deepening search. void comb(int... items) { Arrays.sort(items); for (int k = 1; k &lt;= items.length; k++) { kcomb(items, 0, k, new int[k]); } } public void kcomb(int[] items, int n, int k, int[] arr) { if (k == 0) { System.out.println(Arrays.toString(arr)); } else { for (int i = n; i &lt;= items.length - k; i++) { arr[arr.length - k] = items[i]; kcomb(items, i + 1, k - 1, arr); } } } Then call, say, comb(10,20,30). It will print: [10] [20] [30] [10, 20] [10, 30] [20, 30] [10, 20, 30]
upvote count: 9
downvote count: 0
has comment: http://stackoverflow.com/comment/2608423
score: 9
type: Answer

http://stackoverflow.com/comment/2621339
score: 7
has text: Stop trying to put multiple things on a line. As much as anything, this is what caused your problem. Once you get in a habit of writing clearly, you'll find this kind of thing happens much less. Also set your warnings in eclipse higher--it should have pointed out the empty statement to you. Don't just address this problem, fix the root causes.
comment on: http://stackoverflow.com/q/2610679
type: QuestionComment
type: Comment

http://stackoverflow.com/comment/2621890
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2611015
has text: @mmyers: good idea @Eval: thanks, also tried myself on the mac 1.6 jdk - same error
score: 0

http://stackoverflow.com/q/2657619
tagged with: mtj
score: 1
tagged with: java
tagged with: eclipse
type: Question
accepted answer: http://stackoverflow.com/a/2657709
answer count: 1
downvote count: 0
linked to: http://stackoverflow.com/q/2639730
tagged with: java-me
favorite count: 0
has answer: http://stackoverflow.com/a/2657709
upvote count: 1
has body: Please tell me how can i activate the Sun JavaME memory monitor within eclipse mtj. Thank you.
has title: eclipse mtj memory monitor
type: AnsweredQuestion

dialog
tag name: dialog
tags question: http://stackoverflow.com/q/2715004
tags question: http://stackoverflow.com/q/2629031
type: Tag
tags question: http://stackoverflow.com/q/2632785
tags question: http://stackoverflow.com/q/2774446

http://stackoverflow.com/comment/2796709
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2763647
has text: How are you the only one to think of this? How did the others get so many votes??
score: 0

http://stackoverflow.com/q/2724035
has body: I would like to know what's the best approach to test the method "pushEvent()" in the following class with a jUnit test. My problem is, that the private method "callWebsite()" always requires a connection to the network. How can I avoid this requirement or refactor my class that I can test it without a connection to the network? class MyClass { public String pushEvent (Event event) { //do something here String url = constructURL (event); //construct the website url String response = callWebsite (url); return response; } private String callWebsite (String url) { try { URL requestURL = new URL (url); HttpURLConnection connection = null; connection = (HttpURLConnection) requestURL.openConnection (); String responseMessage = responseParser.getResponseMessage (connection); return responseMessage; } catch (MalformedURLException e) { e.printStackTrace (); return e.getMessage (); } catch (IOException e) { e.printStackTrace (); return e.getMessage (); } } }
tagged with: java
has answer: http://stackoverflow.com/a/2724164
tagged with: unit-testing
type: Question
accepted answer: http://stackoverflow.com/a/2724119
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2724099
has title: How to write a jUnit test for a class that uses a network connection
tagged with: tdd
possible better answer: http://stackoverflow.com/a/2724099
tagged with: junit
downvote count: 0
has answer: http://stackoverflow.com/a/2724492
favorite count: 0
score: 28
upvote count: 28
has answer: http://stackoverflow.com/a/2724228
has answer: http://stackoverflow.com/a/2724119
answer count: 5
linked to: http://stackoverflow.com/q/22697

http://stackoverflow.com/a/2764608
has comment: http://stackoverflow.com/comment/62592645
has comment: http://stackoverflow.com/comment/2797150
type: AcceptedAnswer
downvote count: 0
upvote count: 8
type: Answer
score: 8
has comment: http://stackoverflow.com/comment/2797650
has body: Try to have the pointcut and advice inside the &lt;aop:aspect&gt; element. Something like this: &lt;aop:config&gt; &lt;aop:aspect id="aspect1" ref="springBean"&gt; &lt;aop:pointcut expression="execution(......)" id="pointcutOne" /&gt; &lt;aop:around pointcut-ref="pointcutOne" method="commonMethod" /&gt; &lt;/aop:aspect&gt; &lt;aop:aspect id="aspect2" ref="springBean"&gt; &lt;aop:pointcut expression="execution(.....)" id="pointcurTwo" /&gt; &lt;aop:around pointcut-ref="pointcutTwo" method="commonMethod" /&gt; &lt;/aop:aspect&gt; &lt;/aop:config&gt; I guess your XML configuration resulted in just one proxy object, while it should have been two proxy objects. Btw: You should consider using @AspectJ syntax instead. It's just Java with pointcuts and advices in annotations. It works well with Spring AOP and offers more functionality than the XML alternative. All you need in your configuration to enable @AspectJ aspects with Spring AOP: &lt;aop:aspectj-autoproxy&gt; &lt;aop:include name="aspect1" /&gt; &lt;aop:include name="aspect2" /&gt; &lt;/aop:aspectj-autoproxy&gt; &lt;bean id="aspect1" class="com.demo.Aspect1"/&gt; &lt;bean id="aspect2" class="com.demo.Aspect2"/&gt; And the Aspect could be something like this: @Aspect public class Aspect1 { @Pointcut("execution(* *(..))") public void demoPointcut() {} @Around("demoPointcut()") public void demoAdvice(JoinPoint joinPoint) {} } Updated: Example that uses a pointcut to combine three other pointcuts: @Pointcut("traceMethodsInDemoPackage() &amp;&amp; notInTestClass() " + "&amp;&amp; notSetMethodsInTraceDemoPackage()") public void filteredTraceMethodsInDemoPackage() {}
accepted answer of: http://stackoverflow.com/q/2763646
has comment: http://stackoverflow.com/comment/2797009
has comment: http://stackoverflow.com/comment/54688199
answers question: http://stackoverflow.com/q/2763646

http://stackoverflow.com/a/2844575
upvote count: 2
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2775349
type: Answer
has body: You could iterate through the RDF statements and populate your JAXB beans via a Bean population utility like BeanUtils. Iterate the statements in such a form that statements with the same subject are processed in a group. The rdf:type statements define which Class to instantiate and the rest can be probably mapped to properties of the created beans. If you are familiar with Java reflection then this is probably quite straightforward.
accepted answer of: http://stackoverflow.com/q/2775349
score: 2

http://stackoverflow.com/q/2715613
tagged with: midi
has comment: http://stackoverflow.com/comment/2741626
has answer: http://stackoverflow.com/a/6723848
tagged with: sequence
upvote count: 2
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/2741472
has title: MidiSystem.getSequencer() returns Audio Device Unavailable
score: 2
tagged with: java
has answer: http://stackoverflow.com/a/2716261
type: Question
has answer: http://stackoverflow.com/a/12429971
downvote count: 0
favorite count: 0
tagged with: runtime-error
has body: I've keep having an exception thrown, on and on. When i try to make a new Sequencer object, i keep getting the javax.sound.midi.MidiUnavailableException: Audio Device Unavailable exception. So, here's the code: import javax.sound.midi.*; public class MiniMusicPlayer1 { public static void main(String[] args) { try { Sequencer sequencer = MidiSystem.getSequencer(); sequencer.open(); Sequence seq = new Sequence(Sequence.PPQ, 4); Track track = seq.createTrack(); for (int i = 5; i &lt; 61; i += 4) { track.add(makeEvent(144, 1, i, 100, i)); track.add(makeEvent(128, 1, i, 100, (i+2))); } sequencer.setSequence(seq); sequencer.setTempoInBPM(220); sequencer.start(); } catch (Exception e) { e.printStackTrace(); } } public static MidiEvent makeEvent(int comd, int chan, int one, int two, int tick) { MidiEvent event = null; try { ShortMessage a = new ShortMessage(); a.setMessage(comd, chan, one, two); event = new MidiEvent(a, tick); } catch (Exception e) { e.printStackTrace(); } return event; } } And here's the complete error (at compile): javax.sound.midi.MidiUnavailableException: Audio Device Unavailable at com.sun.media.sound.MixerSynth.implOpen(MixerSynth.java:165) at com.sun.media.sound.AbstractMidiDevice.doOpen(AbstractMidiDevice.java:144) at com.sun.media.sound.AbstractMidiDevice.openInternal(AbstractMidiDevice.java:134) at com.sun.media.sound.AbstractMidiDevice.getReceiverReferenceCounting(AbstractMidiDevice.java:339) at javax.sound.midi.MidiSystem.getReceiver(MidiSystem.java:243) at javax.sound.midi.MidiSystem.getSequencer(MidiSystem.java:442) at javax.sound.midi.MidiSystem.getSequencer(MidiSystem.java:348) at MiniMusicPlayer1.main(MiniMusicPlayer1.java:9) First i was unable to play MIDI files on my pc, but then i got it to work, so now i can play MIDI files, that's okay. I tried even to close every process which uses my sound card, but the error is still there. Anyone can help me?
answer count: 3

http://stackoverflow.com/comment/2666391
score: 0
has text: @Dave Jarvis, it is certainly a reasonable alternative, but I think the above represents the "standard" best practice. But as long as you log the exception, then I think it doesn't really matter.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2649342

http://stackoverflow.com/q/2656059
has comment: http://stackoverflow.com/comment/2673322
answer count: 10
has answer: http://stackoverflow.com/a/2658306
upvote count: 12
has body: Is there any Java profiler that allows profiling short-lived applications? The profilers I found so far seem to work with applications that keep running until user termination. However, I want to profile applications that work like command-line utilities, it runs and exits immediately. Tools like visualvm or NetBeans Profiler do not even recognize that the application was ran. I am looking for something similar to Python's cProfile, in that the profiler result is returned when the application exits.
has answer: http://stackoverflow.com/a/2656786
has title: Profiling short-lived Java applications
has comment: http://stackoverflow.com/comment/2674404
tagged with: profiler
has answer: http://stackoverflow.com/a/2656124
tagged with: optimization
has answer: http://stackoverflow.com/a/2656111
type: AnsweredQuestion
tagged with: profiling
has answer: http://stackoverflow.com/a/2658239
downvote count: 0
linked to: http://stackoverflow.com/q/1777556
has answer: http://stackoverflow.com/a/2657451
has answer: http://stackoverflow.com/a/9554074
has answer: http://stackoverflow.com/a/2658192
favorite count: 0
type: Question
has answer: http://stackoverflow.com/a/2656504
possible better answer: http://stackoverflow.com/a/2658192
has answer: http://stackoverflow.com/a/2656544
accepted answer: http://stackoverflow.com/a/2656111
linked to: http://stackoverflow.com/q/2563777
score: 12
tagged with: java
linked to: http://stackoverflow.com/q/266373

.net
tags question: http://stackoverflow.com/q/2759188
tags question: http://stackoverflow.com/q/2633020
tags question: http://stackoverflow.com/q/2725495
tags question: http://stackoverflow.com/q/2664714
tags question: http://stackoverflow.com/q/2753769
tags question: http://stackoverflow.com/q/2597640
tag name: .net
tags question: http://stackoverflow.com/q/2735037
tags question: http://stackoverflow.com/q/2635013
tags question: http://stackoverflow.com/q/2748018
tags question: http://stackoverflow.com/q/2719198
tags question: http://stackoverflow.com/q/2631390
tags question: http://stackoverflow.com/q/2667646
type: Tag
tags question: http://stackoverflow.com/q/2698868
tags question: http://stackoverflow.com/q/2745365
tags question: http://stackoverflow.com/q/2704139
tags question: http://stackoverflow.com/q/2612915
tags question: http://stackoverflow.com/q/2633185
tags question: http://stackoverflow.com/q/2756779
tags question: http://stackoverflow.com/q/2603368
tags question: http://stackoverflow.com/q/2748056
tags question: http://stackoverflow.com/q/2691579
tags question: http://stackoverflow.com/q/2711404
tags question: http://stackoverflow.com/q/2684398
tags question: http://stackoverflow.com/q/2724327

http://stackoverflow.com/comment/2794264
has text: I tried some variations using BoxLayout and BorderLayout and the issue showed up in all cases. Seems like the component's UI under the Windows 7 Look-and-Feel.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2754306

http://stackoverflow.com/comment/2729749
type: Comment
comment on: http://stackoverflow.com/q/2706054
type: QuestionComment
has text: just a GUI implemented in Swing
score: 0

http://stackoverflow.com/a/20681523
has body: you can increase the number of open files limit if you do ulimit -n 2048 the value is changed temporarily, it is reset after reboot you better change it by sudo vi /etc/security/limits.conf and add these lines by replacing the jboss user name user soft nofile 9000 user hard nofile 65000 after that sudo vi /etc/pam.d/common-session and add session required pam_limits.so restart the server and check the limits ulimit -n
answers question: http://stackoverflow.com/q/2613674
score: 0
type: Answer

http://stackoverflow.com/a/2648155
has comment: http://stackoverflow.com/comment/26489860
score: 3
downvote count: 0
has body: After much experimentation and frustration, I eventually determined that I cannot do exactly what I want. Ultimately, I went ahead and gave the child object its own synthetic key and let Hibernate manage it. It's a not ideal, since the key is almost as big as the rest of the data, but it works.
accepted answer of: http://stackoverflow.com/q/2611619
answers question: http://stackoverflow.com/q/2611619
upvote count: 3
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/26940154
type: Answer

http://stackoverflow.com/comment/2794040
comment on: http://stackoverflow.com/a/2757079
score: 0
type: AnswerComment
has text: +1, a link to a tutorial or a specific method is always appreciated. Not only does it provide information to this answer but it provides a resource for potential future problems.
type: Comment

http://stackoverflow.com/q/2686887
possible better answer: http://stackoverflow.com/a/2686917
has title: Java: Possible to consolidate empty subdirectories for packages that only contain other packages?
has comment: http://stackoverflow.com/comment/2707435
has answer: http://stackoverflow.com/a/2686917
tagged with: java
answer count: 2
has body: Good afternoon, all. I'm not too hopeful for a "yes" here, but if anyone can figure it out, the folks at SO can. I have a Java project that has the following package structure: src |-net | |-binarymuse | |-gwt | |-client | | |-ui | | |-project | | |-Project.java | |-Project.gwt.xml |-overview.html I would like to consolidate the empty subdirectories in the src/ folder so that instead of /src/net/binarymuse/gwt/client/ui/project/ I'd have /src/net.binarymuse.gwt/client.ui.project/. Is this possible? Thanks.
upvote count: 1
has comment: http://stackoverflow.com/comment/2707566
has comment: http://stackoverflow.com/comment/2707805
accepted answer: http://stackoverflow.com/a/2686938
tagged with: subdirectory
has comment: http://stackoverflow.com/comment/2708731
type: AnsweredQuestion
downvote count: 0
score: 1
favorite count: 0
type: Question
tagged with: package
has answer: http://stackoverflow.com/a/2686938

http://stackoverflow.com/comment/2615903
score: 0
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/2601169
has text: hmm, I think it's a problem with setting the text. I use setText() but probably i should use insertString(). i'll try that

http://stackoverflow.com/q/2717294
has answer: http://stackoverflow.com/a/2717378
has answer: http://stackoverflow.com/a/2717333
has answer: http://stackoverflow.com/a/2717311
has comment: http://stackoverflow.com/comment/37926047
tagged with: http
has answer: http://stackoverflow.com/a/55232049
has answer: http://stackoverflow.com/a/18746669
has answer: http://stackoverflow.com/a/9777838
linked to: http://stackoverflow.com/q/13155734
has answer: http://stackoverflow.com/a/17622475
has answer: http://stackoverflow.com/a/59196034
has comment: http://stackoverflow.com/comment/101592410
has body: What's the easiest way to create a simple HTTP server with Java? Are there any libraries in commons to facilitate this? I only need to respond to GET/POST, and I can't use an application server. What's the easiest way to accomplish this?
tagged with: post
tagged with: get
type: AnsweredQuestion
score: 68
downvote count: 0
has answer: http://stackoverflow.com/a/2717319
has answer: http://stackoverflow.com/a/2717309
has title: Create a simple HTTP server with Java?
favorite count: 0
has answer: http://stackoverflow.com/a/2717300
type: Question
accepted answer: http://stackoverflow.com/a/2717309
linked to: http://stackoverflow.com/q/640022
linked to: http://stackoverflow.com/q/3732109
has answer: http://stackoverflow.com/a/19372289
answer count: 13
has answer: http://stackoverflow.com/a/2717366
possible better answer: http://stackoverflow.com/a/2717378
linked to: http://stackoverflow.com/q/1186328
upvote count: 68
tagged with: java

http://stackoverflow.com/a/2607409
accepted answer of: http://stackoverflow.com/q/2604875
upvote count: 26
score: 26
has comment: http://stackoverflow.com/comment/30426309
has comment: http://stackoverflow.com/comment/37362855
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2604875
has body: To be precise, it's the content of the test output directory (target/test-classes) that is on the class path, not src/test/resources. But resources under src/test/resources are copied to the test output directory by the resources:testResources goal (which is bound by default to the process-test-resources phase). Having that said, your code looks fine and resources for the test source code should have been copied either by your IDE or by Maven when running tests and should thus be available on the class path. So there must be something else wrong. I can see that your class is a base class for integration tests. Did you configure anything fancy in your pom? Can you show it?
type: Answer

http://stackoverflow.com/comment/2820097
has text: You can databind SWT controls, too. Look at the JFace databinding API.
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/2784780

http://stackoverflow.com/comment/2665340
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2649342
has text: +1 for the `finally`. Surprisingly a lot of answers didn't mention about it. Here are some Sun links of interest: [Lesson: Basic IO](http://java.sun.com/docs/books/tutorial/essential/io/) and [Lesson: Exceptions](http://java.sun.com/docs/books/tutorial/essential/exceptions/index.html)
type: AnswerComment

http://stackoverflow.com/comment/2635725
type: AnswerComment
type: Comment
has text: Huh? Why do you want to reinvent the wheel? At any way: Gson is open source. Take your benefit.
comment on: http://stackoverflow.com/a/2623202
score: 0

http://stackoverflow.com/comment/16340182
type: Comment
has text: String.hashCode() will return int, so == will work fine. In reality, in this example, it will be very rare that same hash code will come for two different Maps. If not hashCode, we can use MD5.
comment on: http://stackoverflow.com/a/11036803
type: AnswerComment
score: 0

http://stackoverflow.com/a/2700277
accepted answer of: http://stackoverflow.com/q/2700047
type: Answer
answers question: http://stackoverflow.com/q/2700047
score: 3
upvote count: 3
has body: Doe Hibernate use cache (second level or otherwise) if all I am doing is batch inserts? Newly inserted Entities instances are cached in the L1 cache (the session-level cache) before they are flushed to the database (see the section 13. Batch processing), hence the need to flush and clear your session regularly to prevent OOM. Also, would StatelessSession vs Session change the answer? Yes. As written in section 13.3. The StatelessSession interface : A StatelessSession has no persistence context associated with it and does not provide many of the higher-level life cycle semantics. In particular, a stateless session does not implement a first-level cache nor interact with any second-level or query cache. What if I was using a Session with a JDBC batch size of 50? This just means that you should flush/clear the session every 50 insert.
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/2636962
has body: Unfortunately, there is no rule for this. You need to refer to the API docs and call super if the docs say you need to. One hint as to whether you'll probably need to or not in Android's case is if the method you're overriding is one of the lifecycle methods. In this case, you can be fairly certain that you need to call super.
type: Answer
upvote count: 1
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/2636906

http://stackoverflow.com/q/2732295
tagged with: interface
possible better answer: http://stackoverflow.com/a/2732352
has comment: http://stackoverflow.com/comment/2760009
has body: I have an assignment and i got a library including an interface class. [InfoItem] I implement this class [Item]. Now i am required to write a method watchProgram(InfoItem item) [other class, importing InfoItem], which (as shown) requires an InfoItem. The passed parameter item has a variable 'Recorded' [boolean] which i want to edit using a method changeRecorded() that i defined in the implementation of InfoItem. I cannot edit the interface and i get an error message that the method is not found [cannot find symbol].. Any hints, suggestions, solutions? Thanks!! -Samuel-
accepted answer: http://stackoverflow.com/a/2732359
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/2732376
tagged with: methods
type: Question
tagged with: implementation
has answer: http://stackoverflow.com/a/2732352
has answer: http://stackoverflow.com/a/2732359
has title: Use method not defined in Interface [Java]
score: 0
answer count: 3

http://stackoverflow.com/q/2779951
has body: I need to translate colors in bitmap loaded to BufferedImage from RGB to YCbCr (luminance and 2 channels chrominance) and back after process. I made it with functions used like rgb2ycbcr() in main method for each pixel, but it isn't so smart solution. I should use ColorSpace and ColorModel classes to get BufferedImage with correct color space. It would be more flexible method, but I don't know how to do that. I'm lost and I need some tips. Can somebody help me?
score: 0
answer count: 1
tagged with: colors
has title: How to work with BufferedImage and YCbCr colorspace?
accepted answer: http://stackoverflow.com/a/2780378
type: AnsweredQuestion
tagged with: java
tagged with: bufferedimage
type: Question
has answer: http://stackoverflow.com/a/2780378

http://stackoverflow.com/a/14753618
upvote count: 3
downvote count: 0
has comment: http://stackoverflow.com/comment/82867898
type: Answer
has comment: http://stackoverflow.com/comment/134484757
has body: The normal guideline is to never test against boolean. Some argue that the additional verbosity adds to clarity. The added code may help some people, but every reader will need to read more code. This morning, I have lost 1/2 hour to find a bug. The code was if ( !strcmp(runway_in_use,"CLOSED") == IPAS_FALSE) printf(" ACTIVE FALSE \n"); else printf(" ACTIVE TRUE \n"); If it was coded with normal convention, I would have seen a lot faster that it was wrong: if (strcmp(runway_in_use, "CLOSED")) printf(" ACTIVE FALSE \n"); else printf(" ACTIVE TRUE \n");
answers question: http://stackoverflow.com/q/2661110
score: 3

http://stackoverflow.com/q/2776168
type: Question
has body: Does anyone have a simple example of how to take a local file and (unicast) stream it with Java JMF? Examples from others seem scarce.
answer count: 2
downvote count: 0
score: 1
has answer: http://stackoverflow.com/a/2776330
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2823172
has title: JMF Output Stream
tagged with: jmf
tagged with: audio
linked to: http://stackoverflow.com/q/2822074
tagged with: java
tagged with: stream
upvote count: 1

http://stackoverflow.com/q/2692095
upvote count: 4
has title: Java/Swing: JTable.rowAtPoint doesn't work correctly for points outside the table?
downvote count: 0
tagged with: swing
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/2692512
accepted answer: http://stackoverflow.com/a/2692512
has body: I have this code to get a row from a JTable that is generated by a DragEvent for a DropTarget in some component C which may or may not be the JTable: public int getRowFromDragEvent(DropTargetDragEvent event) { Point p = event.getLocation(); if (event.getSource() != this.table) { SwingUtilities.convertPointToScreen(p, event.getDropTargetContext().getComponent()); SwingUtilities.convertPointFromScreen(p, this.table); if (!this.table.contains(p)) { System.out.println("outside table, would be row "+this.table.rowAtPoint(p)); } } return this.table.rowAtPoint(p); } The System.out.println is just a hack right now. What I'm wondering, is why the System.out.println doesn't always print "row -1". When the table is empty it does, but if I drag something onto the table's header row, I get the println with "row 0". This seems like a bug... or am I not understanding how rowAtPoint() works?
tagged with: coordinates
type: Question
answer count: 1
score: 4
favorite count: 0

http://stackoverflow.com/comment/2682790
type: QuestionComment
has text: I'm using JAVA2D for drawing... I use Swing objects to make them entities!
comment on: http://stackoverflow.com/q/2664807
score: 1
type: Comment

http://stackoverflow.com/a/2617719
score: 4
has comment: http://stackoverflow.com/comment/2629831
type: Answer
has body: I'm looking for a short and sweet example, that would give some serious headache to work around. You're looking for a simple example of something that would be trivial in one language and difficult to do in Java? How about this one-liner of inlined assembly (inside a C program)? static inline void cpuid(int code, dword *a, dword *d) { asm volatile("cpuid":"=a"(*a),"=d"(*d):"0"(code)); } Good luck Mr Java ;)
has comment: http://stackoverflow.com/comment/2629599
has comment: http://stackoverflow.com/comment/2629569
answers question: http://stackoverflow.com/q/2617662
upvote count: 4
downvote count: 0

http://stackoverflow.com/a/2601182
has comment: http://stackoverflow.com/comment/2610531
type: AcceptedAnswer
downvote count: 0
type: Answer
has body: You can always rely upon the good old java.awt.Robot class, which, i think, has all the features you're asking : moving mouse capturing a Rectangle on screen clicking mouse
has comment: http://stackoverflow.com/comment/2610381
score: 5
upvote count: 5
has comment: http://stackoverflow.com/comment/2610684
accepted answer of: http://stackoverflow.com/q/2601146
answers question: http://stackoverflow.com/q/2601146

code-generation
tag name: code-generation
tags question: http://stackoverflow.com/q/2600474
tags question: http://stackoverflow.com/q/2623726
tags question: http://stackoverflow.com/q/2702315
tags question: http://stackoverflow.com/q/2667993
type: Tag
tags question: http://stackoverflow.com/q/2678748

flash
tags question: http://stackoverflow.com/q/2678091
tags question: http://stackoverflow.com/q/2699488
tags question: http://stackoverflow.com/q/2660198
tags question: http://stackoverflow.com/q/2739329
tags question: http://stackoverflow.com/q/2719039
tags question: http://stackoverflow.com/q/2761928
tags question: http://stackoverflow.com/q/2665974
tags question: http://stackoverflow.com/q/2607442
tags question: http://stackoverflow.com/q/2628054
tags question: http://stackoverflow.com/q/2741843
tag name: flash
tags question: http://stackoverflow.com/q/2621391
type: Tag

http://stackoverflow.com/a/2737545
upvote count: 3
downvote count: 1
score: 2
has comment: http://stackoverflow.com/comment/15377226
has comment: http://stackoverflow.com/comment/2770931
type: Answer
answers question: http://stackoverflow.com/q/2737456
has body: Long lived TCP connections are a bad idea in anything mobile because the network is so spotty. Personally I use UDP or transient HTTP connections with an HTTP session concept.

http://stackoverflow.com/comment/2789905
score: 0
comment on: http://stackoverflow.com/a/2758341
type: Comment
has text: Do you mean to say that any java source code when compiled using 32 bit JDK would run 64 bit JRE?
type: AnswerComment

http://stackoverflow.com/comment/2676790
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2657357
has text: I notiched that \s* detects one or more whitespaces. How do I make it so that it detects only whitespace? For example "test test" would be invalid?

http://stackoverflow.com/comment/2654546
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2618511
type: Comment
has text: I actually changed the tests from the one that I had posted and was still having the same problem. Then I was thinking that maybe the timeOut lock I was getting was because the updates were happening too fast so that the other thread couldn't even get a lock on the row. I added the sleep period and now I am getting deadlocks. Thanks

http://stackoverflow.com/comment/2762839
type: AnswerComment
score: 0
type: Comment
has text: You're not supposed to get an access violation just because you run out of memory.
comment on: http://stackoverflow.com/a/2734813

http://stackoverflow.com/a/2626238
score: 3
upvote count: 3
has comment: http://stackoverflow.com/comment/2644924
has body: A couple of suggestions: A file in a subdirectory of the project is cross-platform portable (assuming, were you to launch the program outside of Eclipse you would maintain the file in the same location). Store the file in a similar relative path to your home directory (~ on Linux %USERPROFILE% on Windows) and use System.getProperty("user.home") Store the file on the class path and use ClassLoader.getResourceAsStream() or similar.
downvote count: 0
has comment: http://stackoverflow.com/comment/2644561
answers question: http://stackoverflow.com/q/2626211
type: Answer

http://stackoverflow.com/a/2731199
answers question: http://stackoverflow.com/q/2731119
type: Answer
score: 1
upvote count: 1
has body: It is doing fine. Inside static Hotel doStuff(Hotel hotel), you are creating a new instance of of Hotel, old hotel reference is unchanged.
downvote count: 0

http://stackoverflow.com/comment/114660769
has text: Just found goldsborough's benchmark with descriptive readme. https://github.com/goldsborough/ipc-bench
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2642814
type: AnswerComment

http://stackoverflow.com/comment/2713911
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/2692445
has text: @Paul: he mentioned in a comment he didn't want to use external libraries :) That was enough hint for me.

http://stackoverflow.com/a/2599750
has body: I don't see any advantage in using arrays instead of lists. Lists are far more comfortable. Maybe the guy just likes working with arrays:)
answers question: http://stackoverflow.com/q/2599703
score: 0
type: Answer

http://stackoverflow.com/a/63764829
answers question: http://stackoverflow.com/q/2751073
type: Answer
has comment: http://stackoverflow.com/comment/112762769
score: 0
has body: (time / 24 / 60).toFixed(0) + &quot;:&quot; +(time / 60 % 24).toFixed(0) + ':' + (time % 60) Does it best

http://stackoverflow.com/a/2687836
type: Answer
has comment: http://stackoverflow.com/comment/2708981
has comment: http://stackoverflow.com/comment/3774059
has comment: http://stackoverflow.com/comment/2709347
answers question: http://stackoverflow.com/q/2687690
score: 0
has body: I think member of cannot be used with a @ElementCollection property.

http://stackoverflow.com/q/2614457
tagged with: jtable
downvote count: 0
has answer: http://stackoverflow.com/a/8718944
possible better answer: http://stackoverflow.com/a/2623364
has answer: http://stackoverflow.com/a/2623364
favorite count: 0
has title: Using an empty column as a divider in a JTable
has answer: http://stackoverflow.com/a/2614514
tagged with: swing
answer count: 4
has body: I'm trying to use an empty column as a divider between pairs of columns in a JTable. Here's a picture and code for what I have so far. I know I can change the look using a custom TableCellRenderer. Before I go down that road, is there a better way to do this? Any ideas appreciated. import javax.swing.*; import javax.swing.table.*; public class TablePanel extends JPanel { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JFrame f = new JFrame("TablePanel"); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.add(new TablePanel()); f.pack(); f.setVisible(true); } }); } public TablePanel() { TableModel dataModel = new MyModel(); JTable table = new JTable(dataModel); table.getColumnModel().getColumn(MyModel.DIVIDER).setMaxWidth(0); JScrollPane jsp = new JScrollPane(table); jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); this.add(jsp); } private static class MyModel extends AbstractTableModel { private static final int DIVIDER = 2; private final String[] names = { "A1", "A2", "", "B1", "B2" }; @Override public int getRowCount() { return 32; } @Override public int getColumnCount() { return names.length; } @Override public String getColumnName(int col) { if (col == DIVIDER) return ""; return names[col]; } @Override public Object getValueAt(int row, int col) { if (col == DIVIDER) return ""; return (row + 1) / 10.0; } @Override public Class&lt;?&gt; getColumnClass(int col) { if (col == DIVIDER) return String.class; return Number.class; } } }
accepted answer: http://stackoverflow.com/a/2614514
type: AnsweredQuestion
tagged with: java
linked to: http://stackoverflow.com/q/8712694
has answer: http://stackoverflow.com/a/2614507
type: Question
score: 5
upvote count: 5
tagged with: divider

http://stackoverflow.com/q/2598504
score: -1
linked to: http://stackoverflow.com/q/848675
accepted answer: http://stackoverflow.com/a/2776200
tagged with: ejb
upvote count: 0
answer count: 1
favorite count: 0
has title: is it right to call ejb bean from thread by ThreadPoolExecutor?
has comment: http://stackoverflow.com/comment/2608174
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2776200
tagged with: multithreading
downvote count: 1
type: Question
has body: I trying to call some ejb bean method from tread. and getting error : (as is glassfish v3) Log Level SEVERE Logger javax.enterprise.system.std.com.sun.enterprise.v3.services.impl Name-Value Pairs {_ThreadName=Thread-1, _ThreadID=42} Record Number 928 Message ID java.lang.NullPointerException at ua.co.rufous.server.broker.TempLicService.run(TempLicService.java Complete Message 35) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:637) here is tread public class TempLicService implements Runnable { String hash; //it`s Stateful bean @EJB private LicActivatorLocal lActivator; public TempLicService(String hash) { this.hash= hash; } @Override public void run() { lActivator.proccessActivation(hash); } } my ThreadPoolExecutor public class RequestThreadPoolExecutor extends ThreadPoolExecutor { private boolean isPaused; private ReentrantLock pauseLock = new ReentrantLock(); private Condition unpaused = pauseLock.newCondition(); private static RequestThreadPoolExecutor threadPool; private RequestThreadPoolExecutor() { super(1, Integer.MAX_VALUE, 10, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()); System.out.println("RequestThreadPoolExecutor created"); } public static RequestThreadPoolExecutor getInstance() { if (threadPool == null) threadPool = new RequestThreadPoolExecutor(); return threadPool; } public void runService(Runnable task) { threadPool.execute(task); } protected void beforeExecute(Thread t, Runnable r) { super.beforeExecute(t, r); pauseLock.lock(); try { while (isPaused) unpaused.await(); } catch (InterruptedException ie) { t.interrupt(); } finally { pauseLock.unlock(); } } public void pause() { pauseLock.lock(); try { isPaused = true; } finally { pauseLock.unlock(); } } public void resume() { pauseLock.lock(); try { isPaused = false; unpaused.signalAll(); } finally { pauseLock.unlock(); } } public void…
has comment: http://stackoverflow.com/comment/2607923
tagged with: threadpool
tagged with: java

http://stackoverflow.com/comment/77799063
score: 6
has text: Perfect answer for testing purposes!!! And yes it is a bad idea to use in production, but come on ... that should be clear to everyone looking at the question title. It still answers it best/shortest/with the same (in)security level!
comment on: http://stackoverflow.com/a/5297100
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2781020
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2750685
has text: I just wanted you to think in terms of design aspect. Its perfectly logical to have both checked and unchecked. Now, in order for the compiler to check these rules, you will have to set the 'types' of them of which RuntimeException is one and NullPointerException is a type of it. And the answer to your question is yes, its a prob when NPE is made checked. The example I have provided is to tell that the Object obj passed to the method can be and cannot be null and that this method has no idea about it. A compiler can never check such instances.

http://stackoverflow.com/a/2664040
has body: Since you're switching on an object of type EnumType and the only possible values for it are the enum constants, there's no need to qualify those constants again in within the switch. After all, it would be illegal to have case OtherEnumType.ENUM1: in it anyway.
type: Answer
score: 21
has comment: http://stackoverflow.com/comment/2681958
answers question: http://stackoverflow.com/q/2663980
upvote count: 21
has comment: http://stackoverflow.com/comment/102708960
downvote count: 0

http://stackoverflow.com/comment/2714128
score: 2
has text: What do you mean by wrong folder? Can you fix it by creating a new source folder?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2692643

hierarchy
tags question: http://stackoverflow.com/q/2681459
tag name: hierarchy
tags question: http://stackoverflow.com/q/2772136
type: Tag

http://stackoverflow.com/comment/22496335
comment on: http://stackoverflow.com/q/2704417
has text: Also, as of now the benchmark game shows that the Go program is just about two times slower for most examples than the C code (and has about the same speed and much less memory than Java)
type: QuestionComment
score: 4
type: Comment

http://stackoverflow.com/q/2743023
upvote count: 1
tagged with: swing
type: Question
accepted answer: http://stackoverflow.com/a/3101282
tagged with: java
has body: In Netbeans, I created a JTable and bound it's values to a JPA result set. This works great. The query contains a parameter which I set in the pre-create box of the "query result" component. So just before Netbeans creates the query result I write this: myQuery.setParameter("year", "1997"); This works fine. Now, I have an event handler which is supposed to change the parameter and display the new values in the table. So I do this: myQuery.setParameter("year", "2005"); myResultList.clear(); myResultList.addAll(myQuery.getResultList()); jTable1.updateUI(); This works, but it feels wrong to me. Note: The result set is bound to the table. So I was hoping there was something like this: myQuery.setParameter("year", "2005"); myResultList.refresh(); Is there something like this?
answer count: 2
tagged with: jpa
has title: Refreshing a JPA result list which is bound with a jTable
downvote count: 0
score: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/2772306
tagged with: binding
possible better answer: http://stackoverflow.com/a/2745786
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2745786
has answer: http://stackoverflow.com/a/3101282

http://stackoverflow.com/a/28552249
answers question: http://stackoverflow.com/q/2743130
downvote count: 0
has body: This happened to me too, because I had my id as Long, and I was receiving from the view the value 0, and when I tried to save in the database I got this error, then I fixed it by set the id to null.
upvote count: 2
type: Answer
score: 2

http://stackoverflow.com/comment/2778874
comment on: http://stackoverflow.com/a/2747281
has text: The latest relase of JDEE not only indents enums improperly, but actually indents the enum's closing brace AT THE SAME LEVEL as the badly-indented members.
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/2721400
score: 4
comment on: http://stackoverflow.com/q/2699008
type: Comment
type: QuestionComment
has text: Sure, you just have to break their CAPTCHA.

http://stackoverflow.com/comment/11757376
score: 0
type: Comment
has text: Not quite, my point is that in "Remi Fouilloux"s code, the Capture the javadoc example is unneeded. It is also unneeded in "does_the_trick"s example code, as improved above.
comment on: http://stackoverflow.com/a/8901208
type: AnswerComment

http://stackoverflow.com/comment/2813549
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2777746
has text: i think instanceof is just what you need. if (object instanceof MyType) means: is this object instance of MyType or any of MyType's subclasses
type: AnswerComment

http://stackoverflow.com/q/2648537
has title: Deploy a jar in Jetty
score: 2
has answer: http://stackoverflow.com/a/2648604
upvote count: 2
tagged with: jetty
has body: I was wondering if is it possible to deploy a jar file in Jetty? If not, are there applications servers who can do so? I am beginner. I am asking this question because all the docs that i have found, it seems that we can only deploy war archive in application servers. Is that true?
tagged with: war
has answer: http://stackoverflow.com/a/2649931
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/2648720
type: Question
has comment: http://stackoverflow.com/comment/2664456
possible better answer: http://stackoverflow.com/a/2648720
downvote count: 0
tagged with: jar
accepted answer: http://stackoverflow.com/a/2649931
favorite count: 0
answer count: 3

http://stackoverflow.com/q/2608296
favorite count: 0
has body: is there a tool to generate a Swing form from xml code?
tagged with: http://stackoverflow.com/tag/xml
upvote count: 2
has comment: http://stackoverflow.com/comment/2618512
tagged with: swing
type: AnsweredQuestion
score: 2
tagged with: java
has comment: http://stackoverflow.com/comment/2619133
possible better answer: http://stackoverflow.com/a/2608438
type: Question
has answer: http://stackoverflow.com/a/5562978
downvote count: 0
has answer: http://stackoverflow.com/a/2608313
has title: Java form from xml
accepted answer: http://stackoverflow.com/a/2608313
answer count: 3
has comment: http://stackoverflow.com/comment/2618593
has answer: http://stackoverflow.com/a/2608438

http://stackoverflow.com/a/4433117
has comment: http://stackoverflow.com/comment/16229390
has comment: http://stackoverflow.com/comment/19689253
has comment: http://stackoverflow.com/comment/26148318
has body: This is a little off-topic because you asked for "directions", but you can also use the Geo URI scheme described in the Android Documentation: http://developer.android.com/guide/appendix/g-app-intents.html The problem using "geo:latitude,longitude" is that Google Maps only centers at your point, without any pin or label. That's quite confusing, especially if you need to point to a precise place or/and ask for directions. If you use the query parameter "geo:lat,lon?q=name" in order to label your geopoint, it uses the query for search and dismiss the lat/lon parameters. I found a way to center the map with lat/lon and display a pin with a custom label, very nice to display and useful when asking for directions or any other action: Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=37.423156,-122.084917 (" + name + ")")); startActivity(intent); NOTE (by @TheNail): Not working in Maps v.7 (latest version at the time of writing). Will ignore the coordinates and search for an object with the given name between the parentheses. See also Intent for Google Maps 7.0.0 with location
has comment: http://stackoverflow.com/comment/24704612
downvote count: 0
has comment: http://stackoverflow.com/comment/8725646
upvote count: 133
has comment: http://stackoverflow.com/comment/10924057
has comment: http://stackoverflow.com/comment/20420280
has comment: http://stackoverflow.com/comment/9717206
type: Answer
has comment: http://stackoverflow.com/comment/84063193
score: 133
answers question: http://stackoverflow.com/q/2662531
has comment: http://stackoverflow.com/comment/140261328

http://stackoverflow.com/comment/2651732
type: Comment
score: 1
type: AnswerComment
has text: From http://hc.apache.org: *HttpComponents Client is a successor of and replacement for Commons HttpClient 3.x. Users of Commons HttpClient are strongly encouraged to upgrade.* ;)
comment on: http://stackoverflow.com/a/2636125

http://stackoverflow.com/a/2706091
type: Answer
has comment: http://stackoverflow.com/comment/2733570
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/2704882
downvote count: 0
has body: public static void main(String[] args) throws IOException { final File file = new File("apriori.txt"); final Multimap&lt;String, String&gt; map = HashMultimap.create(); final BufferedReader reader = new BufferedReader(new FileReader(file)); while (true) { final String line = reader.readLine(); if (line == null) break; final String[] parts = line.split(" ; "); map.put(parts[0].trim(), parts[1].trim()); } for (Map.Entry&lt;String, String&gt; e : map.entries()) { System.out.println(e); } } Should do the trick. (I didn't compile it, no guarantees though.) Make sure you use Multimap&lt;String, String&gt;, no need to use a single element set as a key there.
has comment: http://stackoverflow.com/comment/2729764

http://stackoverflow.com/comment/2806677
type: AnswerComment
score: 0
type: Comment
has text: That was a mistake when I copied the code to this forum it is just setAddress1
comment on: http://stackoverflow.com/a/2772139

http://stackoverflow.com/comment/2744404
comment on: http://stackoverflow.com/q/2718560
score: 0
type: Comment
type: QuestionComment
has text: possibly a useful reference: http://stackoverflow.com/questions/1085709/what-does-synchronized-mean

http://stackoverflow.com/a/2753875
downvote count: 0
upvote count: 2
answers question: http://stackoverflow.com/q/2753722
type: Answer
has body: I think it depends on the scale of your web applications and your human resources. Do you have good programmers who can catch up with the new technology quickly? You also need to care about the due time for the project and the budget as well. It may be a good time to try out new technology only if it is really suitable for your project. Java still has a strong position in community and you can also find a lot of supports and open source framework.
score: 2

http://stackoverflow.com/a/2708617
accepted answer of: http://stackoverflow.com/q/2708586
answers question: http://stackoverflow.com/q/2708586
has body: Via the Relevant KeySpec classes, you can call the getModulus() and getPublicExponent()/getPrivateExponent() methods to pull out the key components: KeyFactory fact = KeyFactory.getInstance("RSA"); RSAPublicKeySpec pub = fact.getKeySpec(kp.getPublic(), RSAPublicKeySpec.class); RSAPrivateKeySpec priv = fact.getKeySpec(kp.getPrivate(), RSAPrivateKeySpec.class); saveToFile("public.key", pub.getModulus(), pub.getPublicExponent()); saveToFile("private.key", priv.getModulus(), priv.getPrivateExponent()); In case it's useful, I wrote a few articles a while back dealing with some of the details of RSA encryption in Java (and Java-based cryptography generally.
type: AcceptedAnswer
score: 4
type: Answer
upvote count: 4
downvote count: 0

http://stackoverflow.com/comment/2737950
type: AnswerComment
comment on: http://stackoverflow.com/a/2713062
type: Comment
has text: The complete screen should be cleared only after users finish drawing, so there will be images drawn to it already. if this is not the method you specified, then can you post any code snippet?
score: 0

http://stackoverflow.com/q/2765823
downvote count: 0
favorite count: 0
tagged with: focus
type: Question
tagged with: launching-application
score: 4
tagged with: java
answer count: 2
linked to: http://stackoverflow.com/q/2114318
has answer: http://stackoverflow.com/a/2799104
has body: From within Java, I am opening an Excel file with the default file handler (MS Excel, in this case :-) ) using the method described in this stackoverflow question: Desktop dt = Desktop.getDesktop(); dt.open(new File(filename)); However, the Excel program doesn't get the focus. Is there any easy way to do so? Edit: There is a related stackoverflow question for C#, but I didn't find any similar Java method. Edit 2: I've did some simple tests, and discovered that Excel starts and gets the focus whenever no instance of Excel is running. When Excel is already open en NOT minimized, the application doesn't get the focus. If instead the Excel Windows was minimized, the above code will trigger a maximization of the window and Excel getting the focus (or vice versa :-) ).
has answer: http://stackoverflow.com/a/2790760
has title: How to give focus to default program of shell-opened file, from Java?
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/1737664
tagged with: desktop
upvote count: 4

http://stackoverflow.com/comment/2819959
has text: Related: http://stackoverflow.com/questions/1814095/sorting-an-arraylist-of-contacts
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/2784514
score: 4

http://stackoverflow.com/comment/7067742
type: AnswerComment
comment on: http://stackoverflow.com/a/2686268
type: Comment
score: 0
has text: Please note that not all login methods use the AuthenticationSuccessEvent. You might want to look at the InteractiveAuthenticationSuccessEvent as well.

junit
type: Tag
tags question: http://stackoverflow.com/q/2755358
tags question: http://stackoverflow.com/q/2715568
tags question: http://stackoverflow.com/q/2739302
tags question: http://stackoverflow.com/q/2783007
tags question: http://stackoverflow.com/q/2702870
tags question: http://stackoverflow.com/q/2716400
tags question: http://stackoverflow.com/q/2710545
tags question: http://stackoverflow.com/q/2730325
tags question: http://stackoverflow.com/q/2717902
tags question: http://stackoverflow.com/q/2686226
tags question: http://stackoverflow.com/q/2767075
tags question: http://stackoverflow.com/q/2597271
tag name: junit
tags question: http://stackoverflow.com/q/2769416
tags question: http://stackoverflow.com/q/2618423
tags question: http://stackoverflow.com/q/2669414
tags question: http://stackoverflow.com/q/2701861
tags question: http://stackoverflow.com/q/2730365
tags question: http://stackoverflow.com/q/2724035
tags question: http://stackoverflow.com/q/2624724
tags question: http://stackoverflow.com/q/2698174
tags question: http://stackoverflow.com/q/2753783
tags question: http://stackoverflow.com/q/2727500
tags question: http://stackoverflow.com/q/2650691
tags question: http://stackoverflow.com/q/2701438
tags question: http://stackoverflow.com/q/2744351
tags question: http://stackoverflow.com/q/2635839
tags question: http://stackoverflow.com/q/2722358
tags question: http://stackoverflow.com/q/2647365
tags question: http://stackoverflow.com/q/2688304
tags question: http://stackoverflow.com/q/2668009
tags question: http://stackoverflow.com/q/2639018
tags question: http://stackoverflow.com/q/2694529
tags question: http://stackoverflow.com/q/2668997
tags question: http://stackoverflow.com/q/2677288
tags question: http://stackoverflow.com/q/2689217
tags question: http://stackoverflow.com/q/2604875
tags question: http://stackoverflow.com/q/2609522
tags question: http://stackoverflow.com/q/2620117
tags question: http://stackoverflow.com/q/2737737
tags question: http://stackoverflow.com/q/2690528
tags question: http://stackoverflow.com/q/2674697

http://stackoverflow.com/comment/3403106
type: AnswerComment
has text: This code won't work for odd length lists. If `fast.next == null` then the element `fast` refers to is never advanced. After some time, the `slow` reference will catch up and falsely report a loop.
type: Comment
comment on: http://stackoverflow.com/a/2663147
score: 4

http://stackoverflow.com/comment/2807704
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2773912
has text: @froadie The details of the definite assignment rules are in the JLS. They are very tedious, but you should be able know what is going on by example. The compiler is required to detect that the variable is definitely assigned if an exception is not caught, and if an exception is caught the code leaves via an exception and is therefore not required to definitely assign the variable. (For `final` instance fields there are sneaky ways to look at the uninitialised variable before or after.)
score: 0

http://stackoverflow.com/comment/2687068
comment on: http://stackoverflow.com/a/2668219
type: AnswerComment
score: 0
type: Comment
has text: @flumins I don't mean the "domain model", but the difficult to change decisions made about interfacing with the database.

http://stackoverflow.com/q/2779019
type: UnansweredQuestion
has body: Is method overloading is an example of runtime polymorphism or compile time polymorphism?
answer count: 4
has answer: http://stackoverflow.com/a/2779662
score: 2
upvote count: 3
tagged with: java
has title: polymorphism in java
has answer: http://stackoverflow.com/a/12963150
downvote count: 1
has answer: http://stackoverflow.com/a/24647665
type: Question
tagged with: runtime
has answer: http://stackoverflow.com/a/2779041
has comment: http://stackoverflow.com/comment/3016168
linked to: http://stackoverflow.com/q/409969
tagged with: polymorphism
has comment: http://stackoverflow.com/comment/2813802
favorite count: 0
linked to: http://stackoverflow.com/q/154577

http://stackoverflow.com/comment/81337631
comment on: http://stackoverflow.com/a/17142065
type: AnswerComment
has text: But on Image you enter with \bin.
score: 0
type: Comment

http://stackoverflow.com/a/2747189
answers question: http://stackoverflow.com/q/2745003
score: 0
has comment: http://stackoverflow.com/comment/97935024
type: Answer
upvote count: 1
downvote count: 1
has body: Since you say, "its all about predictability not straight line speed," you should look at using a realtime Java system with deterministic garbage collection.

http://stackoverflow.com/a/2734098
score: 1
has body: The Hibernate online documentation has some very good information on mapping your classes, in particular this section on setting up subclasses: http://docs.jboss.org/hibernate/stable/core/manual/en/html/mapping.html#mapping-declaration-subclass You want to pay special attention to using discriminator values and such if you are storing your sub-classed objects in a common table. You might also consider picking up a copy of Java Persistence with Hibernate, which is considered the "Hibernate Bible" amongst my co-workers. http://www.amazon.com/Java-Persistence-Hibernate-Christian-Bauer/dp/1932394885/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1272501916&amp;sr=8-1
has comment: http://stackoverflow.com/comment/27073685
answers question: http://stackoverflow.com/q/2734063
upvote count: 1
has comment: http://stackoverflow.com/comment/27160061
type: Answer
downvote count: 0

http://stackoverflow.com/a/2653723
type: Answer
score: 2
upvote count: 2
has body: Static variables are initialized when the class is loaded. Instance variables are initialized when the instance is constructed. Most of the time this is after the class is fully initialized, but contrary to what the others have written this may also happen while initializing static variables. For example, it is quite common to have static constants for commonly used instances of a class, like this: class Foo { private static final Foo FOO_BAR = new Foo("bar"); private static final Foo FOO_BAZ = new Foo("baz"); private final String name; public Foo(String n) { name = n; } [...] } Here name in the first instance is initialized to "bar" before FOO_BAZ is initialized.
answers question: http://stackoverflow.com/q/2652801
downvote count: 0

http://stackoverflow.com/a/2679962
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/2679759
has body: Calling makePersistent() on an entity that has been retrieved or previously inserted will update the entity in the datastore. See the docs.
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/3703060

http://stackoverflow.com/a/2703723
answers question: http://stackoverflow.com/q/2703671
has body: If all you need is to change the 8080 port: Goto the deploy folder of the server instance you use. Goto the jbossweb-tomcat55.sar inside that deploy folder. Find the file named server.xml inside that folder. (tomcat service file). Look for the HTTP Connector section inside the server.xml where 8080 configuration is available. Change the port value to what ever the required port number. (taken from here , first result when googling it :-) ) See this question for changing all JBoss ports at once Running JBoss AS 5 and JBoss AS 4 simultaneously
type: Answer
accepted answer of: http://stackoverflow.com/q/2703671
downvote count: 0
score: 1
upvote count: 1
type: AcceptedAnswer

http://stackoverflow.com/comment/2779238
score: 0
type: Comment
type: AnswerComment
has text: I see. This is still the way to go though. At the same place where you change the data that the visualization depends on and varies with, you should invoke `repaint`.
comment on: http://stackoverflow.com/a/2749198

http://stackoverflow.com/a/2766340
accepted answer of: http://stackoverflow.com/q/2766293
type: Answer
has comment: http://stackoverflow.com/comment/2799113
score: 2
downvote count: 0
upvote count: 2
has comment: http://stackoverflow.com/comment/2799526
type: AcceptedAnswer
has body: A design pattern provides a known solution to a common design problem, and is given a name to allow programmers to communicate more efficiently. However, I have no idea what you mean by "programming styles". Edit: I think the question is simply very badly worded. While "design pattern" has a relatively clear definition, "programming style" is, in my experience, not a term with a generally agreed clear definition. The question seems to assume that design patterns are a kind of programming style, and I don't think that's true.
answers question: http://stackoverflow.com/q/2766293

runtime-environment
tags question: http://stackoverflow.com/q/2692742
tags question: http://stackoverflow.com/q/2725795
tag name: runtime-environment
type: Tag

http://stackoverflow.com/q/2724147
answer count: 1
favorite count: 0
has answer: http://stackoverflow.com/a/2724171
accepted answer: http://stackoverflow.com/a/2724171
tagged with: thread-local
type: AnsweredQuestion
score: 3
downvote count: 0
tagged with: java
tagged with: hibernate
tagged with: multithreading
type: Question
tagged with: session
has body: I have a web-application which uses hibernate and for some reason every thread (httprequest or other threads related to queueing) uses a different session. I've implemented a HibernateSessionFactory class which looks like this: public class HibernateSessionFactory { private static final ThreadLocal<Session> threadLocal = new ThreadLocal<Session>(); private static Configuration configuration = new AnnotationConfiguration(); private static org.hibernate.SessionFactory sessionFactory; static { try { configuration.configure(configFile); sessionFactory = configuration.buildSessionFactory(); } catch (Exception e) {} } private HibernateSessionFactory() {} public static Session getSession() throws HibernateException { Session session = (Session) threadLocal.get(); if (session == null || !session.isOpen()) { if (sessionFactory == null) { rebuildSessionFactory();//This method basically does what the static init block does } session = (sessionFactory != null) ? sessionFactory.openSession(): null; threadLocal.set(session); } return session; } //More non relevant methods here. Now from my testing it seems that the threadLocal member is indeed initialized only once when the class is first loaded by the JVM but for some reason when different threads access the getSession() method they use different sessions. When a thread first accesses this class (Session) threadLocal.get(); will return null but as expected all other access requests will yeild the same session. I'm not sure how this can be happening as the threadLocal variable is final and the method threadLocal.set(session) is only used in the above context (which I'm 99.9% sure has to yeild a non null session as I would have encountered a NullPointerException at a different part of my app). I'm not sure this is relevant but these are the main parts of my hibernate.cfg.xml file: <hibernate-configuration> <session-factory> someURL com.microsoft.sqlserver.jdbc.SQLServerDriver org.hibernate.dialect.SQLServerDialect 1 User Password …
upvote count: 3
has title: Why does every thread in my application use a different hibernate session?

http://stackoverflow.com/comment/2723163
type: QuestionComment
has text: I think that for this case, don't matter which Exception is thrown. Or why would?
score: 1
type: Comment
comment on: http://stackoverflow.com/q/2699209

http://stackoverflow.com/comment/2761434
type: Comment
has text: Yes, quite correct. (Except long, which is actually stored in two slots).
type: AnswerComment
comment on: http://stackoverflow.com/a/2733579
score: 0

http://stackoverflow.com/comment/2808794
score: 0
type: AnswerComment
type: Comment
has text: But it is not like the whole document can't be seen. Its only one static label that doesn't show the complete text and it also happens that a whole row of the detail section doesn't show up at all. Could this behaviour be still font-related?
comment on: http://stackoverflow.com/a/2774856

http://stackoverflow.com/a/15501570
has body: Three years later... You want to use XACML and a XACML authorization engine. There are open-source alternatives (WSO2, Heras AF, Sun XACML) and vendors alternatives (Axiomatics, IBM...). Disclaimer: I work for Axiomatics. Our solution can be an authorization service or used as a library you embed within your application - see more at http://www.axiomatics.com/
type: Answer
answers question: http://stackoverflow.com/q/2764040
score: 0

http://stackoverflow.com/a/2706308
has body: Isn't this a use case for Double Dispatching ? Update: class Function { public void add(Function f) { f.addMe(this); } public void addMe(Function f) { // Default case throw NotImplementedException(); } public void addMe(Logarithmic log) { // Code that handles the real } } class Logarithmic extends Function { // This object supports adding public void add(Function f) { f.addMe(this); } } Logarithmic log = new Logarithmic(); log.add(new Function()); log.add(new Logarithmic()); Function f = log; f.add(new Function()); f.add(new Logarithmic());
answers question: http://stackoverflow.com/q/2706258
accepted answer of: http://stackoverflow.com/q/2706258
has comment: http://stackoverflow.com/comment/2730127
score: 3
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2730081
type: Answer
has comment: http://stackoverflow.com/comment/2732285
upvote count: 3

http://stackoverflow.com/comment/96443654
has text: Have you actually tried this? The default `com.sun.imageio.plugins.png.PNGImageWriteParam` in Java 7 and 8 throws `java.lang.UnsupportedOperationException: Compression not supported.`
score: 1
comment on: http://stackoverflow.com/a/54422581
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2724122
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2701095
score: 2
has text: @Justin - I don't like the concept of using public fields, but it doesn't seem like it would be a breaking change; accessing a public field or a property of the same name would have the same syntax.

http://stackoverflow.com/a/2691377
answers question: http://stackoverflow.com/q/2690614
downvote count: 0
has comment: http://stackoverflow.com/comment/2713344
type: Answer
has comment: http://stackoverflow.com/comment/2714257
has body: public static String data ="X2\naaaaXXaaaa\naaaa\naaaaaaX\naaaaaaXaX"; public static String[] lines = data.split("\n"); public static void main(String[] args){ Map&lt;Integer, List&lt;Integer&gt;&gt; result = new HashMap&lt;Integer, List&lt;Integer&gt;&gt;(); Integer lineNum = 1; for(String s : lines){ boolean keepSearching = true; List&lt;Integer&gt; charPositions=null; Integer charNum=0, lastCharNum=0; while(keepSearching){ if (start == true){ charNum = s.indexOf("X", lastCharNum); start = false; }else{ charNum = s.indexOf("X", lastCharNum+1); } if(charNum &gt;= 0){ if(charPositions== null){ charPositions = new ArrayList&lt;Integer&gt;(); } charPositions.add(charNum); lastCharNum = charNum; }else{ keepSearching = false; if(charPositions!= null){ result.put(lineNum, charPositions); } } } lineNum++; } for (Integer i : result.keySet()){ System.out.print("Line "+i+" : "); for(Integer j : result.get(i)){ System.out.print("at char "+j+", "); //you should start for the end if you want to print in the right order ! } System.out.println(); } } Output : Line 1 : at char 0, Line 2 : at char 4, at char 5, Line 4 : at char 6, Line 5 : at char 6, at char 8,
upvote count: 1
score: 1

http://stackoverflow.com/comment/2807805
score: 0
has text: I agree with Ryan's answer (and voted up appropriately). One thing I'll say though is... do you really want to System.exit if you can't initialize? Perhaps the best idea is to just let the exception get thrown - either way if it's not handled you'll still exit, but if there is a handling mechanism in place, it can be taken care of properly.
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2773779

http://stackoverflow.com/comment/2729347
score: 1
has text: Thanks, but just tips. It's not cool, I find that it's not appropriate in an entreprise development. I hope that Maven 3 will fixe this problem.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2678289

http://stackoverflow.com/comment/2797436
has text: This did not work. in the html it just displays ${brand} and not the variable
type: AnswerComment
comment on: http://stackoverflow.com/a/2764838
score: 0
type: Comment

http://stackoverflow.com/comment/33681683
comment on: http://stackoverflow.com/a/22188697
type: AnswerComment
score: 0
type: Comment
has text: java.lang.ClassCastException will raise at `return (car) new vechicle();`

http://stackoverflow.com/a/16568540
has comment: http://stackoverflow.com/comment/24134418
has body: Actually it's: request.getHeader("Referer"), or even better, and to be 100% sure, request.getHeader(HttpHeaders.REFERER), where HttpHeaders is com.google.common.net.HttpHeaders
has comment: http://stackoverflow.com/comment/43983558
score: 29
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2648984
has comment: http://stackoverflow.com/comment/134365309
upvote count: 29

http://stackoverflow.com/comment/58347848
score: 0
comment on: http://stackoverflow.com/a/2695660
type: AnswerComment
has text: Also, testing this now, I only receive success messages, even if settings are wrong. Any idea why? (Using hosted SMTP with 1and1, rather than gmail)
type: Comment

http://stackoverflow.com/a/40843350
answers question: http://stackoverflow.com/q/2743130
score: 0
has body: I got this error because I mistakenly mapped the ID column using Id(x =&gt; x.Id, "id").GeneratedBy.**Assigned**(); Issue resolved by using Id(x =&gt; x.Id, "id").GeneratedBy.**Identity**();
type: Answer

http://stackoverflow.com/a/2637060
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2629366
has comment: http://stackoverflow.com/comment/109059768
answers question: http://stackoverflow.com/q/2629366
type: Answer
score: 16
has comment: http://stackoverflow.com/comment/105980311
upvote count: 16
has body: I had the bad luck using SOAP over JMS. It does make some sense, if it is used for fire-and-forget operations (no response message defined in the WSDL). In this case you can use the WSDL to generate client skeletons and you can store the WSDL in your service registry. Plus you get all the usual benefits of JMS (decoupling sender and receiver, load-balancing, prioritising, security, bridging to multiple destinations - e.g. non-intrusive auditing). On the other hand SOAP is mainly used for request/reply type operations. Implementing request/reply pattern over JMS introduces the following problems: Impossible to handle timeouts properly. You never know if a request is still waiting for delivery or got stuck in the called component. Responses are typically sent on temporary queues. If the client disconnects before receiving the response and there is no explicit time to live set on the response message, the temp queue can get stuck in the JMS server until you restart it. Having a JMS server in the middle dramatically increases roundtrip times and adds unnecessary compexity. JMS provides a reliable transport medium that decouples the sender from the receiver, but in case of request/reply the client should not be decoupled from the server. The client needs to know if the server is up and available. The only advantage I could think about is that the server can be moved or load-balanced without the client knowing about it, but using UDDI and HTTP load balancer is a better solution.

http://stackoverflow.com/comment/2734544
type: AnswerComment
type: Comment
has text: Spring is indeed doing all that for you. That's the best feature of the Spring JDBC design: eliminating boilerplate. Rod Johnson hated writing it on his consulting engagements as much or more than you do, so he figured out a good way to do it once.
comment on: http://stackoverflow.com/a/2708704
score: 0

http://stackoverflow.com/a/2767182
has body: public class Foo { private final Random random = new Random(); public List&lt;Integer&gt; createList() { // Create empty list to store results. List&lt;Integer&gt; ret = new ArrayList&lt;Integer&gt;(30); // Add 10 randomly generated integers. ret.addAll(createRandomIntegers(10)); // Add another 20 randomly generated integers which could potentially // contain integers already added previously (the OP states that this is ok). ret.addAll(createRandomIntegers(20)); return ret; } /** * Utility function that creates a set of randomly generated * integers of specified size. We use a Set to avoid duplicates. */ protected Set&lt;Integer&gt; createRandomIntegers(int sz) { Set&lt;Integer&gt; ret = new HashSet&lt;Integer&gt;(); while (ret.size() &lt; sz) { ret.add(random.nextInt()); } return ret; } }
answers question: http://stackoverflow.com/q/2767134
downvote count: 0
score: 6
type: Answer
upvote count: 6

http://stackoverflow.com/comment/2741327
comment on: http://stackoverflow.com/a/2714958
type: AnswerComment
type: Comment
score: 0
has text: Because Lilipond does not what I want my program to do - lack features, does not format music automatically... And My program will be more specific, only for guitar chords over lyrics.

http://stackoverflow.com/a/28525822
has comment: http://stackoverflow.com/comment/45368530
has comment: http://stackoverflow.com/comment/45368182
upvote count: 8
has body: Though the article is pretty old now, and though I understand that I'm not really very helpful, I think the proposal described in Adding tuples to Java: a study in lightweight data structures, would have been nice in mainstream Java. You can do things like: int a; char b; float c; [a,b,c] = [3,'a',2.33]; or [int,int,char] x = [1,2,'a']; or public [int,boolean] Find(int i) { int idx = FindInArray(A,i); return [idx,idx&gt;=0]; } [idx, found] = Find(7); Here tuples are: Defined as primitive types - no templates/generics Stack-allocated if declared locally Assigned using pattern-matching This approach increases Performance Readability Expressiveness
type: Answer
downvote count: 1
answers question: http://stackoverflow.com/q/2670982
score: 7
has comment: http://stackoverflow.com/comment/45367876
has comment: http://stackoverflow.com/comment/138414178
has comment: http://stackoverflow.com/comment/45368082

http://stackoverflow.com/comment/2737903
type: Comment
type: QuestionComment
has text: Also: http://stackoverflow.com/questions/318887/j2me-development-without-java
score: 0
comment on: http://stackoverflow.com/q/2713019

http://stackoverflow.com/q/2617181
favorite count: 0
has title: Testing JavaMail Related Modules
has answer: http://stackoverflow.com/a/2617214
score: 2
type: AnsweredQuestion
downvote count: 0
tagged with: unit-testing
type: Question
tagged with: java
possible better answer: http://stackoverflow.com/a/2617214
has answer: http://stackoverflow.com/a/2617255
has body: Part of my application depends on JavaMail, moving arranging messages etc. Is it possible to test this module without firing a IMAP server to run the tests on? I am always stuck when it comes to testing stuff that depends on external servers or modules.
accepted answer: http://stackoverflow.com/a/2617255
upvote count: 2
tagged with: jakarta-mail
answer count: 3
has answer: http://stackoverflow.com/a/2617292

http://stackoverflow.com/comment/2650096
score: 0
comment on: http://stackoverflow.com/a/2636069
type: AnswerComment
type: Comment
has text: @Kobi this is a string, not xml in this case parsing with xml is just an overhead

http://stackoverflow.com/a/2732702
has body: If you want to set a "fresh" object in each setter of your class, you can typically do it by getting the Method, for each Method you get the Class of the arguments with getParameterTypes() , for each Class you invoke Class.newInstance() ... and cross your fingers (that should break with primitive types -I doubt Java does autoboxing here). You can always ask if a parameter is a pimitive calling isPrimitive() Why would you want to set "empty" instances for primitive fields of a class? They are already initialized. Do you want to "reset" them ?
has comment: http://stackoverflow.com/comment/44607574
answers question: http://stackoverflow.com/q/2732659
upvote count: 1
type: Answer
downvote count: 0
score: 1

http://stackoverflow.com/q/2686588
has body: In the following: for (String deviceNetwork : deviceOrganizer.getNetworkTypes(deviceManufacturer)) { // do something } Is it safe to assume that deviceOrganizer.getNetworkTypes(deviceManufacturer) will be called only once?
answer count: 3
score: 14
linked to: http://stackoverflow.com/q/1618202
has comment: http://stackoverflow.com/comment/2707164
has answer: http://stackoverflow.com/a/2686591
favorite count: 0
has comment: http://stackoverflow.com/comment/2707240
possible better answer: http://stackoverflow.com/a/2686648
upvote count: 14
has title: In a java enhanced for loop, is it safe to assume the expression to be looped over will be evaluated only once?
has answer: http://stackoverflow.com/a/2686648
has comment: http://stackoverflow.com/comment/2707226
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2686591
tagged with: java
has answer: http://stackoverflow.com/a/2686976
has comment: http://stackoverflow.com/comment/2707353
type: Question
downvote count: 0

http://stackoverflow.com/q/2627180
type: Question
score: 0
accepted answer: http://stackoverflow.com/a/2627221
answer count: 1
has body: I am trying to write an hql query which gives me the number of hours between two timestamp. So, far i am unable to do this. I have used hql hour function but that does not work if the timestamp corresponds to different date. Please provide any input. My hql query is select count(*) from com.xxx.Request as request where request.id = :id and hour(current_timestamp - request.lastEventDate) &gt; :delay
has title: how to find difference between two timestamp using hibernate query language
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2627221
tagged with: java
tagged with: hibernate
tagged with: hql

http://stackoverflow.com/a/2602064
has body: Not just JDBC specific, just general SQL stuff If you have to rerun a query multiple times, use PreparedStatement. Use stored procedure if it is available. This is obviously not portable so YMMV. Always close your ResultSet or Statement if you are not using it. Closing a Statement will auto close all ResultSet associated with the Statement. Still it is a good habit to close the ResultSet. Try to restrict what can be queried eg. select * from orders where order_date between XXX and yyy. In MySQL the query may either be a full table scan or 'range' depending on how much data is returned. So deciding a how 'flexible' you want your queries to be If you are using MySQL, use explain to optimize your query. If you are using JPA, then you don't get to see the SQL generated. (This is not strictly JDBC) You might want to enable logging on the ORM manager to display the SQL statement used. Then use explain to optimize that. You may want to use @NamedNativeQuery if the ORM generates a really convoluted query If your JDBC driver supports batch update then use that. Batch updates is supported in PreparedStatement and ResultSet. You can also control the commit. Good idea to turn it off if you are performing lots of updates. The call commit() yourself.
type: AcceptedAnswer
upvote count: 5
type: Answer
accepted answer of: http://stackoverflow.com/q/2601875
downvote count: 0
answers question: http://stackoverflow.com/q/2601875
score: 5

http://stackoverflow.com/q/2664424
tagged with: win64
answer count: 1
tagged with: tomcat
favorite count: 0
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/2695410
score: 6
has body: Hoping someone can help. The rub: I can't get Tomcat 5.5 to start as a windows service on 64-bit windows using a 32-bit JDK. the details: I've been running Tomcat 5.5 on Windows Server 2008 (x64) as a service for some time using a 64-bit JDK. I'm being forced to install a 32-bit JDK on this 64-bit machine so I can make use of the Java JAI libraries (no 64-bit JAI version). I have to run Tomcat using this 32-bit JDK. I can run Tomcat using the 32-bit JDK if I start it using /bin/startup.bat Problem is, it will not start as a windows service. I'm using the Tomcat bundled procrun executables. Has anyone had success starting Tomcat as a service using a 32-bit JDK on a 64-bit machine? Thanks for your expertise.
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/2664456
tagged with: windows-services
type: Question
upvote count: 6
has comment: http://stackoverflow.com/comment/2682997
has title: Tomcat on Windows x64 using 32-bit JDK

http://stackoverflow.com/a/7991448
downvote count: 1
has comment: http://stackoverflow.com/comment/40405368
upvote count: 0
has comment: http://stackoverflow.com/comment/9876948
type: Answer
score: -1
has body: The best possible way to end the loop could be done by adding a null object at the end. While reading the null object can be used as a boundary condition to exit the loop. Catching the EOFException also solves the purpose but it takes few m
answers question: http://stackoverflow.com/q/2626163

http://stackoverflow.com/a/10471029
downvote count: 0
has comment: http://stackoverflow.com/comment/40145734
has comment: http://stackoverflow.com/comment/66634745
answers question: http://stackoverflow.com/q/2784514
has body: For sorting an ArrayList you could use the following code snippet: Collections.sort(studList, new Comparator&lt;Student&gt;(){ public int compare(Student s1, Student s2) { return s1.getFirstName().compareToIgnoreCase(s2.getFirstName()); } });
score: 164
has comment: http://stackoverflow.com/comment/113875063
type: Answer
upvote count: 164

http://stackoverflow.com/q/2606523
has answer: http://stackoverflow.com/a/2606673
has comment: http://stackoverflow.com/comment/2623387
has comment: http://stackoverflow.com/comment/25202160
has comment: http://stackoverflow.com/comment/2616760
type: Question
has comment: http://stackoverflow.com/comment/2616560
downvote count: 23
has answer: http://stackoverflow.com/a/2606617
has comment: http://stackoverflow.com/comment/25498234
tagged with: java
linked to: http://stackoverflow.com/q/171952
has comment: http://stackoverflow.com/comment/2623389
has answer: http://stackoverflow.com/a/48154753
has comment: http://stackoverflow.com/comment/2616725
has comment: http://stackoverflow.com/comment/2616780
has answer: http://stackoverflow.com/a/2606546
has comment: http://stackoverflow.com/comment/2616904
has answer: http://stackoverflow.com/a/9673768
has answer: http://stackoverflow.com/a/47997560
favorite count: 0
has answer: http://stackoverflow.com/a/2606588
has answer: http://stackoverflow.com/a/2606918
has answer: http://stackoverflow.com/a/2606549
answer count: 10
tagged with: destructor
has answer: http://stackoverflow.com/a/2606534
has title: Why does Java not have any destructor like C++?
score: 8
has comment: http://stackoverflow.com/comment/47756974
has body: Java has its own garbage collection implementation so it does not require any destructor like C++ . This makes Java developer lazy in implementing memory management. Still we can have destructor along with garbage collector where developer can free resources and which can save garbage collector's work. This might improves the performance of application. Why does Java not provide any destructor kind of mechanism? Developer does not have control over GC but he/she can control or create object. Then why not give them ability to destruct the objects?
upvote count: 31
has comment: http://stackoverflow.com/comment/25162915
type: UnansweredQuestion

http://stackoverflow.com/comment/5587746
type: AnswerComment
score: 0
type: Comment
has text: Jaikiran, it came out as "you can add a in the maven dependency"; did you mean "you can add a 'provided' in the maven dependency", as another answer shows?
comment on: http://stackoverflow.com/a/2683178

http://stackoverflow.com/comment/2752401
type: Comment
type: QuestionComment
has text: Threads? How would you use threads to reproduce this?
comment on: http://stackoverflow.com/q/2725542
score: 0

http://stackoverflow.com/comment/2762715
score: 0
type: Comment
type: QuestionComment
has text: Tiff is different. There are multiple compression schemes available, not to mention variable bit width. In the case of lossless though they're usually 32-bits per pixel, so slightly bigger than a bitmap due to extra header data.
comment on: http://stackoverflow.com/q/2734678

http://stackoverflow.com/q/2642046
has answer: http://stackoverflow.com/a/51543908
type: AnsweredQuestion
tagged with: jsse
has title: Is there a way to load a different cacerts than the one specified in the java_home/jre/lib/security folder?
tagged with: java
tagged with: ssl
has answer: http://stackoverflow.com/a/2645939
has comment: http://stackoverflow.com/comment/72096509
type: Question
has answer: http://stackoverflow.com/a/47154320
has answer: http://stackoverflow.com/a/2642107
downvote count: 0
favorite count: 0
possible better answer: http://stackoverflow.com/a/47154320
tagged with: security
score: 50
upvote count: 50
accepted answer: http://stackoverflow.com/a/2645939
answer count: 4
has body: I have a single installation of java in a system that runs 2 or 3 applications. All the applications use the same runtime. Is there a way to specify a different keystores for the ca certs than the one in java_home/jre/lib/security. That is, is there an option to specify an "extra" keystore that is loaded and added to the certs loaded from java_home/jre/lib/security/cacerts? What I want to avoid is having to re-import our local ca every time I upgrade the jdk in the box.

http://stackoverflow.com/q/2631062
downvote count: 0
possible better answer: http://stackoverflow.com/a/2632204
favorite count: 0
has title: Cactus versus mock objects (jMock, Easy mock)
has answer: http://stackoverflow.com/a/2632204
type: AnsweredQuestion
score: 3
accepted answer: http://stackoverflow.com/a/2632096
tagged with: java
tagged with: easymock
tagged with: jmock
type: Question
tagged with: jakarta-ee
has answer: http://stackoverflow.com/a/2632096
has body: I'm little confused with Cactus and mock objects (jMock, Easy mock). Could anyone please answer the following questions? When to use Cactus for testing? When not to use Cactus for testing? When to use mock objects for testing? When not to use mock objects for testing?
upvote count: 3
answer count: 2
tagged with: cactus

http://stackoverflow.com/a/3682794
has body: The GMaven plugin lets you embed groovy code in your lifecycle. It let's you execute Groovy code either from an inline code snippet in your pom or source files in your project or remote source files. It also Simplifies the Creation of Groovy-based Maven Plugins
answers question: http://stackoverflow.com/q/2616397
score: 3
downvote count: 0
type: Answer
upvote count: 3

http://stackoverflow.com/q/2742336
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2742512
has body: What are my options for libraries to convert XSD files to java beans or objects? I have a large XSD that I have been trying to convert using JAXB2, but JAXB2 is creating invalid classes.
tagged with: xsd
score: 0
type: Question
tagged with: java
tagged with: jaxb
has answer: http://stackoverflow.com/a/2745380
answer count: 3
has answer: http://stackoverflow.com/a/3629147
linked to: http://stackoverflow.com/q/686453
tagged with: jaxb2
has comment: http://stackoverflow.com/comment/2771929
has title: Java libraries for converting xsd to bean/objects

ksoap2
type: Tag
tags question: http://stackoverflow.com/q/2717220
tag name: ksoap2

http://stackoverflow.com/q/2757043
has body: Edit: I've figured out the constructor for the singleton is getting called multiple times so it appears the classes are getting loaded more than once by separate class loaders. How can I make a global singleton in Tomcat? I've been googling, but no luck so far. I have a singleton object that I construct like thus: private static volatile KeyMapper mapper = null; public static KeyMapper getMapper() { if(mapper == null) { synchronized(Utils.class) { if(mapper == null) { mapper = new LocalMemoryMapper(); } } } return mapper; } The class KeyMapper is basically a synchronized wrapper to HashMap with only two functions, one to add a mapping and one to remove a mapping. When running in Tomcat 6.24 on my 32bit Windows machine everything works fine. However when running on a 64 bit Linux machine (CentOS 5.4 with OpenJDK 1.6.0-b09) I add one mapping and print out the size of the HashMap used by KeyMapper to verify the mapping got added (i.e. verify size = 1). Then I try to retrieve the mapping with another request and I keep getting null and when I checked the size of the HashMap it was 0. I'm confident the mapping isn't accidentally being removed since I've commented out all calls to remove (and I don't use clear or any other mutators, just get and put). The requests are going through Tomcat 6.24 (configured to use 200 threads with a minimum of 4 threads) and I passed -Xnoclassgc to the jvm to ensure the class isn't inadvertently getting garbage collected (jvm is also running in -server mode). I also added a finalize method to KeyMapper to print to stderr if it ever gets garbage collected to verify that it wasn't being garbage collected. I'm at my wits end and I can't figure out why one minute the entry in HashMap is there and the next it isn't :(
downvote count: 0
has answer: http://stackoverflow.com/a/2758004
tagged with: java
has answer: http://stackoverflow.com/a/2757074
type: Question
upvote count: 2
tagged with: tomcat
has answer: http://stackoverflow.com/a/2757863
tagged with: linux
possible better answer: http://stackoverflow.com/a/2758004
has answer: http://stackoverflow.com/a/2760754
favorite count: 0
accepted answer: http://stackoverflow.com/a/2760754
has title: Accessing global variable in multithreaded Tomcat server
answer count: 5
has comment: http://stackoverflow.com/comment/2789474
tagged with: multithreading
has answer: http://stackoverflow.com/a/2757700
type: AnsweredQuestion
score: 2

http://stackoverflow.com/a/2625598
downvote count: 1
has comment: http://stackoverflow.com/comment/2661694
score: 9
has body: H2 database the new thing from the creator of Hypersonic SQL: H2 stands for Hypersonic 2, however H2 does not share code with Hypersonic SQL or HSQLDB. H2 is built from scratch.
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2662090
has comment: http://stackoverflow.com/comment/2668324
type: Answer
accepted answer of: http://stackoverflow.com/q/2624665
has comment: http://stackoverflow.com/comment/2662007
answers question: http://stackoverflow.com/q/2624665
has comment: http://stackoverflow.com/comment/9549009
upvote count: 10

http://stackoverflow.com/q/2653431
tagged with: multithreading
has answer: http://stackoverflow.com/a/2653462
has answer: http://stackoverflow.com/a/2653500
type: Question
has answer: http://stackoverflow.com/a/2653525
answer count: 8
tagged with: java
has title: is this class thread safe?
score: 4
tagged with: concurrency
upvote count: 4
possible better answer: http://stackoverflow.com/a/2653451
has answer: http://stackoverflow.com/a/2653451
downvote count: 0
accepted answer: http://stackoverflow.com/a/2653525
favorite count: 0
has answer: http://stackoverflow.com/a/2653449
has comment: http://stackoverflow.com/comment/2669727
has answer: http://stackoverflow.com/a/2653771
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2653452
has answer: http://stackoverflow.com/a/2653444
has body: consider this class,with no instance variables and only methods which are non-synchronous can we infer from this info that this class in Thread-safe? public class test{ public void test1{ // do something } public void test2{ // do something } public void test3{ // do something } }

http://stackoverflow.com/comment/2680066
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/2661065
type: Comment
has text: Also, "Because .NET has it" is possibly the worst reason I've heard to add a feature to an API.

http://stackoverflow.com/a/2752492
has comment: http://stackoverflow.com/comment/2783135
upvote count: 0
has body: Maybe I'm missing something, but where is the throws clause in your program? The source code as it appears now for method() does not contain a throws clause at the method header, just throw statements. Your quote from the JLS explicitly refers to throws clause.
type: Answer
downvote count: 1
answers question: http://stackoverflow.com/q/2752459
score: -1

war
tags question: http://stackoverflow.com/q/2681270
tags question: http://stackoverflow.com/q/2701945
type: Tag
tags question: http://stackoverflow.com/q/2720275
tag name: war
tags question: http://stackoverflow.com/q/2648537

http://stackoverflow.com/comment/2664309
comment on: http://stackoverflow.com/q/2643789
score: 0
type: QuestionComment
has text: I hope you realizing that an `ADDDAYS` function is reinventing the wheel; adding an number to an Oracle `DATE` or `TIMESTAMP` adds that number of days (or fractions thereof) to it.
type: Comment

treeset
tags question: http://stackoverflow.com/q/2710651
tag name: treeset
tags question: http://stackoverflow.com/q/2632405
tags question: http://stackoverflow.com/q/2759256
type: Tag

http://stackoverflow.com/comment/2677878
type: AnswerComment
comment on: http://stackoverflow.com/a/2653469
type: Comment
score: 0
has text: Although not free, Microsoft SQL Server has an equivalent named Transparent Data Encryption in the 2008 Enterprise Edition.

http://stackoverflow.com/a/3196189
type: Answer
answers question: http://stackoverflow.com/q/2628092
upvote count: 3
score: 3
has body: One solution I have seen used is to use triggers in the database to send a JMS message to your application. The message is then received in a MDB where the EclipseLink cache can be invalidated or refreshed. This approach works well on an Oracle database where the trigger drops messages into an AQ table. The are DBMS specific solutions I am familiar with but the challenge is always to get the change notification to include the table and PK values instead of a ROWID and also to ensure you are not being notified of changes you made yourself or have some way to easily filter out notices from your own changes. I believe GoldenGate helps to address this problem but have not yet tried it myself. Doug
downvote count: 0

http://stackoverflow.com/a/2756001
has body: I'd say that it is a really bad idea. A lot of code is implemented on the assumption that if you catch Error and Exception you have caught all possible exceptions. And most tutorials and textbooks will tell you the same thing. By creating a direct subclass of Throwable you are potentially creating all sorts of maintenance and interoperability problems. I can think of no good reason to extend Throwable. Extend Exception or RuntimeException instead. EDIT - In response to the OP's proposed scenario #1. Exceptions are a very expensive way of dealing with "normal" flow control. In some cases, we are talking thousands of extra instructions executed to create, throw and catch an exception. If you are going to ignore accepted wisdom and use exceptions for non-exceptional flow control, use an Exception subtype. Trying to pretend something is an "event" not an "exception" by declaring is as a subtype of Throwable is not going to achieve anything. However, it is a mistake to conflate an exception with an error, mistake, wrong, whatever. And there is nothing wrong with representing an "exceptional event that is not an error, mistake, wrong, or whatever" using a subclass of Exception. The key is that the event should be exceptional; i.e. out of the ordinary, happening very infrequently, ... In summary, a FlyingPig may not be an error, but that is no reason not to declare it as a subtype of Exception.
score: 37
has comment: http://stackoverflow.com/comment/2787449
has comment: http://stackoverflow.com/comment/39330963
answers question: http://stackoverflow.com/q/2755972
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2755972
has comment: http://stackoverflow.com/comment/2787434
type: Answer
has comment: http://stackoverflow.com/comment/2788309
has comment: http://stackoverflow.com/comment/2788628
has comment: http://stackoverflow.com/comment/32827255
upvote count: 37

http://stackoverflow.com/comment/35229795
comment on: http://stackoverflow.com/a/19425549
type: Comment
score: 2
has text: There could be a `try {} catch (Throwable t)` somewhere in the code that would hide such exceptions. And you could do `if (...)` (in some languages assertions are even coded like that), but what do you do in the error case? Either your if would just duplicate what assertions are doing, or you would lower the effect of them. One purpose of assertions is that they poke you in the eye and scream "FIX ME!!" until you do it. Assert vs laziness so to say.
type: AnswerComment

http://stackoverflow.com/q/2639167
tagged with: hash
has title: How to specify hash algorithm when updating LDAP via Java?
upvote count: 3
type: UnansweredQuestion
tagged with: java
has body: Is there a way to specify the hash algorithm (MD5, SHA1, etc.) to use for storing the passwords when you update an Open LDAP directory using Java APIs with code like this: private void resetPassword(String principal, String newPassword) throws NamingException { InitialDirContext ctxAdmin = null; Hashtable&lt;String, String&gt; ctxData = new Hashtable&lt;String, String&gt;(); ctxData.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); ctxData.put(Context.PROVIDER_URL, "ldap://myserver:389"); ctxData.put(Context.SECURITY_AUTHENTICATION, "simple"); ctxData.put(Context.SECURITY_PRINCIPAL, "admin_dn"); ctxData.put(Context.SECURITY_CREDENTIALS, "admin_passwd"); InitialDirContext ctxAdmin = new InitialDirContext(ctxData); if (newPassword == null || newPassword.equals("")) { String msg = "Password can't be null"; throw new NamingException(msg); } else { if (principal == null || principal.equals("")) { String msg = "Principal can't be null"; throw new NamingException(msg); } else { if (ctxAdmin == null) { String errCtx = "Can't get LDAP context"; throw new NamingException(errCtx); } } } BasicAttribute attr = new BasicAttribute("userpassword", newPassword); ModificationItem modItem = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, attr); ModificationItem[] items = new ModificationItem[1]; items[0] = modItem; ctxAdmin.modifyAttributes("cn=" + principal + ",ou=Users,dc=com", items); }
has answer: http://stackoverflow.com/a/2639246
type: Question
score: 3
has answer: http://stackoverflow.com/a/2644145
answer count: 2
downvote count: 0
favorite count: 0
tagged with: ldap

http://stackoverflow.com/comment/70138725
type: AnswerComment
has text: @Venki: Just read 4th paragraph of answer which tells something about dealing with user-controlled HTML.
type: Comment
comment on: http://stackoverflow.com/a/2658941
score: 0

http://stackoverflow.com/comment/37851984
score: 0
type: Comment
type: AnswerComment
has text: Digging up an old post, but the included link is dead. For any one seeing this in the future, here's a working version: http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
comment on: http://stackoverflow.com/a/2742398

http://stackoverflow.com/a/4372504
has body: http://groups.google.com/group/android-developers/browse_thread/thread/3911749addce534d They are working on pushing a fix now for 2.3 Edit: This has been fixed for 2.3 , go get the update via eclipse.
downvote count: 0
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/2687773

http://stackoverflow.com/a/2761001
has body: ...or perhaps i am not understanding the SwingWorker Class. You should be aware of the life-cycle of the SwingWorker. When you call execute, your processing will switch to a background thread and the current thread will return immediately. This is why your getImages does not return anything. From the javadoc: Workflow There are three threads involved in the life cycle of a SwingWorker : Current thread: The execute() method is called on this thread. It schedules SwingWorker for the execution on a worker thread and returns immediately. One can wait for the SwingWorker to complete using the get methods. Worker thread: The doInBackground() method is called on this thread. This is where all background activities should happen. To notify PropertyChangeListeners about bound properties changes use the firePropertyChange and getPropertyChangeSupport() methods. By default there are two bound properties available: state and progress. Event Dispatch Thread: All Swing related activities occur on this thread. SwingWorker invokes the process and done() methods and notifies any PropertyChangeListeners on this thread.
answers question: http://stackoverflow.com/q/2760811
downvote count: 0
type: Answer
upvote count: 1
score: 1

http://stackoverflow.com/a/2661909
upvote count: 1
type: AcceptedAnswer
has body: String pattern = "http://www.example.com/pk/[^/]+/?$"; I am assuming http://www.example.com/pk// is not accepted. If this should be accepted too, then use String pattern = "http://www.example.com/pk/[^/]*/?$";
has comment: http://stackoverflow.com/comment/2679357
has comment: http://stackoverflow.com/comment/2679253
type: Answer
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/2679322
has comment: http://stackoverflow.com/comment/2679250
has comment: http://stackoverflow.com/comment/2679355
answers question: http://stackoverflow.com/q/2661884
has comment: http://stackoverflow.com/comment/2679270
has comment: http://stackoverflow.com/comment/2679247
accepted answer of: http://stackoverflow.com/q/2661884

http://stackoverflow.com/comment/104981578
type: Comment
score: 3
type: AnswerComment
has text: Nice and well documented library
comment on: http://stackoverflow.com/a/49971795

http://stackoverflow.com/q/2749236
has answer: http://stackoverflow.com/a/51718306
has body: For my app, I need to record audio from MIC on an Android phone, and send it over TCP to the other android phone, where it needs to be played. I am using AudioRecord and AudioTrack class. This works great with a file - write audio to the file using DataOutputStream, and read from it using DataInputStream. However, if I obtain the same stream from a socket instead of a File, and try writing to it, I get an exception. I am at a loss to understand what could possibly be going wrong. Any help would be greatly appreciated. EDIT: The problem is same even if I try with larger buffer sizes (65535 bytes, 160000 bytes). This is the code: Recorder: int bufferSize = AudioRecord.getMinBufferSize(11025, , AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT); AudioRecord recordInstance = new AudioRecord(MediaRecorder.AudioSource.MIC, 11025, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT, bufferSize); byte[] tempBuffer = new byte[bufferSize]; recordInstance.startRecording(); while (/*isRecording*/) { bufferRead = recordInstance.read(tempBuffer, 0, bufferSize); dataOutputStreamInstance.write(tempBuffer); } The DataOutputStream above is obtained as: BufferedOutputStream buff = new BufferedOutputStream(out1); //out1 is the socket's outputStream DataOutputStream dataOutputStreamInstance = new DataOutputStream (buff); Could you please have a look, and let me know what is it that I could be doing wrong here? Thanks,
upvote count: 21
type: AnsweredQuestion
score: 21
tagged with: java
has answer: http://stackoverflow.com/a/2751413
has answer: http://stackoverflow.com/a/2752367
tagged with: dataoutputstream
type: Question
answer count: 3
downvote count: 0
favorite count: 0
tagged with: sockets
tagged with: android
accepted answer: http://stackoverflow.com/a/2752367
possible better answer: http://stackoverflow.com/a/51718306
has title: Android: Streaming audio over TCP Sockets

http://stackoverflow.com/a/2601061
score: 0
has body: You might want to have a look to Thrift: http://incubator.apache.org/thrift/
type: Answer
answers question: http://stackoverflow.com/q/2600077

http://stackoverflow.com/q/2753876
favorite count: 0
has answer: http://stackoverflow.com/a/2753941
type: Question
has answer: http://stackoverflow.com/a/2753914
has comment: http://stackoverflow.com/comment/2785002
has answer: http://stackoverflow.com/a/2753964
upvote count: 3
has comment: http://stackoverflow.com/comment/2784801
has answer: http://stackoverflow.com/a/2754165
tagged with: java
has comment: http://stackoverflow.com/comment/2784967
accepted answer: http://stackoverflow.com/a/2753964
has title: Why is my code not printing anything to stdout?
answer count: 5
has body: I'm trying to calculate the average of a student's marks: import java.util.Scanner; public class Average { public static void main(String[] args) { int mark; int countTotal = 0; // to count the number of entered marks int avg = 0; // to calculate the total average Scanner Scan = new Scanner(System.in); System.out.print("Enter your marks: "); String Name = Scan.next(); while (Scan.hasNextInt()) { mark = Scan.nextInt(); countTotal++; avg = avg + ((mark - avg) / countTotal); } System.out.print( Name + " " + avg ); } }
possible better answer: http://stackoverflow.com/a/2753886
type: AnsweredQuestion
score: 3
has answer: http://stackoverflow.com/a/2753886
downvote count: 0

http://stackoverflow.com/comment/2756906
type: Comment
comment on: http://stackoverflow.com/a/2729235
has text: Nothing happened, it still produces the same sql.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/49688149
comment on: http://stackoverflow.com/a/2647265
has text: Did you mean `counters.containsKey(newEl)`
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/2798702
comment on: http://stackoverflow.com/a/2765578
type: AnswerComment
score: 0
has text: Are you sure you are looking at the right file? Have you used the full path? Do you have the right permissions?
type: Comment

http://stackoverflow.com/comment/2753997
score: 0
comment on: http://stackoverflow.com/a/2719282
type: Comment
has text: Of course there is a guarantee. See the RFC. It is enforced by checksums.
type: AnswerComment

http://stackoverflow.com/q/2747146
has body: I get a NullPointerException calling a Superclass Method in Subclass Inner Class Constructor... What's the Deal? In my application's main class (subclass of Application), I have a public inner class that simply contains 3 public string objects. In the parent class I declare an object of that inner class. public class MainApplication extends Application { public class Data { public String x; public String y; public String z; } private Data data; MainApplication() { data = new Data() data.x = SuperClassMethod(); } } After I instantiate the object in the constructor, I get a runtime error when I try to assign a value in the inner class with a superclass method. Any idea what's up here?? Can you not call superclass methods in the subclass constructor? ** Edit ** Original question was about inner class member assignment in outer class constructor. Turned out the issue was with calling a superclass method in the class's constructor. It was giving me a null pointer exception. Thus, the question has changed.
has comment: http://stackoverflow.com/comment/2780991
has comment: http://stackoverflow.com/comment/2777309
tagged with: constructor
has answer: http://stackoverflow.com/a/2747250
has answer: http://stackoverflow.com/a/2747297
tagged with: android
possible better answer: http://stackoverflow.com/a/2747265
has comment: http://stackoverflow.com/comment/2789749
has answer: http://stackoverflow.com/a/2747265
has comment: http://stackoverflow.com/comment/2777293
tagged with: java
type: Question
has title: Issue calling superclass method in subclass constructor
type: AnsweredQuestion
score: 0
has comment: http://stackoverflow.com/comment/2780234
answer count: 3
accepted answer: http://stackoverflow.com/a/2747250

http://stackoverflow.com/comment/2677144
comment on: http://stackoverflow.com/a/2651651
has text: Will Flash be able to give you the full path and directory structure??
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/2631124
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/2648885
score: 1
tagged with: row-number
tagged with: java
has title: Oracle rownum in db2 - Java data archiving
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/2734852
tagged with: db2
answer count: 2
has answer: http://stackoverflow.com/a/2642844
downvote count: 0
favorite count: 0
has body: I have a data archiving process in java that moves data between db2 and sybase. FYI - This is not done through any import/export process because there are several conditions on each table that are available on run-time and so this process is developed in java. Right now I have single DatabaseReader and DatabaseWriter defined for each source and destination combination so that data is moved in multiple threads. I guess I wanted to expand this further where I can have Multiple DatabaseReaders and Multiple DatabaseWriters defined for each source and destination combination. So, for example if the source data is about 100 rows and I defined 10 readers and 10 writer, each reader will read 10 rows and give them to the writer. I hope process will give me extreme performance depending on the resources available on the server [CPU, Memory etc]. But I guess the problem is these source tables do not have primary keys and it is extremely difficult to grab rows in multiple sets. Oracle provides rownum concept and i guess the life is much simpler there....but how about db2? How can I achieve this behavior with db2? Is there a way to say fetch first 10 records and then fetch next 10 records and so on? Any suggestions / ideas ? Db2 Version - DB2 v8.1.0.144 Fix Pack Num - 16 Linux

http://stackoverflow.com/comment/2787692
has text: +1… but maybe "if you implement the pop function in C++, you should follow the standard container interface."
score: 2
comment on: http://stackoverflow.com/a/2756265
type: AnswerComment
type: Comment

http://stackoverflow.com/a/2782246
has comment: http://stackoverflow.com/comment/17619697
has body: I've found Powershell Bridge (PSB). Still need to look into it though
score: 0
type: Answer
answers question: http://stackoverflow.com/q/2629511

http://stackoverflow.com/comment/66457276
has text: @Kevin Crowell What is the filetype of this file?
comment on: http://stackoverflow.com/a/2609474
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/2671560
type: AcceptedAnswer
upvote count: 9
type: Answer
has body: The Apache MINA Networking framework is built on NIO (and is used by many applications to provide high-performance networking). Apache MINA is a network application framework which helps users develop high performance and high scalability network applications easily. It provides an abstract · event-driven · asynchronous API over various transports such as TCP/IP and UDP/IP via Java NIO. Apache MINA is often called: NIO framework · library, client · server framework · library, or a networking · socket library. However, it's much more than that. Please take a look around the list of the features that enable rapid network application development, and what people says about MINA. Please grab yourself a download, try our Quick Start Guide, surf our FAQ or start join us on our community I believe JETTY uses continuations to support 5000+ HTTP Comet connections using Servlet 3.0 continuations. Also you can look at a BlazeDS NIO implementation (basically an opensource LCDS). http://blogs.webtide.com/athena/entry/asynchronous_blazeds_polling_with_jetty
has comment: http://stackoverflow.com/comment/26253634
downvote count: 0
answers question: http://stackoverflow.com/q/2671520
score: 9
accepted answer of: http://stackoverflow.com/q/2671520
has comment: http://stackoverflow.com/comment/29974484

http://stackoverflow.com/q/2714314
has answer: http://stackoverflow.com/a/2716888
possible better answer: http://stackoverflow.com/a/2716888
has body: I am creating an application using Griffon->SwingBuilder. I would like to able to center the application on the desktop. I know we have the 'location: [x,y]' argument we can provide on application creation. Is there anyway to access desktop properties to calculate the center?
type: AnsweredQuestion
score: 3
accepted answer: http://stackoverflow.com/a/2717416
upvote count: 3
tagged with: java
tagged with: griffon
type: Question
answer count: 2
downvote count: 0
favorite count: 0
tagged with: swingbuilder
has answer: http://stackoverflow.com/a/2717416
has title: Swingbuilder - application location centering

http://stackoverflow.com/q/2655405
tagged with: c++
score: 2
type: AnsweredQuestion
upvote count: 2
accepted answer: http://stackoverflow.com/a/2657347
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/2657360
has title: win32 read java preference from c++ code
has answer: http://stackoverflow.com/a/2655435
possible better answer: http://stackoverflow.com/a/2657360
answer count: 3
downvote count: 0
has answer: http://stackoverflow.com/a/2657347
has body: One of our program writes program information(window title, memory etc) in Java Preferences. On windows this is available under registry. How can I read the values written by Java program using c (or c++). Looks like API I should use is RegGetValue. Is this guaranteed to work on Windows XP 32 bit? The String written by java is UTF-8 encoded. How do I read such strings in windows (win32 or vc++) Cheers, Jayan
favorite count: 0
tagged with: preferences
tagged with: windows
tagged with: utf-8

http://stackoverflow.com/comment/2739168
has text: The real question is how you could test this empirically. The answer to your question is 2, though: `x` and `m`. But I doubt the GC would fire before the program ends.
comment on: http://stackoverflow.com/q/2714066
type: Comment
score: 1
type: QuestionComment

http://stackoverflow.com/q/2723581
downvote count: 0
tagged with: java
has answer: http://stackoverflow.com/a/2723611
type: Question
score: 5
has body: How does jvm know what class an object is an instance of at runtime. I know we can use the getClass method to get the class name but how does the getClass method work? Thx, Praveen.
has answer: http://stackoverflow.com/a/26156517
has title: How does JVM know class of an object at runtime
has answer: http://stackoverflow.com/a/2723908
tagged with: jvm
answer count: 4
favorite count: 0
upvote count: 5
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2723933

http://stackoverflow.com/comment/2745807
score: 0
type: QuestionComment
type: Comment
has text: I edited my question to include the web.xml and applicaton.xml parts. I'm using a Servlet Filter because that's how it was setup in this company, I had to reuse that code. Nothing is keeping me from doing it differently though. Would that solve my problem you think?
comment on: http://stackoverflow.com/q/2715499

http://stackoverflow.com/a/2746666
has comment: http://stackoverflow.com/comment/2776861
type: Answer
upvote count: 16
has comment: http://stackoverflow.com/comment/2776272
score: 16
accepted answer of: http://stackoverflow.com/q/2746578
answers question: http://stackoverflow.com/q/2746578
has comment: http://stackoverflow.com/comment/2776444
has body: At a high level, the win from Log4j over manual logging is that you can decouple your logging code from what you actually want to log and where and how you want to log it. Details about logging verbosity/filtering, formatting, log location, and even log type (files, network, etc.) are handled declaratively using configuration and extensibly via custom appenders, rather you having to code that flexibility yourself. This is critically important because it's often hard for developers to predict how logging needs will change once their software is in production. Operations teams managing that software may need less verbose logs, may need mulitple logs, may need to ship those logs to multiple servers, may need to sometimes get really verbose data for troubleshooting, etc. And it's usually impossible for operations teams, if they need to change how logging works, to convince the developer to make big code changes. This often leads to production downtime, friction between operations and development, and wasted time all around. From the developer's point of view, Log4j insulates you from having to make code changes to support logging, and insulates you from being pestered by people who want logging changes. It enables people managing your code to scratch their own itch rather than bugging you! Also, since Log4j is the de-facto standard for Java logging, there are lots of tools available which can do cool things with Log4j-- furthermore preventing you and your operations teams from re-inventing the wheel. My favorite feature is the ability to easily write appenders send data to non-file sources, like SYSLOG, Splunk, etc. which makes it easy to your app's custom logging into operations management tools your IT department is already using.
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/22218032
comment on: http://stackoverflow.com/a/3437839
type: AnswerComment
has text: Yes, you should dynamically calculated when the nodes are in the boundaries of the visible part of the screen.
score: 0
type: Comment

http://stackoverflow.com/comment/2669279
has text: @bog: um... by holding a reference to it?
type: AnswerComment
type: Comment
score: 0
comment on: http://stackoverflow.com/a/2652217

http://stackoverflow.com/a/2689144
has comment: http://stackoverflow.com/comment/2710097
score: 0
answers question: http://stackoverflow.com/q/2689101
has body: What would be even worse in an architectural sense is if the thread never finished, and you had to arbitrarily kill it to stop it from executing. Place a loop inside your run() method if you want it to execute a routine more than once. You can use a callback method to send data/signals back to the calling thread, and react on them when they occur.
type: Answer

http://stackoverflow.com/a/2716025
downvote count: 1
has body: The behavior is probably undefined since ArrayList isn't threadsafe. If you modify the list while an Iterator is interating over it then you will get a ConcurrentModificationException. You can wrap the ArrayList with Collection.synchronizedList or use a thread-safe collection (there are many), or just put the add calls in a synchronized block.
upvote count: 4
answers question: http://stackoverflow.com/q/2715983
type: Answer
score: 3

http://stackoverflow.com/q/2743704
upvote count: 5
tagged with: java
tagged with: pojo
type: Question
score: 5
accepted answer: http://stackoverflow.com/a/2743748
answer count: 1
downvote count: 0
tagged with: jsp
favorite count: 0
has title: Is dependency injection possible for JSP beans?
has body: This may be a long shot question.. I am working on an application that is based on JSP/Javascript only (without a Web framework!) Is there a way to have depencency injection for JSP beans? By jsp beans I mean beans defined like this &lt;jsp:useBean id="cart" scope="session" class="session.Carts" /&gt; Is there a way/library/hack to intercept the bean creation so that when "cart" is referenced for the first time, some some of injection takes place? Can I define somewhere a "listener" for JSP beans (like you can do for JSF beans for example)? I am free to do anything I want in the back-end, but I cannot add a web framework in the front-end (Don't ask!)
has answer: http://stackoverflow.com/a/2743748
type: AnsweredQuestion
tagged with: dependency-injection

http://stackoverflow.com/comment/2741709
type: Comment
has text: Possibly a bit off topic, but instead of having a method accept a boolean to know if it should use one flow or another, I'd recommend using two methods. You gain clarity (if your methods are properly named) and you get rid of one parameter.
type: QuestionComment
comment on: http://stackoverflow.com/q/2716002
score: 4

http://stackoverflow.com/comment/2758433
comment on: http://stackoverflow.com/a/2726076
has text: I don't see how ScheduledExecutorService can be easily used for this. It's all about scheduling start of the job, no easy way to cancel it after certain period. An example will help.
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/78314072
type: Comment
score: 1
has text: Any specific reason to use `custom.mytag` ? What will happen when there is a `dot`, can we read and separate those names or something , or is it just to clearly state the name.
type: AnswerComment
comment on: http://stackoverflow.com/a/7428109

http://stackoverflow.com/a/7515717
answers question: http://stackoverflow.com/q/2730365
type: Answer
has body: Alternatively, you could simply offer a setter in your MyNumberServer rule instead of giving the folder in the constructor. Furthermore, ordering amongst rules is not guaranteed the way you described. It can become a little tricky, especially when you want some communication between your rules, see e.g. Best way of logging exceptions when tests fail (e.g. using a junit rule).
score: 0

http://stackoverflow.com/comment/2818660
type: Comment
comment on: http://stackoverflow.com/a/2783206
has text: So you never get as far as "GenMic closed OutputStream," right? You must be getting an exception, could you show us that? otherwise I'd try waiting on closing the output stream until after reading everything from the inputstream, but that's just a guess.
type: AnswerComment
score: 0

http://stackoverflow.com/q/2709928
has body: is it possible to change external class field accesses in Java to getter / setter calls automatically, and also hide the exposed fields? I'm using Javabeans and I want change notifications when a field property changes (this is important). I've found cglib which can automatically insert the property change call to the PropertyChangeSupport field. I know about Project Lombok, but this appears to modify the source code, and additionally doesn't support field access modification. Perhaps with modifications to Lombok, this could be supported, or are there other solutions? Cheers and thanks in advance, Chris
answer count: 2
downvote count: 0
has title: Change field access to getter / setter method access
tagged with: getter
has answer: http://stackoverflow.com/a/2710005
has comment: http://stackoverflow.com/comment/2734329
favorite count: 0
has answer: http://stackoverflow.com/a/2710349
has comment: http://stackoverflow.com/comment/2734413
upvote count: 2
tagged with: field
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/2734403
has comment: http://stackoverflow.com/comment/2734395
score: 2
tagged with: java
tagged with: setter
type: Question

http://stackoverflow.com/comment/82779039
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/11120538
has text: @StevenMarkFord so does Bus pattern still holds true til this day? I am trying to improve a codebase with a code like this accessing data between activities: `BookActivity.getInstance().recommendationResponse` in `RoomsActivity`

http://stackoverflow.com/a/2639829
has comment: http://stackoverflow.com/comment/2672043
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2639636
type: Answer
has body: This is half of an answer: You have an unused field declared in that class. FindBugs uses static analysis of byte code to find bugs; unfortunately, the byte code format does not store line numbers for class or member fields, so FindBugs can't actually report a line number. There's got to be some switch that will allow it to output more helpful information (i.e. the name of the field), but I have no idea. Alternatively, you might try PMD, which is a lot noisier, but actually analyzes the source code and also integrates with Hudson. Did a little more digging and it looks like this is probably a bug in the inspector for that bug pattern. Assuming that your FindBugs run is configured with a n appropriate source directory (i.e., using -sourcepath), the majority of the bugs found should have line numbers associated with them. To check this, open the outputted report. You should see elements like the following: &lt;!-- skipping a bit --&gt; &lt;BugInstance type="..."&gt; &lt;Class classname="com.example.MyClass"&gt; &lt;!-- ... --&gt; &lt;/Class&gt; &lt;!-- ... --&gt; &lt;SourceLine classname="com.example.MyClass" start="5" end="5" sourcefile="MyClass.java"/&gt; &lt;/BugInstance&gt; The key there is the &lt;SourceLine classname="..."/&gt;, which reports the line number that the bug was found on. For numerous other inspections, including those for unread fields and a couple of other cases where their are no line numbers in the byte code, this line is filled in correctly, but not for UUF_UNUSED_FIELD. Hence, the Hudson plugin is doing the sensible thing and reporting line = -1. The Eclipse plugin, however, which has access to Eclipse's rich metadata about the source code is able to locate the field by matching the field name, hence, it appearing to work in Eclipse (if you delete the field in question in Eclipse you should see the bug show up on the first line of the file; other bugs show up on the line number specified in the XML report). No fix, but hopefully that clarifies…
has comment: http://stackoverflow.com/comment/2670271
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/2689777
accepted answer of: http://stackoverflow.com/q/2639636
has comment: http://stackoverflow.com/comment/2672392

http://stackoverflow.com/comment/2789756
type: AnswerComment
comment on: http://stackoverflow.com/a/2758177
score: 0
type: Comment
has text: structure = (Map) YAML.load(new FileReader(structurefn)); // load the structure file is all that is happening

http://stackoverflow.com/q/2642371
tagged with: dll
tagged with: java-native-interface
has body: I am new to JNI. And have a few questions : Can JNI handle every type dll exists in windows? I wanted to link a library but it gives me error. Is it possible JNI and the dll are not compatible? Excerpt from VB .NET (It works) Private Declare Function ConnectReader Lib "rfidhid.dll" () As Integer Private Declare Function DisconnectReader Lib "rfidhid.dll" () As Integer Private Declare Function SetAntenna Lib "rfidhid.dll" (ByVal mode As Integer) As Integer Full Code From Java public class MainForm { /** * @param args */ public native int ConnectReader(); public static void main(String[] args) { // TODO Auto-generated method stub MainForm mf = new MainForm(); System.out.println(mf.ConnectReader()); } static { System.loadLibrary("rfidhid"); } } Error code shown Exception in thread "main" java.lang.UnsatisfiedLinkError: MainForm.ConnectReader()I at MainForm.ConnectReader(Native Method) at MainForm.main(MainForm.java:13) Can anyone point to me where I might do wrong? EDIT: Turn out I should be doing this (and it works) import com.sun.jna.Library; import com.sun.jna.Native; public class HelloWorld { public interface MyLibrary extends Library { public int ConnectReader(); } public static void main(String[] args) { Kernel32 lib = (MyLibrary) Native.loadLibrary("rfidhid", MyLibrary.class); System.out.println(lib.ConnectReader()); } }
answer count: 1
downvote count: 0
has answer: http://stackoverflow.com/a/2642390
favorite count: 0
has title: Can JNI handle any dll files (Windows)?
score: 2
upvote count: 2
accepted answer: http://stackoverflow.com/a/2642390
tagged with: java
type: Question
type: AnsweredQuestion

http://stackoverflow.com/a/2693119
accepted answer of: http://stackoverflow.com/q/2674120
answers question: http://stackoverflow.com/q/2674120
type: Answer
has body: Play is very good example of MVC framework. Even more then convension-over-configuration principle i like its short edit-run cycle. Another good example of MVC framework on JVM with short edit-run cycle is Grails, though it's for Groovy langauge, not Java itself.
score: 5
type: AcceptedAnswer
upvote count: 5
downvote count: 0

http://stackoverflow.com/comment/43037485
type: Comment
score: 0
comment on: http://stackoverflow.com/q/2764234
has text: I found a way to separate an inner class into an external file, maybe it helps ? http://stackoverflow.com/q/27284667/1190665
type: QuestionComment

http://stackoverflow.com/comment/33175812
comment on: http://stackoverflow.com/a/2600756
has text: Oh I also forgot speaking about your insulting word "dude". You also made false assertions about the fact I would hae not read the implementation of Hashmap in the JDK. I have read it since many years and even found that its implementation was really poor for many frequently used cases (but the worst thing is the very poor implementation of the hash() method for boxed native types; notably number types). Definitely you'll want to reconsider the use of the default SLOW/INEFFICIENT Hashmap and implement a better Map.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/2773805
has body: Since you're talking about GB's, I would rather prioritize the memory usage in the consideration. SAX needs about 2 times of memory as the document big is, while DOM needs it to be at least 5 times. So if your XML file is 1GB big, then DOM would require a minimum of 5GB of free memory. That's not funny anymore. So SAX (or any variant on it, like StAX) is the best option here. If you want the most memory efficient approach, look at VTD-XML. It requires only a little more memory than the file big is.
upvote count: 3
type: Answer
has comment: http://stackoverflow.com/comment/2807577
downvote count: 0
answers question: http://stackoverflow.com/q/2773733
score: 3
has comment: http://stackoverflow.com/comment/2807552

http://stackoverflow.com/a/5024508
score: 1
answers question: http://stackoverflow.com/q/2689122
upvote count: 1
type: Answer
has body: Actually you can auto-generate a SOAP like stub for JAX-RS but it uses WADL which I believe is a WSDL variant. Apache CXF does this and if that doesn't work for you it will also automatically create SOAP endpoints and SOAP clients.
downvote count: 0

http://stackoverflow.com/q/2621065
tagged with: user-interface
has answer: http://stackoverflow.com/a/2621328
type: UnansweredQuestion
has body: 1. JTextArea messages = new JTextArea(5, 30); 2. JScrollPane scrollTextBox = new JScrollPane(messages, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED ); 3. Container window; 4. ... 5. messages.setPreferredSize(new Dimension(500,100)); 6. messages.setLineWrap(true); 7. messages.add(scrollTextBox, BorderLayout.CENTER); 8. window.add(messages); 9. 10. I'm trying to write a text box within a GUI box that returns messages from a server, it needs a scroll bar because messages are continually being sent but at the moment only the first few lines are visible and the rest aren't because i can't get the scroll to work. 11. my attempts before have either resulted in this error: 12. java.lang.IllegalArgumentException: adding container's parent to itself 13. at java.awt.Container.checkAddToSelf(Unknown Source) 14. at java.awt.Container.addImpl(Unknown Source) 15. at java.awt.Container.add(Unknown Source) 16. at LODGUI.drawAndShow(LODGUI.java:91) 17. at LODClient.run(LODClient.java:94) 18. at LODClient.main(LODClient.java:157) 19. 20. or no change and no scroll bar.
has title: GUI Text box scrollbar help
tagged with: java
tagged with: scroll
tagged with: scrollbar
has comment: http://stackoverflow.com/comment/2633412
type: Question
answer count: 2
score: 0
has answer: http://stackoverflow.com/a/2621158

http://stackoverflow.com/comment/7155555
has text: (I have found, upon feeding it into a parser generator, that the grammar contains numerous errors.)
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2661210
score: 1

http://stackoverflow.com/a/2753013
score: 1
upvote count: 1
has body: URLs can contain anything, but it should be encoded. In Java you can use URLEncoder and URLDecoder to encode and decode urls with the desired character encoding. Have in mind that these classes are actually meant for HTML form encoding, but they can be applied to the query string (the parameters) of the URLs, so do not use them on the whole URLs - only on the parameters.
has comment: http://stackoverflow.com/comment/2784383
accepted answer of: http://stackoverflow.com/q/2752965
has comment: http://stackoverflow.com/comment/2784155
answers question: http://stackoverflow.com/q/2752965
type: AcceptedAnswer
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/2784185

http://stackoverflow.com/comment/3340776
type: AnswerComment
score: 0
type: Comment
has text: No, it's related to Eclipse's way of handling plugins. Fortunately no synchronization involved!
comment on: http://stackoverflow.com/a/2705452

http://stackoverflow.com/comment/2769060
type: Comment
type: QuestionComment
score: 0
has text: Most web servers support persistent connections. This speeds up things when downloading the resources (images, css...) for a page.
comment on: http://stackoverflow.com/q/2739869

http://stackoverflow.com/comment/2727770
has text: I don't know "someObject". It is instantiated in the method I want to test. Think of a method "createImage(InputStream image)" (cut) which internally calls a "Image filter(Image imge)" (mock).
comment on: http://stackoverflow.com/a/2667240
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/a/2724064
has body: Sounds to me like a service locator. This pattern uses a central registry known as the "service locator" which on request returns the information necessary to perform a certain task.
downvote count: 0
type: Answer
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/2723899

http://stackoverflow.com/a/2956910
answers question: http://stackoverflow.com/q/2736646
score: 0
type: Answer
has body: I do not know specifically for graphs, but the usual options are Only process what is actually shown on screen (zoom in) Hide details when zooming out Only update part of the screen that have actually changed content (move a node)

http://stackoverflow.com/a/2756788
upvote count: 4
has body: Note that the cast has a higher precedence than the + operator. Your code does this: byte a = 50; byte b = 40; byte sum = ((byte)a) + b; System.out.println(sum); The cast is redundant, since a is already a byte. You probably meant this: byte a = 50; byte b = 40; byte sum = (byte) (a + b); System.out.println(sum);
answers question: http://stackoverflow.com/q/2756717
has comment: http://stackoverflow.com/comment/2788320
downvote count: 0
type: Answer
score: 4

http://stackoverflow.com/a/2678167
answers question: http://stackoverflow.com/q/2677079
type: Answer
upvote count: 4
downvote count: 0
has comment: http://stackoverflow.com/comment/2717842
has body: Short answer: external clients don't get to use the authentication alias data Longer Answer: From the WAS J2C connection factory documentation: The alias that you configure for component-managed authentication does not apply to all clients that must access the secured resource. External Java clients with Java Naming and Directory Interface (JNDI) access can look up a Java 2 Connector (J2C) resource such as a data source or Java Message Service (JMS) queue. However, they are not permitted to take advantage of the component-managed authentication alias defined on the resource. This alias is the default value that is used when the getConnection() method does not specify any authentication data, like user and password, or a value for ConnectionSpec. If an external client needs to get a connection, it must assume responsibility for the authentication by passing it through arguments on the getConnection() call.
score: 4
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2677079

http://stackoverflow.com/comment/2644907
comment on: http://stackoverflow.com/a/2631497
type: AnswerComment
type: Comment
score: 0
has text: Sorry Paulo. I was joking... There is a well-respected .NET book called CLR via C#. I thought mentioning JVM via .NET might entertain some people. Sorry for the confusion. And i meant that as an alternate title to the article.

http://stackoverflow.com/a/2632501
has body: You should be able to to break it into four cases based on the sign of the numbers: If one of the numbers is zero, the answer is the other number. If one is positive and another negative, then you can't over or underflow. If both are positive you can only overflow. If both are negative you can only underflow. Just do an extra calculation for the last two cases to see if it will result in the undesired case: if(x == 0 || y == 0 || (x &gt; 0 ^ y &gt; 0)){ //zero+N or one pos, another neg = no problems return x+y; }else if(x &gt; 0){ //both pos, can only overflow return Long.MAX_VALUE - x &lt; y ? Long.MAX_VALUE : x+y; }else{ //both neg, can only underflow return Long.MIN_VALUE - x &gt; y ? Long.MIN_VALUE : x+y; }
type: Answer
accepted answer of: http://stackoverflow.com/q/2632392
answers question: http://stackoverflow.com/q/2632392
downvote count: 0
score: 6
upvote count: 6
type: AcceptedAnswer

http://stackoverflow.com/q/2769155
favorite count: 0
tagged with: jtable
has title: get value from jtable
has answer: http://stackoverflow.com/a/2769440
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/2802292
downvote count: 0
score: 1
tagged with: java
type: Question
upvote count: 1
answer count: 1
has body: I have a jtable and I want the user to fill its cells then i get what he wrote! the problem is when i try getValueAt(row index,col index ) the programe give me null , and i am sure that the cell i choose has a value . following show how i create the table String s = JOptionPane.showInputDialog(null, "Enter number of rows"); int row = Integer.parseInt(s); Vector v = new Vector(); v.add("URL"); DefaultTableModel Dm = new DefaultTableModel(v, row); jTable1.setModel(Dm);

http://stackoverflow.com/q/2784831
answer count: 1
tagged with: debugging
tagged with: java
has answer: http://stackoverflow.com/a/2791475
tagged with: eclipse
has title: Is there a good way to add Equinox source to Eclipse to help debugging an OSGi bundle?
type: AnsweredQuestion
type: Question
accepted answer: http://stackoverflow.com/a/2791475
has body: I am banging my head against a mess of JNI code and DLLs that we are trying to shoehorn into an OSGi bundle. It has been particularly hard to get good debugging info out of the system and I have spent too much time stepping through raw byte code trying to infer what is happening inside equinox--when I really don't care--I am just not getting useful errors out. It would be great if I could have easy access to the equinox source in the debugger to see why and where it was loading what. The simple answer of downloading all the source and building my own Eclipse would be one solution, but it feels very heavy handed. Is there a "grab source" repo I could go to and install from or some such thing? It just feels like there should be an easier way to go about this. Something akin to using the debug libraries or installing the SRPM in another situation.
tagged with: equinox
score: 0

http://stackoverflow.com/a/6105621
has comment: http://stackoverflow.com/comment/69690161
type: Answer
score: 2
upvote count: 2
has body: try to add properties.setProperty("mail.smtp.starttls.enable", "true");
answers question: http://stackoverflow.com/q/2732640
downvote count: 0

http://stackoverflow.com/q/2597841
downvote count: 0
has comment: http://stackoverflow.com/comment/2606548
tagged with: java
score: 16
has answer: http://stackoverflow.com/a/43253115
type: Question
has answer: http://stackoverflow.com/a/21179756
upvote count: 16
has answer: http://stackoverflow.com/a/2597852
answer count: 6
accepted answer: http://stackoverflow.com/a/2597939
tagged with: char
has answer: http://stackoverflow.com/a/14677387
has title: Scanner method to get a char
possible better answer: http://stackoverflow.com/a/2597852
favorite count: 0
has answer: http://stackoverflow.com/a/2597939
has answer: http://stackoverflow.com/a/2597991
has body: What is the Scanner method to get a char returned by the keyboard in Java. like nextLine() for String, nextInt() for int, etc.
type: AnsweredQuestion
tagged with: java.util.scanner

http://stackoverflow.com/a/2614950
has body: It sounds like it is being handled by the throw. By calling throw, you are telling Java "exit the program and print out the InvalidStartingStonesException". It sounds like this is what is happening. If you had the following: catch(InvalidStartingStonesException{ // code to handle the exception goes here } Then the program would run your error handling code. If this exception extended IOException you already have a catch there that would print the exception.
score: 0
type: Answer
answers question: http://stackoverflow.com/q/2614930

http://stackoverflow.com/q/2657557
tagged with: struts
has answer: http://stackoverflow.com/a/2657676
downvote count: 0
score: 1
favorite count: 0
tagged with: download
type: Question
answer count: 2
has title: JAVA: multiple files download at the same time?
has answer: http://stackoverflow.com/a/2657698
tagged with: java
upvote count: 1
has body: Is there any methods for downloading multiple files at the same time? That is, after select multiple files, click the download button, and choose the destination directory, the files selected will be downloaded at the same time. i googled it and not find any solutions, can anybody know? im using struts1 and spring2.
type: UnansweredQuestion

http://stackoverflow.com/a/3348311
type: Answer
score: 2
answers question: http://stackoverflow.com/q/2727382
downvote count: 0
has body: I encountered this problem also, I found out the exception isn't related with the error file at all, the problem is from another query for example: @NamedQuery(name = "ChannelType.ALL", query = "SELECT channelType FROM ChannelType channelType WHERE channelType.applicationClient.applicationClientId =:applicationClientId ORDER BY channelType.channelTypId ASC") the problem is from "ORDER BY channelType.channelTypId" its not except to order by primary key ,when I remove this line the exception just gone also. Maybe someone else could explain why this happen. Thanks
upvote count: 2

http://stackoverflow.com/comment/103421282
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2758224
has text: @Yiashai Assertions are off by default so they will most likely be off in production, which is the right way to use them. They're strictly a development phase tool. They're very helpful in catching bugs in development, which is where you're most likely to see bugs.
score: 0

http://stackoverflow.com/comment/2677670
type: Comment
score: 0
has text: How would I match any character but the < character?
type: AnswerComment
comment on: http://stackoverflow.com/a/2660441

http://stackoverflow.com/q/2632631
tagged with: java
has title: Help with Java thread dump of partially hanged j2ee server
score: 4
accepted answer: http://stackoverflow.com/a/2632888
upvote count: 4
answer count: 1
downvote count: 0
favorite count: 0
has body: Our J2ee server (which will remain nameless for embarrassment reasons) slows down drastically from time to time. I have managed to create a thread dump. And trying to analyze it. One of the things that I don't understand is some waiting on locks without finding the locking thread. Here is part of the stack trace of such thread: waiting for monitor entry [] at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:781) - waiting to lock &lt;0xsomenumber&gt; (a org.apache.commons.pool.impl.GenericObjectPool) at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:96) at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880) The somenumber number is only wait upon. I don't see anything locking it. How can that be? Thanks. Update with some more detailed: the jdk version is 1.4.2.05
has answer: http://stackoverflow.com/a/2632888
type: AnsweredQuestion
tagged with: stack-trace
type: Question
tagged with: jakarta-ee
tagged with: debugging

http://stackoverflow.com/a/2854442
has body: A guess, but try running Typeface_renderDocument() in a DeferredCommand -- perhaps those style changes aren't visible in the DOM at the point that the JS executes.
type: Answer
score: 0
answers question: http://stackoverflow.com/q/2751741

http://stackoverflow.com/comment/18158709
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/13292073
type: Comment
has text: I understand the desire to extend the class to take care of this behavior; though, it doesn't seem to scale well. getSuitableCage is just one possible behavior that could be added. There's a huge number of possible gets you might want. eg. getSuitableHairBrush, getVetSpecialist, getSuitableBlanket, getSuitableBedding, getSuitableTrainer, etc. The list can be quite large. Adding them all to the Animal class could bloat the class.

http://stackoverflow.com/q/2619335
has answer: http://stackoverflow.com/a/2619344
type: Question
tagged with: java
has body: I've got a lot of experience in Java but none developing mobile apps. I'd like to write an application using Java/Swing and then convert it for use on an Android phone. Is this feasible or do I really need to develop from the ground up for the Android platform? I don't own an Android phone as I can't afford one at the moment, and the Android emulator is so slow that I find myself wasting a lot of time sitting around waiting.
has answer: http://stackoverflow.com/a/2620138
has answer: http://stackoverflow.com/a/2619342
type: UnansweredQuestion
tagged with: android
has title: Can I write an Android app in Java and convert it later?
answer count: 4
score: 0
has answer: http://stackoverflow.com/a/11279184

http://stackoverflow.com/a/2781193
has comment: http://stackoverflow.com/comment/2816509
has body: Java can't do LINQ. It doesn't even come close, due to the lack of lambdas, yield, extension methods and expression trees. The quaere project offers a poor-man's substitute. I don't think this will satisfy your algorithmic efficiency requirements, however. These can only be done in one of two ways, AFAIK: Hand-coded data structures, optimised for the questions you want to ask. In-memory HSQLDB. The former is hard, but likely to yield the best performance. The latter won't be as fast, but it will be OK, especially if properly tuned with indexes, and much simpler to work with.
type: Answer
answers question: http://stackoverflow.com/q/2781100
downvote count: 0
score: 1
upvote count: 1

http://stackoverflow.com/q/2598219
has answer: http://stackoverflow.com/a/2598291
upvote count: 23
type: Question
accepted answer: http://stackoverflow.com/a/2599114
has title: Java: why can't iterate over an iterator?
has answer: http://stackoverflow.com/a/2598260
linked to: http://stackoverflow.com/q/839178
tagged with: java
answer count: 6
tagged with: iterator
downvote count: 0
tagged with: iterable
favorite count: 0
possible better answer: http://stackoverflow.com/a/2598254
linked to: http://stackoverflow.com/q/27240
linked to: http://stackoverflow.com/q/31702989
has answer: http://stackoverflow.com/a/2598254
has body: I read Why is Java's Iterator not an Iterable? and Why aren't Enumerations Iterable?, but I still don't understand why this: void foo(Iterator<X> it) { for (X x : it) { bar(x); baz(x); } } was not made possible. In other words, unless I'm missing something, the above could have been nice and valid syntactic sugar for: void foo(Iterator<X> it) { for (X x; it.hasNext();) { x = it.next(); bar(x); baz(x); } }
has answer: http://stackoverflow.com/a/2598308
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/20129762
has answer: http://stackoverflow.com/a/2599114
has answer: http://stackoverflow.com/a/31704850
score: 23

http://stackoverflow.com/a/2780103
answers question: http://stackoverflow.com/q/2779251
has comment: http://stackoverflow.com/comment/10528996
downvote count: 11
upvote count: 8
has body: JSONObject typically uses HashMap internally to store the data. So, you can use it as Map in your code. Example, JSONObject obj = JSONObject.fromObject(strRepresentation); Iterator i = obj.entrySet().iterator(); while (i.hasNext()) { Map.Entry e = (Map.Entry)i.next(); System.out.println("Key: " + e.getKey()); System.out.println("Value: " + e.getValue()); }
score: -3
type: Answer

http://stackoverflow.com/a/2749472
answers question: http://stackoverflow.com/q/2745193
has body: I agree with the other answers, and would like to explain one point further: Class objects represent classes that are loaded into the JVM memory. Each class object is actually an in-memory instance of a .class file. Java generics are not separate classes. They are just a part of the compile-time type-checking mechanism. Therefore, they have no run-time representation in a class object.
upvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/2781107
has comment: http://stackoverflow.com/comment/2787799
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/2779931

http://stackoverflow.com/a/2674917
has body: If that is your verbatim code there are two immediate problems. First your ArrayList variable is "catalogue1" but you are attempting to add an item to "Catalogue", which doesn't exist. Secondly you are adding an item at position 1, which would be out of bounds, since the arraylist is empty. So I would change the code (adding generics as mentioned by Carl's comment: ArrayList&lt;Movie&gt; catalogue1 = new ArrayList&lt;Movie&gt;(); Movie movie1= new Movie(); Movie movie2= new Movie(); catalogue1.add(movie1); //equivalently: catalogue.add(0, movie1); catalogue1.add(movie2);
answers question: http://stackoverflow.com/q/2674867
downvote count: 0
type: Answer
score: 1
upvote count: 1

http://stackoverflow.com/comment/2629423
type: AnswerComment
has text: The NetBeans WYSIWYG editor is a nightmare. If you can afford it, I'd recommend JFormDesigner, or just do it by hand with a layout manager. It may be more work at first, but in the long run you have more control.
type: Comment
comment on: http://stackoverflow.com/a/2617429
score: 1

http://stackoverflow.com/comment/2755724
has text: I need it to be 01234, since I'm using this for encoding messages, I need to keep all 5 digits.
comment on: http://stackoverflow.com/q/2728476
score: 0
type: QuestionComment
type: Comment

http://stackoverflow.com/q/2653954
accepted answer: http://stackoverflow.com/a/2654241
has answer: http://stackoverflow.com/a/63719801
favorite count: 0
linked to: http://stackoverflow.com/q/19331700
score: 36
tagged with: android
has answer: http://stackoverflow.com/a/57301697
has answer: http://stackoverflow.com/a/2654241
has answer: http://stackoverflow.com/a/28454175
has answer: http://stackoverflow.com/a/70679338
upvote count: 36
has body: I'm just getting started with android programming, and want to see if there is a way to programmatically set the lock screen image. I've found various ways of setting the wallpaper in the API, but I can't seem to find the equivalent ways of setting the lock screen image. I've seen various posts saying that customising the lock screen by adding widgets or bits of applications is not possible, but surely there must be a way to set the image programmatically? Cheers, Robin
has answer: http://stackoverflow.com/a/38727637
answer count: 8
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/65181810
tagged with: java
has title: How to set android lock screen image
tagged with: image
has answer: http://stackoverflow.com/a/42995256
type: Question
tagged with: wallpaper
possible better answer: http://stackoverflow.com/a/38727637

http://stackoverflow.com/comment/2764560
comment on: http://stackoverflow.com/q/2736420
type: Comment
type: QuestionComment
score: 7
has text: +1 for the word "upgradation" :)

http://stackoverflow.com/q/2719536
has comment: http://stackoverflow.com/comment/2745706
has answer: http://stackoverflow.com/a/16811272
has comment: http://stackoverflow.com/comment/2745539
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2745494
tagged with: nested-class
tagged with: java
answer count: 6
possible better answer: http://stackoverflow.com/a/5710584
type: Question
has answer: http://stackoverflow.com/a/5710584
has comment: http://stackoverflow.com/comment/2745695
has title: Can a Static Nested Class be Instantiated Multiple Times?
downvote count: 0
has comment: http://stackoverflow.com/comment/2749856
has body: Given what I know of every other type of static feature of programming––I would think the answer is 'no'. However, seeing statements like OuterClass.StaticNestedClass nestedObject = new OuterClass.StaticNestedClass(); makes me wonder.
has answer: http://stackoverflow.com/a/2719553
favorite count: 0
tagged with: static
has comment: http://stackoverflow.com/comment/2745485
has comment: http://stackoverflow.com/comment/2745721
linked to: http://stackoverflow.com/q/70324
has comment: http://stackoverflow.com/comment/2745509
has answer: http://stackoverflow.com/a/2719568
linked to: http://stackoverflow.com/q/1353309
score: 25
has comment: http://stackoverflow.com/comment/2745587
upvote count: 25
has answer: http://stackoverflow.com/a/55777487
has comment: http://stackoverflow.com/comment/2745573
accepted answer: http://stackoverflow.com/a/2719553
has answer: http://stackoverflow.com/a/2719574
has comment: http://stackoverflow.com/comment/2745567

http://stackoverflow.com/a/2646059
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2666620
type: Answer
answers question: http://stackoverflow.com/q/2646049
has comment: http://stackoverflow.com/comment/2661274
has body: BigInteger.valueOf(i);
score: 53
upvote count: 53
accepted answer of: http://stackoverflow.com/q/2646049

http://stackoverflow.com/comment/2697332
type: Comment
type: QuestionComment
score: 3
comment on: http://stackoverflow.com/q/2678035
has text: What `MultipartRequest` are you talking about? Spring?

http://stackoverflow.com/a/2650898
type: Answer
score: 0
has comment: http://stackoverflow.com/comment/2670194
has body: You have to define hashCode() and equals() on your CohortGroup and Employee entities. This can be done automatically by your IDE and it can either be on the primary key (sometimes not a good idea) or on a business key (preferable). Read this article.
answers question: http://stackoverflow.com/q/2649145

http://stackoverflow.com/q/2688493
has answer: http://stackoverflow.com/a/2688662
type: Question
tagged with: c#
has answer: http://stackoverflow.com/a/2688556
type: AnsweredQuestion
has title: How can I read barcodes without having the user focus a text box first?
tagged with: java
score: 10
upvote count: 10
downvote count: 0
accepted answer: http://stackoverflow.com/a/2688662
has body: I recently acquired a Metrologic Barcode scanner (USB port), as everyone already knows it works as a keyboard emulator out of the box. How do I configure the scanner and my application so that my app can process the barcode data directly? That is, I don't want the user to focus on a "Text field" and then process the data when the KeyPress event fires.
favorite count: 0
has answer: http://stackoverflow.com/a/2689276
tagged with: delphi
tagged with: windows
answer count: 4
tagged with: barcode
possible better answer: http://stackoverflow.com/a/2695786
has answer: http://stackoverflow.com/a/2695786

http://stackoverflow.com/q/2642908
has answer: http://stackoverflow.com/a/2642914
type: AnsweredQuestion
score: 3
has body: Java's equivalence to Python's "Got value: %s" % variable?
upvote count: 3
tagged with: java
tagged with: formatting
type: Question
has answer: http://stackoverflow.com/a/2642935
answer count: 2
has title: Java's equivalence to Python's "Got value: %s" % variable?
downvote count: 0
accepted answer: http://stackoverflow.com/a/2642914
possible better answer: http://stackoverflow.com/a/2642935
tagged with: string
favorite count: 0
tagged with: python

http://stackoverflow.com/a/2719120
type: Answer
has comment: http://stackoverflow.com/comment/2745035
answers question: http://stackoverflow.com/q/2719107
score: 0
has comment: http://stackoverflow.com/comment/2745044
has body: Do you really need to have a limited pool of userids ? Otherwise, each user can simply have an incrementing userid. This way, there's no risk of collision, and it seems much easier to me.

http://stackoverflow.com/comment/2816996
comment on: http://stackoverflow.com/a/2781777
has text: If there's a chance of invalid data, I'd definitely use JAXB. There's a fairly robust validation / adapter framework which is implemented at the marshal/unmarshal steps.
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/a/2725555
upvote count: 85
answers question: http://stackoverflow.com/q/2725533
score: 75
type: Answer
downvote count: 10
has comment: http://stackoverflow.com/comment/70650118
has comment: http://stackoverflow.com/comment/2754743
has body: You can use instanceof. JLS 15.20.2 Type Comparison Operator instanceof RelationalExpression: RelationalExpression instanceof ReferenceType At run time, the result of the instanceof operator is true if the value of the RelationalExpression is not null and the reference could be cast to the ReferenceType without raising a ClassCastException. Otherwise the result is false. That means you can do something like this: Object o = new int[] { 1, 2 }; System.out.println(o instanceof int[]); // prints "true" You'd have to check if the object is an instanceof boolean[], byte[], char[], double[], float[], int[], long[], short[], or Object[], if you want to detect all array types. Also, an int[][] is an instanceof Object[], so depending on how you want to handle nested arrays, it can get complicated. For the toString, java.util.Arrays has a toString(int[]) and other overloads you can use. It also has deepToString(Object[]) for nested arrays. public String toString(Object arr) { if (arr instanceof int[]) { return Arrays.toString((int[]) arr); } else //… } It's going to be very repetitive (but even java.util.Arrays is very repetitive), but that's the way it is in Java with arrays. See also Managing highly repetitive code and documentation in Java Java Arrays.equals() returns false for two dimensional arrays.
has comment: http://stackoverflow.com/comment/2755070
has comment: http://stackoverflow.com/comment/2755049
has comment: http://stackoverflow.com/comment/2756075
has comment: http://stackoverflow.com/comment/2756008

http://stackoverflow.com/q/2745764
downvote count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2747268
score: 1
tagged with: java
tagged with: database
has answer: http://stackoverflow.com/a/2754200
type: Question
has comment: http://stackoverflow.com/comment/2775093
answer count: 2
upvote count: 1
has title: How can I treat a sequence value like a generated key?
has comment: http://stackoverflow.com/comment/2775572
tagged with: db2
favorite count: 0
has body: Here is my situation and my constraints: I am using Java 5, JDBC, and DB2 9.5 My database table contains a BIGINT value which represents the primary key. For various reasons that are too complicated to go into here, the way I insert records into the table is by executing an insert against a VIEW; an INSTEAD OF trigger retrieves the NEXT_VAL from a SEQUENCE and performs the INSERT into the target table. I can change the triggers, but I cannot change the underlying table or the general approach of inserting through the view. I want to retrieve the sequence value from JDBC as if it were a generated key. Question: How can I get access to the value pulled from the SEQUENCE. Is there some message I can fire within DB2 to float this sequence value back to the JDBC driver? Resolution: I resorted to retrieving the PREVIOUS_VAL from the sequence in a separate JDBC call.
tagged with: sql

http://stackoverflow.com/a/2690240
score: 3
type: Answer
answers question: http://stackoverflow.com/q/2690207
upvote count: 3
has comment: http://stackoverflow.com/comment/78276096
has body: You've started a new thread. That thread runs in parallel to the thread that started it so the order could be: pObject.run(); doSomethingElse(); or doSomethingElse(); pObject.run(); or, more likely, there will be some crossover. pObject.run() may run in the middle of doSomethingElse() or vice versa or one will start before the other finishes and so on. It's important to understand this and understand what is meant by an atomic operation or you will find yourself with some really hard-to-find bugs. It's even more complicated if two or more threads access the same variables. The value in one may never be updated in one thread under certain circumstances. I highly suggest: You don't make your program multi-threaded unless you absolutely need to; and If you do, buy and read from cover to cover Brian Goetz's Java Concurrency in Practice.
downvote count: 0

http://stackoverflow.com/q/2719501
has answer: http://stackoverflow.com/a/2720070
downvote count: 0
has body: I'm developing a client-server application on java. The server offers some operations through a web service. The application must show some content depending on the user's custom date and time; information that is retrieved from the web service. Different users may be in different time zones. I've been thinking on how to store on the server the user's custom time zone and provide the user the right content, for example, when the operation getTodayEvents is invoked. What's the best practices to accoplish this in java?
answer count: 3
has title: Develop web-services aware of user's time zone
favorite count: 0
type: UnansweredQuestion
tagged with: datetime
upvote count: 1
tagged with: web-services
has answer: http://stackoverflow.com/a/2719558
tagged with: internationalization
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/2720017
type: Question

http://stackoverflow.com/a/2599724
downvote count: 0
has comment: http://stackoverflow.com/comment/2608535
answers question: http://stackoverflow.com/q/2599499
upvote count: 3
type: Answer
has body: There are two ways of interpreting the "ascending" requirement. The looser interpretation is "in every list, the integers should appear in ascending order". The stricter interpretation is "the lists need to be given in order". I guess that's the one you want, but I came up with a simple iterative way to satisfy the looser requirement. For n items, count through all n-bit numbers. If the bit corresponding to an item is there, then it's in the result list. public static void displaySubsets(List&lt;Integer&gt; sortedInts) { int n=sortedInts.size(); long combinations = 1 &lt;&lt; n; for (int setNumber=0; setNumber&lt;combinations; setNumber++) { List&lt;Integer&gt; aResult = new ArrayList&lt;Integer&gt;(); for (int digit=0; digit&lt;n; digit++) { if ((setNumber &amp; (1&lt;&lt;digit)) &gt; 0) { aResult.add(sortedInts.get(digit)); } } System.out.println(aResult.toString()+", "); } } Result for 1,2,3,4,5 is: [], [1], [2], [1, 2], [3], [1, 3], [2, 3], [1, 2, 3], [4], [1, 4], [2, 4], [1, 2, 4], [3, 4], [1, 3, 4], [2, 3, 4], [1, 2, 3, 4], [5], [1, 5], [2, 5], [1, 2, 5], [3, 5], [1, 3, 5], [2, 3, 5], [1, 2, 3, 5], [4, 5], [1, 4, 5], [2, 4, 5], [1, 2, 4, 5], [3, 4, 5], [1, 3, 4, 5], [2, 3, 4, 5], [1, 2, 3, 4, 5] Yes, I know, I lose points for not using recursion.
score: 3

http://stackoverflow.com/q/2623213
favorite count: 0
has comment: http://stackoverflow.com/comment/2635689
type: Question
upvote count: 2
has body: I'm getting pretty big input string into my method, but what I actually need is just first line of that string. Is it possible to extract just the first line of an already existing string?
has comment: http://stackoverflow.com/comment/2635785
has answer: http://stackoverflow.com/a/2623225
has title: Reading string more efficiently
linked to: http://stackoverflow.com/q/2496239
tagged with: java
linked to: http://stackoverflow.com/q/2597841
answer count: 3
accepted answer: http://stackoverflow.com/a/2623225
has comment: http://stackoverflow.com/comment/2635792
has answer: http://stackoverflow.com/a/2634230
has answer: http://stackoverflow.com/a/2623255
type: AnsweredQuestion
score: 2
downvote count: 0
possible better answer: http://stackoverflow.com/a/2634230

http://stackoverflow.com/a/2611772
has body: How the data is reaching the java servlet page? JSON, XML? if JSON, I how recommend that you use jQuery, the .get() method is fantastic! And that's the way I use in my ASP pages...
has comment: http://stackoverflow.com/comment/2622487
score: 0
answers question: http://stackoverflow.com/q/2611758
type: Answer
upvote count: 1
downvote count: 1

http://stackoverflow.com/comment/43598556
type: Comment
has text: This was very confusingly phrased; hopefully my edit clarifies your meaning.
comment on: http://stackoverflow.com/a/27587112
score: 0
type: AnswerComment

http://stackoverflow.com/a/2701462
has body: When dealing with inheritance/polymorphism in Java there are basically two types of casts that you see: Upcasting: Superclass x = new Subclass(); This is implicit and does not need a hard cast because Java knows that everything the Superclass can do, the Subclass can do as well. Downcasting Superclass x = new Subclass(); Subclass y = (Subclass) x; In this case you need to do a hard cast because Java isn't quite sure if this will work or not. You have to comfort it by telling it that you know what you're doing. The reason for this is because the subclass could have some weird methods that the superclass doesn't have. In general, if you want to instantiate a class to call something in its subclass, you should probably just instantiate the subclass to begin with -- or determine if the method should be in the superclass as well.
score: 3
upvote count: 3
answers question: http://stackoverflow.com/q/2701182
downvote count: 0
type: Answer

http://stackoverflow.com/q/2683214
has answer: http://stackoverflow.com/a/14047187
favorite count: 0
upvote count: 196
type: Question
has answer: http://stackoverflow.com/a/2683299
has answer: http://stackoverflow.com/a/34780634
has answer: http://stackoverflow.com/a/31357000
has title: Get query from java.sql.PreparedStatement
possible better answer: http://stackoverflow.com/a/2683299
has body: In my code I am using java.sql.PreparedStatement. I then execute the setString() method to populate the wildcards of the prepared statement. Is there a way for me to retrieve (and print out) the final query before the executeQuery() method is called and the query is executed? I Just want this for debugging purposes.
tagged with: java
has answer: http://stackoverflow.com/a/2683339
tagged with: prepared-statement
has answer: http://stackoverflow.com/a/24734294
linked to: http://stackoverflow.com/q/2382532
score: 196
has answer: http://stackoverflow.com/a/10600232
downvote count: 0
duplicate of: http://stackoverflow.com/q/2382532
answer count: 8
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/22925156
accepted answer: http://stackoverflow.com/a/2683339
tagged with: jdbc

http://stackoverflow.com/a/2669413
type: Answer
answers question: http://stackoverflow.com/q/2669326
downvote count: 0
has comment: http://stackoverflow.com/comment/61534530
has comment: http://stackoverflow.com/comment/61534054
has body: The short answer is don't. As soon as instanceof gets involved, Generics are usually the wrong answer. Use overloaded methods instead: public String doIt(String param){ return "string"; } public Integer doIt(Integer param){ return 1; } public Object doIt(Object param){ return null; }
score: 8
upvote count: 8

http://stackoverflow.com/a/2720754
downvote count: 0
has body: It would appear that they base their formatting on the SimpleDateFormatter and the escape character there is ' So your code would be something like this: "d 'days' H 'hours left'"
score: 15
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2720141
accepted answer of: http://stackoverflow.com/q/2720141
type: Answer
upvote count: 15

http://stackoverflow.com/comment/2789122
type: Comment
has text: In the meantime, while waiting for JDK7, anonymous methods can be emulated in an OO context using http://en.wikipedia.org/wiki/Command_pattern
comment on: http://stackoverflow.com/a/2755450
score: 2
type: AnswerComment

http://stackoverflow.com/a/7327138
answers question: http://stackoverflow.com/q/2622062
downvote count: 0
upvote count: 2
type: Answer
score: 2
has body: java -jar "C:\\myjarfile.jar" You might need to add "\\" to the command. Try this!

http://stackoverflow.com/comment/2657216
type: Comment
score: 2
has text: I wonder why it's so common to do as shown here instead of "for(int i=0,siz=myList.size(); i<siz; i++)"?
type: AnswerComment
comment on: http://stackoverflow.com/a/2642028

http://stackoverflow.com/comment/2629566
has text: @Sudheer break up the requests in three categories. The same for all, Limited amount of data, and Per client. Same for all (weather in US) can be done this way. Limited amount of data (weather per state) also, you just have 51 records in stead of 1 cached. Per client (that particular flight from LAX) could be done by Ajax. The initial JSP loads fast and an Ajax request through a limited jsp which loads perhaps slowly, but only part of the page is slow with a nice indicator. Less frustrating than waiting for a page to show up.
comment on: http://stackoverflow.com/a/2617348
type: Comment
score: 2
type: AnswerComment

http://stackoverflow.com/a/48376371
has comment: http://stackoverflow.com/comment/133989043
upvote count: 56
has comment: http://stackoverflow.com/comment/90582878
answers question: http://stackoverflow.com/q/2659593
has body: "The constant interface pattern is a poor use of interfaces" Whoever concocted this hypothesis, however a guru he/she may be, concocted it on the basis of the need to continue implementing bad habits and practices efficiently. The hypothesis is based on the promotion of the validity of bad software design habits. I wrote a response rebuttal against that hypothesis here: What is the best way to implement constants in Java? explaining the baseless-ness of this hypothesis. For 10 years that question had stayed open, until it was closed within 2 hours after I posted my reasons dejustifying this hypothesis, thus exposing UNWILLINGness for debate by those who hold on to this misguided hypothesis dearly. These are the points I expressed against the hypothesis The basis for holding this hypothesis is the need for methods and RESTRICTIVE rules to cope with the effects of bad software habits and methodologies. The proponents of the sentiment "The constant interface pattern is a poor use of interfaces" are unable to provide any reasons other than those caused by the need to cope with the effects of those bad habits and practices. Solve the fundamental issue. And then why not make full use and exploit every language feature of the Java language structure to your own convenience. No Jackets Required. Why invent rules to barricade your ineffective lifestyle to discriminate and incriminate more effective lifestyles? The fundamental issue is information organisation. Information mediating the process, nd the behaviour of that information should first be understood, along with the so-called business rules - before engineering or supplementing solutions to the process. Such method of information organization was called data normalization a few decades ago. Then only the engineering of a solution be possible because aligning the granularity and modularity of the components of a solution with the granularity and modularity of the components of the information is the optimal strategy. T…
type: Answer
has comment: http://stackoverflow.com/comment/93678579
has comment: http://stackoverflow.com/comment/93932604
downvote count: 22
score: 34
has comment: http://stackoverflow.com/comment/133923810
has comment: http://stackoverflow.com/comment/136308579
has comment: http://stackoverflow.com/comment/136308549
has comment: http://stackoverflow.com/comment/134663286

http://stackoverflow.com/comment/105706696
type: Comment
type: AnswerComment
has text: I have src/test/resources but still my junit looking for src/main/webapp
score: 0
comment on: http://stackoverflow.com/a/2699379

http://stackoverflow.com/a/2627287
has comment: http://stackoverflow.com/comment/2640464
answers question: http://stackoverflow.com/q/2627237
has body: And in consideration, id like to go into mobile app dev...So thats +1 for Java. How is that +1 for Java? We're talking about server-side languages.. you're not running your server off a phone are you? Sure, you can use Java to build apps in addition to running your website, but that's a different story. Time taken to learn the language is not an issue...Just would like to know which is the most profitable at the end of all the training. Neither language will make your site more profitable, but you may be in higher demand with different companies depending on what you know. And on a slight note. Can Javascript work with Java? And what is the real advantage of that? Well... yes, but that's almost a nonsensical question. You use Java or PHP to produce the HTML that gets sent to the client, and then your JavaScript manipulates that. It's completely unrelated to what language you use server-side. @comment: I can't really say which is more worth learning. I suppose Java is more versatile in that it has more applications outside the web. PHP is supported by more web-servers though (AFAIK), so you won't have trouble if you need to work on a different server. I can't fairly recommend one over the other though. I've only used PHP for web, and Java for non-web. I like PHP because it's easy to pickup, easy to use, and all sorts of stuff is built into the language without any includes or anything. Has a big community, so there's lots of scripts you can download. One might argue that it's also a mess of a language, but as long as you aren't all uppity about that sort of thing, it's not really a problem. Java OTH... I don't know. I'm not a Java keener, that's all I'll say :)
type: Answer
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/2640372
upvote count: 2

http://stackoverflow.com/a/2784061
downvote count: 0
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/2819429
type: Answer
has body: Why not simply: List&lt;IssueType&gt; selectedIssueType = Arrays.asList(selectedItems);
answers question: http://stackoverflow.com/q/2783960
has comment: http://stackoverflow.com/comment/2825035

http://stackoverflow.com/comment/34389325
type: Comment
comment on: http://stackoverflow.com/a/2784747
score: 0
type: AnswerComment
has text: I tried that - but when I want to access the comparator class ChairWeightComparator outside in any other class I do not get access to this class (of course not since its not public). Do I need to create a new public ChairWeightComparator class in a separate file? - am I really the first one to try this after 3 years or did I miss sth?

http://stackoverflow.com/comment/111568193
has text: can you reproduce a situation where that code in his question would cause an IOException?
comment on: http://stackoverflow.com/a/2629681
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/63719801
answers question: http://stackoverflow.com/q/2653954
type: Answer
has body: Bitmap icon = BitmapFactory.decodeResource(getViewContext().getResources(), R.drawable.wall); if (android.os.Build.VERSION.SDK_INT &gt;= android.os.Build.VERSION_CODES.N) { WallpaperManager wallpaperManager = WallpaperManager.getInstance(getViewContext()); try { wallpaperManager.setBitmap(icon, null, true, WallpaperManager.FLAG_LOCK); } catch (IOException e) { e.printStackTrace(); }
score: 0

http://stackoverflow.com/comment/2726247
comment on: http://stackoverflow.com/a/2702917
has text: Actually, logback is the successor of log4j: http://logback.qos.ch/documentation.html It's a native implementation of slf4j.
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/64318367
type: Comment
has text: Actually, BigInteger is not very bulky. Any type "inbetween" would not be any more lightweight.
comment on: http://stackoverflow.com/a/2776432
type: AnswerComment
score: 0

http://stackoverflow.com/a/2724164
upvote count: 2
has body: Create an abstract class WebsiteCaller which would be a parent of ConcreteWebsiteCaller and WebsiteCallerStub. This class should have one method callWebsite (String url). Move your callWebsite method from MyClass to ConcreteWebsiteCaller. And MyClass will look like: class MyClass { private WebsiteCaller caller; public MyClass (WebsiteCaller caller) { this.caller = caller; } public String pushEvent (Event event) { //do something here String url = constructURL (event); //construct the website url String response = caller.callWebsite (url); return response; } } and implement method callWebsite in your WebsiteCallerStub in some way appropriate for testing. Then in your unit test do something like this: @Test public void testPushEvent() { MyClass mc = new MyClass (new WebsiteCallerStub()); mc.pushEvent (new Event(...)); }
has comment: http://stackoverflow.com/comment/2750725
downvote count: 0
answers question: http://stackoverflow.com/q/2724035
type: Answer
score: 2

http://stackoverflow.com/a/2781724
answers question: http://stackoverflow.com/q/2781666
score: 0
has body: You pretty much just need to add the array to the ArrayList. ArrayList&lt;String[]&gt; veri1 = new ArrayList&lt;String[]&gt;(); String[] veri2 = {"a", "b", "c"}; veri1.add(veri2); System.out.println(veri1.size()); for(String[] sArray : veri1) for(String s : sArray) System.out.println(s);
type: Answer

http://stackoverflow.com/q/2634422
has answer: http://stackoverflow.com/a/2634708
accepted answer: http://stackoverflow.com/a/2634708
tagged with: android
has title: Clicking Elements in Android Doesn't Display the Correct Values
type: AnsweredQuestion
has body: I apologize if this code looks a bit like a mess (considering the length); I figured I'd just include everything that goes on in my program at the moment. I'm attempting to create a fairly simple Tic Tac Toe app for Android. I've set up my UI nicely so far so that there are a "grid" of TextViews. As a sort of "debug" right now, I have it so that when one clicks on a TextView, it should display the value of buttonId in a message box. Right now, it displays the correct assigned value for the first element I click, but no matter what I click afterwards, it always just displays the first value buttonID had. I attempted to debug it but couldn't exactly find a point where it would pull the old value (to the best of my knowledge, it reassigned the value). There's a good possibility I'm missing something small, because this is my first Android project (of any note). Can someone help get different values of buttonId to appear or point out the error in my logic? The code: package com.TicTacToe.app; import com.TicTacToe.app.R; //Other import statements public class TicTacToe extends Activity { public String player = "X"; public int ALERT_ID; public int buttonId; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //Sets up instances of UI elements final TextView playerText = (TextView)findViewById(R.id.CurrentPlayerDisp); final Button button = (Button) findViewById(R.id.SetPlayer); final TextView location1 = (TextView)findViewById(R.id.location1); final TextView location2 = (TextView)findViewById(R.id.location2); final TextView location3 = (TextView)findViewById(R.id.location3); final TextView location4 = (TextView)findViewById(R.id.location4); final TextView location5 = (TextView)findViewById(R.id.location5); final TextView location6 = (TextView)findViewById(R.id.location6); final TextView location7 = (TextView)findViewById(R.id.location7); final TextVi…
tagged with: java
type: Question
score: 0
answer count: 1

http://stackoverflow.com/comment/2609155
comment on: http://stackoverflow.com/a/2599292
type: AnswerComment
has text: What do you mean? If it is only that there is not a tab at the beginning, you can solve it easily.
score: 0
type: Comment

http://stackoverflow.com/a/3401754
upvote count: 17
type: Answer
answers question: http://stackoverflow.com/q/2725233
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2725233
has body: There is a bug report and a discussion thread. The DateSerializer that comes with Kryo is slightly more efficient size-wise than the SimpleSerializer implementation posted on SO because it uses LongSerializer optimized for positive values. Edit: I forgot to answer the original question. I believe Kryo is used in at least a few production systems. There is mention of it in this article, Jive SBS cache redesign: Part 3. In the Destroy All Humans project, Kryo is used to communicate with an Android phone that serves as a robot brain (video here). Not a direct answer, but you might browse the Kryo source and/or javadocs. Check out the read* and write* methods on the Kryo class, then look at the Serializer class. This is really the core of the library.
has comment: http://stackoverflow.com/comment/4335751
score: 17
type: AcceptedAnswer

http://stackoverflow.com/comment/2775200
type: AnswerComment
type: Comment
has text: When I run the main java, I think there is a problem during query execution. When I do tx.commit(), the application takes a lot of time to execute query and doesn't get any error. It seems like there some conflicts between the toplink and hibernate. What can I do? Thank you for your help
comment on: http://stackoverflow.com/a/2744378
score: 0

http://stackoverflow.com/comment/2743435
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2717013
has text: Can we say that Processing is an Environment for Mathematical Modelling and Programming?
score: 0

http://stackoverflow.com/comment/24859082
type: Comment
comment on: http://stackoverflow.com/a/7827593
has text: There is no any relation with my answer. It's very different thing you are getting. Could you share your codes?
type: AnswerComment
score: 0

http://stackoverflow.com/a/2607703
has comment: http://stackoverflow.com/comment/2617917
answers question: http://stackoverflow.com/q/2607676
has comment: http://stackoverflow.com/comment/2618038
has comment: http://stackoverflow.com/comment/2617975
downvote count: 0
has body: Private - only that particular class needs access to them. Nothing outside the class can see or use them. Protected - that particular class and any class that extends that class can access them. Classes that do not extend the member's class cannot see or use them. Public - any other class can access, see and use them. I learnt today that Java also has another access level which is implied if you don't specify public/protected/private. This is called "package private" and means classes within the same package can access the members, but no class outside of the package can. This page might also help you out.
type: Answer
score: 1
upvote count: 1

http://stackoverflow.com/comment/2697619
type: Comment
score: 0
has text: I am doing this in File Read: // Creating a new File instance File FileToBeRead = new File(fileName); // Creates a DataInputStream that uses the specified underlying InputStream. DataInputStream input = new DataInputStream(new FileInputStream(FileToBeRead)); Data = new byte[(int)FileToBeRead.length()]; // Reads bytes from the input stream and stores them into the buffer array Data. input.read(Data); // Closes this input stream and releases any system resources associated with the stream. input.close();
comment on: http://stackoverflow.com/a/2678295
type: AnswerComment

rmi
tags question: http://stackoverflow.com/q/2728495
tags question: http://stackoverflow.com/q/2748259
tags question: http://stackoverflow.com/q/2650893
tags question: http://stackoverflow.com/q/2611754
tags question: http://stackoverflow.com/q/2719936
tags question: http://stackoverflow.com/q/2658843
tags question: http://stackoverflow.com/q/2685825
tag name: rmi
tags question: http://stackoverflow.com/q/2722949
type: Tag
tags question: http://stackoverflow.com/q/2608245
tags question: http://stackoverflow.com/q/2620687
tags question: http://stackoverflow.com/q/2728805

http://stackoverflow.com/a/2640740
type: AcceptedAnswer
downvote count: 0
score: 4
type: Answer
accepted answer of: http://stackoverflow.com/q/2640727
answers question: http://stackoverflow.com/q/2640727
upvote count: 4
has body: printDice() is never called: public static void main (String[] arg) { Dice a1 = new Dice ("a1") ; printValues (a1) ; // You only call printValues }

http://stackoverflow.com/a/2755054
downvote count: 0
has body: On the JPA level, the only thing you can do is use the JPA API of the currently used persistence library (i.e. when using hibernate, don't use Hibernate.initialize()). On the DB level, your best bet is to keep things simple as chances of differences in behaviour grow as you move away from the most frequent use cases. Specifically, this might mean not using composite primary keys, not storing binary data, not using SQL execution at all...I'm sure others will have more good examples of practices which will allow you to move from one database to another easily. The above made it possible for me to switch one application between PostgreSQL and Oracle and another between PostgreSQL and a few "dialects" (in hibernate lingo) of MySQL.
upvote count: 2
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2754793
type: Answer
accepted answer of: http://stackoverflow.com/q/2754793
score: 2

http://stackoverflow.com/comment/2615643
type: AnswerComment
score: 0
has text: In that case, you're editing a different file than the parser reads.
type: Comment
comment on: http://stackoverflow.com/a/2599948

http://stackoverflow.com/a/2705079
has body: Javacc generates java parsers from BNF-like input, and does not require a runtime library. You may need to modify the BNF slightly, I think there are some caveats as to what Javacc can accept.
answers question: http://stackoverflow.com/q/2705002
type: AcceptedAnswer
type: Answer
upvote count: 4
downvote count: 0
score: 4
accepted answer of: http://stackoverflow.com/q/2705002

http://stackoverflow.com/q/2743236
has body: I would like to know if it's possible to view my values through JTable and then edit them through there?
favorite count: 0
has answer: http://stackoverflow.com/a/2743380
has answer: http://stackoverflow.com/a/2743546
possible better answer: http://stackoverflow.com/a/2743288
has answer: http://stackoverflow.com/a/2743288
type: AnsweredQuestion
downvote count: 0
tagged with: java
has title: Is it possible to edit data in jtable and save it?
type: Question
score: 3
tagged with: jtable
upvote count: 3
answer count: 3
accepted answer: http://stackoverflow.com/a/2743380

http://stackoverflow.com/comment/2670604
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2653814
has text: yes your are right at your first point. but i dont agree with your second. you write efficient code once, even it's annoying, and than reuse it. anyway BalusC solved the riddle.
type: AnswerComment

http://stackoverflow.com/a/2716663
upvote count: 1
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2716600
answers question: http://stackoverflow.com/q/2716600
type: Answer
downvote count: 0
score: 1
has body: Has the client closed the stream it is writing to? If it hasn't, your readLine() is blocking for more data from the client. Client-server protocols typically establish a mechanism (other than stream close) to indicate size. Whether it is a content-length or through a special token.

http://stackoverflow.com/q/2745088
upvote count: 2
tagged with: generics
favorite count: 0
accepted answer: http://stackoverflow.com/a/4346827
has body: I am not sure if the following is either sufficiently complicated or excessively complicated. It basically boils down to an interrelated class and interface. (See below) Suggestions appreciated.... /** * @param &lt;T&gt; item type * @param &lt;TF&gt; table format type */ interface EnumTableFormatItem&lt;T, TF extends TableFormat&lt;T&gt;&gt; { Object getValue(TF context, T item); String getLabel(); } /** * @param &lt;T&gt; item type * @param &lt;E&gt; enum type which specifies each column */ static public class EnumTableFormat &lt; T, E extends Enum&lt;E&gt; &amp; EnumTableFormatItem&lt;T, EnumTableFormat&lt;T, E&gt;&gt; &gt; implements TableFormat&lt;T&gt; { final private List&lt;E&gt; fields = new ArrayList&lt;E&gt;(); public EnumTableFormat(List&lt;E&gt; fieldList) { this.fields.addAll(fieldList); } @Override public int getColumnCount() { return this.fields.size(); } @Override public String getColumnName(int column) { return this.fields.get(column).getLabel(); } @Override public Object getColumnValue(T item, int column) { return this.fields.get(column).getValue(this, item); } } edit: On a quick reflection, it seems excessively complicated, I just wanted to use an object for context &amp; I think I shouldn't have coupled it to the EnumTableFormat. (see my answer)
score: 2
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/4346827
tagged with: java
type: Question
answer count: 2
has title: Java generics: convoluted template definition
possible better answer: http://stackoverflow.com/a/2745626
has answer: http://stackoverflow.com/a/2745626

http://stackoverflow.com/q/2763273
has answer: http://stackoverflow.com/a/2764875
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/3869615
type: Question
tagged with: jasper-reports
has title: How to stream pdf document from servlet?
score: 3
tagged with: java
tagged with: servlets
upvote count: 3
has body: I am creating pdf document using jasper report and i need to stream that pdf document from servlet.Can anyone help me where i did mistake.This is the code snippet which i am using in my application. ServletOutputStream servletOutputStream = response.getOutputStream(); String fileName="test.pdf"; response.setContentType("application/pdf"); response.setHeader("Content-Disposition","attachment; filename=\"" + fileName + "\""); response.setHeader("Cache-Control", "no-cache"); try { Map parameters = new HashMap(); parameters.put("SUBREPORT_DIR", JasperReportFilepath); parameters.put("TestId", testID); JasperPrint jprint=JasperFillManager.fillReport(filePath, parameters, conn); byte[] output=JasperExportManager.exportReportToPdf(jprint); System.out.println("Size====&gt;"+output.length); servletOutputStream.write(output); servletOutputStream.flush(); servletOutputStream.close(); System.out.println("===============&gt;Streaming perfectly"); } catch(Exception e) { System.out.println("===============&gt;+JasperException"+e.getMessage()); } and i could not get any error message also.Everything is working fine but document is not streaming. Please help me to sort out the problem.
answer count: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/2797218

http://stackoverflow.com/comment/2642566
type: Comment
has text: MMmmm... It's very tasty C++ language sugar. I do sometimes find myself missing it in Java.
type: QuestionComment
score: 3
comment on: http://stackoverflow.com/q/2629501

http://stackoverflow.com/comment/2660753
type: QuestionComment
comment on: http://stackoverflow.com/q/2645584
score: 2
has text: Can you tell us what is showing up as the name in the GUI?
type: Comment

http://stackoverflow.com/q/2699788
tagged with: java
upvote count: 30
type: Question
has answer: http://stackoverflow.com/a/2699801
has comment: http://stackoverflow.com/comment/2722375
has title: Java - is there a "subclassof" like instanceof?
has answer: http://stackoverflow.com/a/2699806
downvote count: 0
has body: Im overriding an equals() method and I need to know if the object is an instance of a Event's subclass (Event is the superclass). I want something like "obj subclassof Event". How can this be made? Thanks in advance!
answer count: 6
has answer: http://stackoverflow.com/a/2699854
tagged with: subclass
has answer: http://stackoverflow.com/a/2699883
favorite count: 0
score: 30
tagged with: instanceof
has answer: http://stackoverflow.com/a/2699821
tagged with: equals
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2699854
has answer: http://stackoverflow.com/a/2699807
accepted answer: http://stackoverflow.com/a/2699801

http://stackoverflow.com/q/2658505
type: AnsweredQuestion
tagged with: java
accepted answer: http://stackoverflow.com/a/2658560
has title: Java swing app can't find image
type: Question
answer count: 2
tagged with: file-not-found
tagged with: image
has answer: http://stackoverflow.com/a/34176543
score: 0
has body: I'm making a torpedo game for school in java with swing gui, please see the zipped source HERE. I use custom button icons and mouse cursors of images stored in the /bin/resource/graphics/default folder's subfolders, where the root folder is the program's root folder (it will be the root in the final .jar as well I suppose) which apart from "bin" contains a "main" folder with all the classes. The relative path of the resources is stored in MapStruct.java's shipPath and mapPath variables. Now Battlefield.java's PutPanel class finds them all right and sets up its buttons' icons fine, but every other class fail to get their icons, e.g. Table.java's setCursor, which should set the mouse cursor for all its elements for the selected ship's image or Field.java's this.button.setIcon(icon); in the constructor, which should set the icon for the buttons of the "water". I watched with debug what happens, and the images stay null after loading, though the paths seem to be correct. I've also tried to write a test file in the image folder but the method returns a filenotfound exception. I've tried to get the path of the class to see if it runs from the supposed place and it seems it does, so I really can't find the problem now. Could anyone please help me? Thank you.
has answer: http://stackoverflow.com/a/2658560
possible better answer: http://stackoverflow.com/a/34176543
has comment: http://stackoverflow.com/comment/2675551
tagged with: swing

http://stackoverflow.com/a/39560151
downvote count: 1
answers question: http://stackoverflow.com/q/2703161
upvote count: 9
type: Answer
score: 8
has body: With fluent 4.5.2 i had to make the following modification to make it work. try { TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } public void checkClientTrusted(X509Certificate[] certs, String authType) { } public void checkServerTrusted(X509Certificate[] certs, String authType) { } } }; SSLContext sc = SSLContext.getInstance("SSL"); sc.init(null, trustAllCerts, new SecureRandom()); CloseableHttpClient httpClient = HttpClients.custom().setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).setSslcontext(sc).build(); String output = Executor.newInstance(httpClient).execute(Request.Get("https://127.0.0.1:3000/something") .connectTimeout(1000) .socketTimeout(1000)).returnContent().asString(); } catch (Exception e) { }
has comment: http://stackoverflow.com/comment/67884957

http://stackoverflow.com/a/2630816
has body: It's not as elegant as using OS support for ephemeral ports, but the docs show that you should be able to specify a port for your socket to bind to. Specify a port at the base of the range you want and if it is used an exception will be thrown, in which case increment the port and try again. Given that windows isn't using the port range that you want, there shouldn't be many collisions.
accepted answer of: http://stackoverflow.com/q/2630009
type: Answer
has comment: http://stackoverflow.com/comment/2644254
score: 0
answers question: http://stackoverflow.com/q/2630009
type: AcceptedAnswer

http://stackoverflow.com/comment/2834133
comment on: http://stackoverflow.com/a/2773033
type: AnswerComment
score: 0
type: Comment
has text: @Bruno Rothgiesser will not calling ParentSingleto::getInstance() and ChildSingleton ::getInstance() creates two instances of the singleton object ParentSingleton

http://stackoverflow.com/comment/2609037
comment on: http://stackoverflow.com/q/2599973
score: 0
type: Comment
type: QuestionComment
has text: Is it ok for the memory footprint to increase? are you storing some part of the index in memory? If the answer is no, I suppose this is a memory leak. Try using: jmap -histo <process id> to see what kind of objects occupy a larger portion of the heap than expected.

http://stackoverflow.com/q/2670570
type: Question
has answer: http://stackoverflow.com/a/2670607
score: 3
tagged with: java
has comment: http://stackoverflow.com/comment/66984761
has answer: http://stackoverflow.com/a/2670625
answer count: 3
accepted answer: http://stackoverflow.com/a/2670625
tagged with: java-7
has body: Are Open JDK and JDK7 the same thing?
downvote count: 0
favorite count: 0
has title: Are Open JDK and JDK7 the same thing?
possible better answer: http://stackoverflow.com/a/2670632
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2670632
upvote count: 3
linked to: http://stackoverflow.com/q/22358071

http://stackoverflow.com/comment/95382101
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2620609
has text: This fails if the String at the beginning is empty (OP specified that they could be any length), such as the String `"135"`.

http://stackoverflow.com/a/2636991
score: 7
answers question: http://stackoverflow.com/q/2636906
type: AcceptedAnswer
upvote count: 7
type: Answer
has comment: http://stackoverflow.com/comment/2651072
accepted answer of: http://stackoverflow.com/q/2636906
has body: I don't think you can answer this question in the abstract: it depends on the behavior of the superclass method you're overriding. Depending on circumstances, it may be appropriate to: call super first call super last handle some cases yourself (customizations), call super for the rest never call super Hopefully the documentation for the particular class you're overriding will tell you if/when it's necessary to call super.
downvote count: 0

http://stackoverflow.com/a/2661100
type: Answer
answers question: http://stackoverflow.com/q/2661065
score: 1
has comment: http://stackoverflow.com/comment/2680448
has body: What about using a HashMap? Insertion, deletion, and retrieval are all O(1) operations. If you wanted to sort everything, you could grab a List of the values in the Map and run them through an O(n log n) sorting algorithm. edit A quick search has found LinkedHashMap, which maintains insertion order of your keys. It's not an exact solution, but it's pretty close.
upvote count: 2
downvote count: 1

http://stackoverflow.com/comment/2641289
type: Comment
comment on: http://stackoverflow.com/a/2628049
score: 1
has text: I usually use the first option to permanently remove a listener from a component that lives longer that the one which registered the listener (e.g. in a `dispose()` method). To temporarily disable a listener, I have used the third option. This is mostly required to prevent recursion. E.g. when a listener that triggers on text changes leads to a change in that same text (for whatever reason), I disable the listener at the start of its listening method and enable it at the end.
type: AnswerComment

http://stackoverflow.com/comment/2746085
has text: Good point, I'm not using these objects in a context where hashcode() needs to return a stable result. I guess returning a fixed value (eg. 0) would work but it defeats the purpose of hashing.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2719981

http://stackoverflow.com/a/2615366
score: 40
has comment: http://stackoverflow.com/comment/54307643
has body: I'm confused. Emmanuel Bernard wrote in ANN-418 that @Lob are lazy by default (i.e. you don't even need to use the @Basic(fetch = FetchType.LAZY) annotation). Some users report that lazy loading of a @Lob doesn't work with all drivers/database. Some users report that it works when using bytecode instrumentation (javassit? cglib?). But I can't find any clear reference of all this in the documentation. At the end, the recommended workaround is to use a "fake" one-to-one mappings instead of properties. Remove the LOB fields from your existing class, create new classes referring to the same table, same primary key, and only the necessary LOB fields as properties. Specify the mappings as one-to-one, fetch="select", lazy="true". So long as your parent object is still in your session, you should get exactly what you want. (just transpose this to annotations).
type: Answer
has comment: http://stackoverflow.com/comment/95653420
has comment: http://stackoverflow.com/comment/8866425
has comment: http://stackoverflow.com/comment/2634483
has comment: http://stackoverflow.com/comment/57357679
upvote count: 40
has comment: http://stackoverflow.com/comment/2633608
answers question: http://stackoverflow.com/q/2605477
downvote count: 0
has comment: http://stackoverflow.com/comment/2634474
has comment: http://stackoverflow.com/comment/54357136

http://stackoverflow.com/comment/101054616
comment on: http://stackoverflow.com/a/2614484
type: AnswerComment
score: 0
type: Comment
has text: What happens if an exception is thrown inside finally ?

http://stackoverflow.com/a/2614058
answers question: http://stackoverflow.com/q/2613921
score: 0
type: Answer
has body: Did you consider JavaFX at all? JavaFX will let you create "scene-graphs" based on vector/graphics edited using Adobe Photoshop/Inkscape etc. If not, most simple way would be to extend JTextField such that that will just hold 1 char and will be black/or whatever color to indicate non-editable and disabled. Also, add a custom Border to indicate puzzle question number. Put everything in to a GridLayout.

http://stackoverflow.com/a/2715800
downvote count: 1
type: Answer
has body: Ant, like make, works on dependencies on a target level. In a target, the actions will operate in a sequential fashion. Targets however can be run in any order that satisfies their dependencies.
answers question: http://stackoverflow.com/q/2715764
score: 0
upvote count: 1

http://stackoverflow.com/a/2724207
has body: I was a huge fan of the work done for Aerith. It uses Swing and Java 2D.
answers question: http://stackoverflow.com/q/2724112
upvote count: 1
type: Answer
downvote count: 0
score: 1

http://stackoverflow.com/a/15686667
has comment: http://stackoverflow.com/comment/22278154
upvote count: 28
answers question: http://stackoverflow.com/q/2716596
has comment: http://stackoverflow.com/comment/139065623
has body: There is a more efficient variant of @DJClayworth's answer. As @seh correctly noticed, ByteArrayOutputStream.toByteArray() returns a copy of the backing byte[] object, which may be inefficient. However, the backing byte[] object as well as the count of the bytes are both protected members of the ByteArrayOutputStream class. Hence, you can create your own variant of the ByteArrayOutputStream exposing them directly: public class MyByteArrayOutputStream extends ByteArrayOutputStream { public MyByteArrayOutputStream() { } public MyByteArrayOutputStream(int size) { super(size); } public int getCount() { return count; } public byte[] getBuf() { return buf; } } Using this class is easy: MyByteArrayOutputStream out = new MyByteArrayOutputStream(); fillTheOutputStream(out); return new ByteArrayInputStream(out.getBuf(), 0, out.getCount()); As a result, once all the output is written the same buffer is used as the basis of an input stream.
downvote count: 0
score: 28
type: Answer
has comment: http://stackoverflow.com/comment/43681899
has comment: http://stackoverflow.com/comment/134634788

http://stackoverflow.com/comment/73362650
type: AnswerComment
has text: [PLUS ONE] Nice flowers!
type: Comment
comment on: http://stackoverflow.com/a/17142065
score: 7

http://stackoverflow.com/comment/2625262
has text: What was the ouptut from your test?
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/2614066

http://stackoverflow.com/q/2738342
downvote count: 0
has answer: http://stackoverflow.com/a/24375664
favorite count: 0
answer count: 4
possible better answer: http://stackoverflow.com/a/2738407
type: AnsweredQuestion
has title: Deploying java class files without restarting JBoss
has answer: http://stackoverflow.com/a/42266476
tagged with: java
tagged with: jboss
has answer: http://stackoverflow.com/a/2738407
type: Question
score: 5
upvote count: 5
has answer: http://stackoverflow.com/a/2738380
accepted answer: http://stackoverflow.com/a/2738380
has body: I would like to know if its possible to deploy java class files without restarting JBoss server. I am using jboss v4.2.2. Also, when I try to deploy jsp files, it works fine and server picks up the changes almost instantly. Thanks a lot in advance :)

http://stackoverflow.com/comment/21921403
comment on: http://stackoverflow.com/a/2772214
type: Comment
has text: @EJP what do you mean by *overlapping* arrays?
score: 0
type: AnswerComment

http://stackoverflow.com/a/2616396
score: 0
type: Answer
has body: I think that you may have to request for permission in your JNLP file. Try adding &lt;security&gt; &lt;all-permissions/&gt; &lt;/security&gt; See http://java.sun.com/javase/6/docs/technotes/guides/javaws/developersguide/syntax.html.
has comment: http://stackoverflow.com/comment/2632611
answers question: http://stackoverflow.com/q/2599284
has comment: http://stackoverflow.com/comment/2639327

http://stackoverflow.com/comment/2768271
type: AnswerComment
score: 0
type: Comment
has text: by changing the port I got this error com.sun.mail.smtp.SMTPSendFailedException: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 http://mail.google.com/support/bin/answer.py?answer=14257 i35sm2744098gve.26
comment on: http://stackoverflow.com/a/2739625

http://stackoverflow.com/q/2776425
accepted answer: http://stackoverflow.com/a/2776472
upvote count: 1
tagged with: swing
type: AnsweredQuestion
has title: Add a Component to two different JTabbedPanes
score: 1
tagged with: java
type: Question
answer count: 1
downvote count: 0
has answer: http://stackoverflow.com/a/2776472
favorite count: 0
tagged with: jtabbedpane
has body: I have a LinkedList of Components, each of which I would like to add into two different JTabbedPanes. For some reason, Swing is only letting me put each component into one or the other. The code I'm using is the following: /* The two tab panes */ JTabbedPane leftTabs = new JTabbedPane(); JTabbedPane rightTabs = new JTabbedPane(); for (int i=0; i&lt;tabPanes.size(); i++) { rightTabs.add(tabPanes.get(i)); leftTabs.add(tabPanes.get(i)); } Whichever add call I put last is the one that works; if I add to leftTabs last, then rightTabs ends up empty, and vice-versa. Any ideas on how to get this working? Thanks!

http://stackoverflow.com/q/2649073
has answer: http://stackoverflow.com/a/2649108
type: AnsweredQuestion
tagged with: java
type: Question
has title: FileInputStream throws NullPointerException
tagged with: fileinputstream
has answer: http://stackoverflow.com/a/2649349
possible better answer: http://stackoverflow.com/a/2649118
score: 0
tagged with: nullpointerexception
answer count: 3
accepted answer: http://stackoverflow.com/a/2649108
has answer: http://stackoverflow.com/a/2649118
has body: I am getting nullpointerexception, don't know what actually is causing it. I read from java docs that fileinputstream only throws securityexception so don't understand why this exception pops up. here is my code snippet. private Properties prop = new Properties(); private String settings_file_name = "settings.properties"; private String settings_dir = "\\.autograder\\"; public Properties get_settings() { String path = this.get_settings_directory(); System.out.println(path + this.settings_dir + this.settings_file_name); if (this.settings_exist(path)) { try { FileInputStream in = new FileInputStream(path + this.settings_dir + this.settings_file_name); this.prop.load(in); in.close(); } catch (IOException e) { e.printStackTrace(); } } else { this.create_settings_file(path); try{ this.prop.load(new FileInputStream(path + this.settings_dir + this.settings_file_name)); }catch (IOException ex){ //ex.printStackTrace(); } } return this.prop; } private String get_settings_directory() { String user_home = System.getProperty("user.home"); if (user_home == null) { throw new IllegalStateException("user.home==null"); } return user_home; } and here is my stacktrace: C:\Users\mohamed\.autograder\settings.properties Exception in thread "main" java.lang.NullPointerException at autograder.Settings.get_settings(Settings.java:41) at autograder.Application.start(Application.java:20) at autograder.Main.main(Main.java:19) Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds) Line 41 is: this.prop.load(in);

http://stackoverflow.com/comment/2767856
comment on: http://stackoverflow.com/a/2739295
has text: Which configuration file do you mean?
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/11122919
score: 31
upvote count: 31
has comment: http://stackoverflow.com/comment/53139352
answers question: http://stackoverflow.com/q/2637864
has comment: http://stackoverflow.com/comment/38849696
downvote count: 0
type: Answer
has body: Singleton scope in spring means single instance in a Spring context .. Spring container merely returns the same instance again and again for subsequent calls to get the bean. And spring doesn't bother if the class of the bean is coded as singleton or not , in fact if the class is coded as singleton whose constructor as private, Spring use BeanUtils.instantiateClass (javadoc here) to set the constructor to accessible and invoke it. Alternatively, we can use a factory-method attribute in bean definition like this &lt;bean id="exampleBean" class="example.Singleton" factory-method="getInstance"/&gt;

http://stackoverflow.com/q/2652414
type: AnsweredQuestion
has body: I am trying to get the selected items string out of a Spinner. So far I have gotten this: bundle.putString(ListDbAdapter.DB_PRI, v.getText().toString()); This does not work and gives a class casting exception (I thought I could cast a View to a widget that inherits it. Obviously not!) So how do you get the selected value of a Spinner?
tagged with: java
has title: How do you get the selected value of a Spinner?
has answer: http://stackoverflow.com/a/72570588
type: Question
has answer: http://stackoverflow.com/a/4204065
has answer: http://stackoverflow.com/a/32848428
accepted answer: http://stackoverflow.com/a/2652629
score: 53
upvote count: 53
has answer: http://stackoverflow.com/a/9259495
downvote count: 0
tagged with: spinner
favorite count: 0
answer count: 9
has answer: http://stackoverflow.com/a/2652649
has answer: http://stackoverflow.com/a/44636200
has answer: http://stackoverflow.com/a/7059188
tagged with: android
has answer: http://stackoverflow.com/a/2652629
has answer: http://stackoverflow.com/a/32088612
possible better answer: http://stackoverflow.com/a/2652649

http://stackoverflow.com/comment/2715364
has text: @JRL: That is not possible. Everything must be done within this one program in the simplest, most primitive but fast way.
comment on: http://stackoverflow.com/q/2693223
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/2647277
type: Comment
comment on: http://stackoverflow.com/a/2614126
score: 0
type: AnswerComment
has text: Nice, but can you do it without publishing the reference in the constructor. That's what I'm really after and according to the book it is possible

http://stackoverflow.com/comment/2618489
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2608241
has text: source file encoding defaults to the platform default encoding, i.e. usually not UTF-8.

http://stackoverflow.com/q/2705990
type: Question
tagged with: c#
score: 3
tagged with: java
upvote count: 3
answer count: 2
has answer: http://stackoverflow.com/a/2706003
has answer: http://stackoverflow.com/a/2706006
favorite count: 0
has body: I'm looking to find the equivalent in C# for the equivalent of this regex. Java: public static final String expression = "[\\s\\p{Punct}]"; {Punct} is a reserved character class in Java but I'm not sure how to create the equivalent expression so that the .net regex engine doesn't barf.
type: UnansweredQuestion
tagged with: regex
has title: C# equivalent of Java Punctuation regex
downvote count: 0

http://stackoverflow.com/comment/63590793
type: AnswerComment
comment on: http://stackoverflow.com/a/38062319
type: Comment
has text: The question is just finding if there exists a loop or not.In this case,yes,the question will absolutely work fine and get the desired boolean result for the case.If you want the exact node from where the loop started,then we will need to add somethng more to the code.But as far as producing a result is concerned,this willl produce a faster conclusion.
score: 0

http://stackoverflow.com/a/2759542
has body: A jndi.properties file should be at the root of the classpath and typically contains the URL of the JNDI server and the initial context factory to use. For example, with JBoss: java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.provider.url=jnp://localhost:1099 But, when using Hibernate, you should actually declare these properties in the hibernate.cfg.xml. For example, with WebLogic: weblogic.jndi.WLInitialContextFactory t3://127.0.0.1:7001
has comment: http://stackoverflow.com/comment/2791302
has comment: http://stackoverflow.com/comment/2791396
has comment: http://stackoverflow.com/comment/2791912
has comment: http://stackoverflow.com/comment/2791752
score: 0
has comment: http://stackoverflow.com/comment/2791495
type: Answer
answers question: http://stackoverflow.com/q/2759300

http://stackoverflow.com/q/2665569
has answer: http://stackoverflow.com/a/38147303
has body: My code snippet: ExecutorService executor = Executors.newSingleThreadExecutor(); try { Task t = new Task(response,inputToPass,pTypes,unit.getInstance(),methodName,unit.getUnitKey()); Future&lt;SCCallOutResponse&gt; fut = executor.submit(t); response = fut.get(unit.getTimeOut(),TimeUnit.MILLISECONDS); } catch (TimeoutException e) { // if the task is still running, a TimeOutException will occur while fut.get() cat.error("Unit " + unit.getUnitKey() + " Timed Out"); response.setVote(SCCallOutConsts.TIMEOUT); } catch (InterruptedException e) { cat.error(e); } catch (ExecutionException e) { cat.error(e); } finally { executor.shutdown(); } How should i handle the InterruptedException and ExecutionException in the code? And in what cases, are these exceptions thrown?
downvote count: 0
possible better answer: http://stackoverflow.com/a/2665594
score: 42
accepted answer: http://stackoverflow.com/a/2686613
has answer: http://stackoverflow.com/a/2665594
answer count: 3
tagged with: executorservice
favorite count: 0
linked to: http://stackoverflow.com/q/10964882
tagged with: multithreading
tagged with: future
has answer: http://stackoverflow.com/a/2686613
type: AnsweredQuestion
tagged with: interrupted-exception
has title: In what cases does Future.get() throw ExecutionException or InterruptedException
tagged with: java
upvote count: 42
type: Question

http://stackoverflow.com/a/2622234
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/2634608
upvote count: 1
answers question: http://stackoverflow.com/q/2622206
type: Answer
has body: You could do this by opening the file for writing and then truncating its content, the following example uses NIO: import static java.nio.file.StandardOpenOption.*; Path file = ...; OutputStream out = null; try { out = new BufferedOutputStream(file.newOutputStream(TRUNCATE_EXISTING)); } catch (IOException x) { System.err.println(x); } finally { if (out != null) { out.flush(); out.close(); } } Another way: truncate just the last 20 bytes of the file: import java.io.RandomAccessFile; RandomAccessFile file = null; try { file = new RandomAccessFile ("filename.ext","rw"); // truncate 20 last bytes of filename.ext file.setLength(file.length()-20); } catch (IOException x) { System.err.println(x); } finally { if (file != null) file.close(); }

http://stackoverflow.com/comment/91402092
type: AnswerComment
score: 0
type: Comment
has text: Can you server side render that?
comment on: http://stackoverflow.com/a/29895662

http://stackoverflow.com/q/2604451
accepted answer: http://stackoverflow.com/a/2604490
tagged with: excel
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/1176080
tagged with: java
has body: Possible Duplicate: Create Excel file in Java How to save output in excel format rather than in .txt file?
downvote count: 1
has comment: http://stackoverflow.com/comment/16189426
duplicate of: http://stackoverflow.com/q/1176080
type: Question
upvote count: 0
score: -1
has title: How to save output in excel format?
has answer: http://stackoverflow.com/a/2604490
answer count: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/16189490

http://stackoverflow.com/comment/2754380
score: 0
has text: @bkail: +1 to you for you're the only one in this thread to mention that a Java *char* cannot store arbitrary codepoints and that *int* should be used instead.
comment on: http://stackoverflow.com/a/2726150
type: AnswerComment
type: Comment

http://stackoverflow.com/q/2604980
type: Question
tagged with: iphone
has answer: http://stackoverflow.com/a/2604988
accepted answer: http://stackoverflow.com/a/2604988
score: 4
has comment: http://stackoverflow.com/comment/2614892
has body: I accidentally bumped into an ad like this: http://monotouch.net/DownloadTrial?ref=so1. Then I start to wonder if we have an equivalent thing in Java. From my understanding, objective c is still the only language that people use to develop iPhone apps. Is this true?
has answer: http://stackoverflow.com/a/2604993
answer count: 3
has comment: http://stackoverflow.com/comment/2614905
has title: Is it possible to develop IPhone applications with Java?
possible better answer: http://stackoverflow.com/a/2604993
favorite count: 0
has comment: http://stackoverflow.com/comment/2614895
has comment: http://stackoverflow.com/comment/2615429
has answer: http://stackoverflow.com/a/2604998
upvote count: 4
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2615604
downvote count: 0
linked to: http://stackoverflow.com/q/2050943
tagged with: java

http://stackoverflow.com/a/2722028
upvote count: 0
has body: Strings are more commonly concatenated with the + operator, as in "Hello," + " world" + "!" Source
has comment: http://stackoverflow.com/comment/2748184
answers question: http://stackoverflow.com/q/2721998
type: Answer
score: -2
downvote count: 2

http://stackoverflow.com/comment/85560497
has text: @zackygaurav According to the [javadoc](https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/conn/ssl/AllowAllHostnameVerifier.html), `AllowAllHostnameVerifier` is replaced by `NoopHostnameVerifier`"
type: AnswerComment
score: 3
type: Comment
comment on: http://stackoverflow.com/a/28318375

http://stackoverflow.com/q/2664687
linked to: http://stackoverflow.com/q/592303
tagged with: oop
has body: I have a small socket server, and I need to distribute various messages from client-to-client depending on different conditionals. However I think I have a small problem with livelyness in my current code, and is there anything wrong in my approach: public class CuClient extends Thread { Socket socket = null; ObjectOutputStream out; ObjectInputStream in; CuGroup group; public CuClient(Socket s, CuGroup g) { this.socket = s; this.group = g; out = new ObjectOutputStream(this.socket.getOutputStream()); out.flush(); in = new ObjectInputStream(this.socket.getInputStream()); } @Override public void run() { String cmd = ""; try { while (!cmd.equals("client shutdown")) { cmd = (String) in.readObject(); this.group.broadcastToGroup(this, cmd); } out.close(); in.close(); socket.close(); } catch (Exception e) { System.out.println(this.getName()); e.printStackTrace(); } } public void sendToClient(String msg) { try { this.out.writeObject(msg); this.out.flush(); } catch (IOException ex) { } } And my CuGroup: public class CuGroup { private Vector&lt;CuClient&gt; clients = new Vector&lt;CuClient&gt;(); public void addClient(CuClient c) { this.clients.add(c); } void broadcastToGroup(CuClient clientName, String cmd) { Iterator it = this.clients.iterator(); while (it.hasNext()) { CuClient cu = (CuClient)it.next(); cu.sendToClient(cmd); } } } And my main-class: public class SmallServer { public static final Vector&lt;CuClient&gt; clients = new Vector&lt;CuClient&gt;(10); public static boolean serverRunning = true; private ServerSocket serverSocket; private CuGroup group = new CuGroup(); public void body() { try { this.serverSocket = new ServerSocket(1337, 20); System.out.println("Waiting for clients\n"); do { Socket s = this.serverSocket.accept(); CuClient t = new CuClient(s,group); System.out.println("SERVER: " + s.getInetAddress() + " is connected!\n"); t.start(); } while (this.serverRunning); } catch (IOException ex) { ex.printStackTrace(); } } public static void main(String[] args) …
tagged with: java
type: Question
answer count: 2
has title: Socket server with multiple clients, sending messages to many clients without hurting liveliness
has answer: http://stackoverflow.com/a/2665006
score: 0
has comment: http://stackoverflow.com/comment/2682775
type: UnansweredQuestion
tagged with: multithreading
has answer: http://stackoverflow.com/a/2664716
tagged with: design-patterns

http://stackoverflow.com/comment/2700193
comment on: http://stackoverflow.com/a/2676201
type: AnswerComment
has text: @Brad. You can't do it the way you have done. It is possible as a static method. See Edit.
type: Comment
score: 0

http://stackoverflow.com/q/2759618
type: Question
has title: Integration testing - Hibernate & DbUnit
has answer: http://stackoverflow.com/a/2759817
has answer: http://stackoverflow.com/a/2759757
score: 4
has answer: http://stackoverflow.com/a/2759821
favorite count: 0
possible better answer: http://stackoverflow.com/a/2759817
upvote count: 4
has body: I'm writing some integrations tests in JUnit. What happens here is that when i run all the tests together in a row (and not separately), the data persisted in the database always changes and the tests find unexpected data (inserted by the previous test) during their execution. I was thinking to use DbUnit, but i wonder if it resets the auto-increment index between each execution or not (because the tests also check the IDs of the persisted entities). Thanks M.
answer count: 4
tagged with: dbunit
type: AnsweredQuestion
downvote count: 0
tagged with: java
tagged with: hibernate
tagged with: orm
has answer: http://stackoverflow.com/a/2759641
tagged with: integration-testing
accepted answer: http://stackoverflow.com/a/2759757

http://stackoverflow.com/comment/78887117
comment on: http://stackoverflow.com/a/24370091
type: AnswerComment
type: Comment
score: 1
has text: @eis, I was pointing out that this answer addresses the original question in certain cases but not others.

http://stackoverflow.com/q/2691539
favorite count: 0
has answer: http://stackoverflow.com/a/2691643
has answer: http://stackoverflow.com/a/2691717
has comment: http://stackoverflow.com/comment/2712812
possible better answer: http://stackoverflow.com/a/2691643
type: AnsweredQuestion
has body: I'm sorry if the question title may mis-inform you, but I cannot find a proper word to explain that. If you ever working with .NET, you would know that there is Assert class that will automatically wake up and attach debugger if necessary and then have debugger (Visual Studio) pausing at the Assert command, given the Assert command failed. Given I'm running a java program and having debugger connected, then how can I have debugger to break on certain condition without manually setup a break point? I'm expecting something like that: void doSomeThing(String x){ if (x==null) breakDebuggerNow(); }
score: 1
tagged with: java
upvote count: 1
type: Question
tagged with: debugging
accepted answer: http://stackoverflow.com/a/2691717
answer count: 2
has title: How to write a virtual conditional breakpoint in java
downvote count: 0

http://stackoverflow.com/q/2756170
type: Question
downvote count: 0
has answer: http://stackoverflow.com/a/2756195
tagged with: writer
has title: Trying to write a loop that uses an OutputStream to write to a text file
has body: I'm not a java programmer, I'm a VB programmer. I am doing this as part of an assignment, however, I'm not asking for help on something assignment related. I'd like to figure out how to get the OutputStreamWriter to work properly in this instance. I just want to capture the values I'm generating and place them into a text document. The file is generated, but only one entry exists, not the 40 I'm expecting. I could do this in a heartbeat with VB, but java feels very strange to me right now. Your help is appreciated. Thanks, Steve Here's the code: public static void main(String[] args) { long start, end; double result,difference; try { //OutputStream code assistance from // http://tutorials.jenkov.com/java-io/outputstreamwriter.html OutputStream outputStream = new FileOutputStream("c:\\Temp\\output1.txt"); Writer out = new OutputStreamWriter(outputStream); for(int n=1; n&lt;=20; n++) { //Calculate the Time for n^2. start = System.nanoTime(); //Add code to call method to calculate n^2 result = mN2(n); end = System.nanoTime(); difference = (end - start); //Output results to a file out.write("N^2 End time: " + end + " Difference: " + difference + "\n"); out.close(); } } catch (IOException e){ } try { OutputStream outputStream = new FileOutputStream("c:\\Temp\\output1.txt"); Writer out = new OutputStreamWriter(outputStream); for(int n=1; n&lt;=20; n++){ //Calculate the Time for 2^n. start = System.nanoTime(); //Add code to call method to calculate 2^n result = m2N(n); end = System.nanoTime(); difference = (end - start); //Output results to a file out.write("N^2 End time: " + end + " Difference: " + difference + "\n"); out.close(); } } catch (IOException e){ } } //Calculate N^2 public static double mN2(double n) { n = n*n; return n; } //Calculate 2N public static double m2N(double n) { n = 2*n; return n; }
answer count: 1
tagged with: outputstream
score: 1
favorite count: 0
accepted answer: http://stackoverflow.com/a/2756195
tagged with: text
type: AnsweredQuestion
tagged with: java
upvote count: 1

http://stackoverflow.com/a/52503800
answers question: http://stackoverflow.com/q/2599698
has body: import java.util.Arrays; import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; public class FuntionAsParameter { public static void main(final String[] args) { Person p1 = new Person("Jenny", 20); Person p2 = new Person("Kate", 22); List&lt;Person&gt; pList = Arrays.asList(new Person[]{p1, p2}); Function&lt;List&lt;Person&gt;, List&lt;Person&gt;&gt; theFunction = Function.&lt;List&lt;Person&gt;&gt;identity() .andThen(personList -&gt; personList .stream() .map(person -&gt; new Person(person.getName(), person.getAge() + 1)) .collect(Collectors.toList())); // You can use this directly List&lt;Person&gt; directly = theFunction.apply(pList); directly.forEach(person -&gt; System.out.println(person)); // Or use it as an input parameter List&lt;Person&gt; toMethod = modList(pList, theFunction); toMethod.forEach(person -&gt; System.out.println(person)); // Or you might prefer this way List&lt;Person&gt; thirdWay = modList(pList, (list) -&gt; list.stream() .map(person -&gt; new Person(person.getName(), person.getAge() + 1)) .collect(Collectors.toList()) ); thirdWay.forEach(person -&gt; System.out.println(person)); } private static List&lt;Person&gt; modList(List&lt;Person&gt; personList, Function&lt;List&lt;Person&gt;, List&lt;Person&gt;&gt; theFunction) { return theFunction.apply(personList); } } class Person { private String name; private int age; public Person(final String name, final int age) { this.name = name; this.age = age; } public String getName() { return name; } public int getAge() { return age; } @Override public String toString() { return "Person{" + "name='" + name + '\'' + ", age=" + age + '}'; } }
score: 0
type: Answer

http://stackoverflow.com/a/2614935
has body: A distributed in-memory cache like memcached might be what you are looking for. You can configure object age, cache size and also expose callbacks to remove specific objects from the cache (like when the information is stale).
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/2628264
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2608842

http://stackoverflow.com/comment/2790772
score: 4
type: AnswerComment
comment on: http://stackoverflow.com/a/2759040
has text: The executor will only schedule this cancel once. If the task is completed then the cancel is a no op and work continues unchanged. There only needs to be one extra thread scheudling to cancel the tasks and one thread to run them. You could have two executors, one to submit your main tasks and one to cancel them.
type: Comment

http://stackoverflow.com/a/2710391
has comment: http://stackoverflow.com/comment/8775079
upvote count: 7
answers question: http://stackoverflow.com/q/2710303
score: 7
has body: To create a connection, you need to load the driver first. For example, for MySQL: Class.forName("com.mysql.jdbc.Driver"); The driver class to load obviously depends on the JDBC driver (and thus on the database) that needs to be on the classpath. Then, make the connection: String url = "jdbc:mysql://host_name:port/dbname"; String user = "scott"; String pwd = "tiger"; Connection con = DriverManager.getConnection(url, user, pwd); The url is the "connection url" and identifies the database to connect to. Again, the syntax will depend on the JDBC driver you're using. So, refer to the documentation of your JDBC driver. Establishing a Connection in The Java Tutorials is indeed a good reference.
downvote count: 0
type: Answer

logic
tags question: http://stackoverflow.com/q/2682793
tag name: logic
type: Tag
tags question: http://stackoverflow.com/q/2777887

http://stackoverflow.com/comment/2798656
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2762514
type: Comment
has text: @Yishai: saying that this *"whole question wouldn't make sense if the call was to an asynchronous method"* [sic] shows an amazing level of intellectual dishonesty: I've got **much** more callbacks in the 200KLOC codebase I'm working here made from other threads than from the same thread. It's basically the whole point of a callback: you don't really know who nor when nor from where it's going to be called. I'm bringing here a very real concern of uttermost importance and instead of acknowledging it you find excuse to justify your bogus answer. This is very sad, so is your upvote.

http://stackoverflow.com/q/2773225
type: Question
has comment: http://stackoverflow.com/comment/16964744
has comment: http://stackoverflow.com/comment/12244138
score: 0
answer count: 2
has body: Rerendering is not working in my code: &lt;rich:simpleTogglePanel id="bookIncomeHeader1" value="#{myBean.ftBoookIncomelst}" label="BOOK INCOME" bodyClass="STP" style="ReptxtBold Reptxt_LtPad" switchType="server"&gt; &lt;rich:dataTable id="bookIncome" value="#{myBean.ftBoookIncomelst}" var="item" rowKeyVar="row" first="0" width="100%"&gt; &lt;rich:subTable id="subBookIncome"value="#{item.txIncome}" var="income" rowKeyVar="row"&gt; &lt;rich:column id="descrtiptionColumn" width="30%"&gt; &lt;h:outputText value="#{income.descriptionCell.value}" rendered="#{!item.editableRow}" style="#{income.descriptionCell.boldClass}" /&gt; &lt;rich:inplaceInput layout="block" required="true" value="#{income.descriptionCell.value}" rendered="#{item.editableRow}" requiredMessage="Description at row #{row+1} wasn't filled." changedHoverClass="hover" viewHoverClass="hover" viewClass="inplace" changedClass="inplace" selectOnEdit="true" editEvent="onclick" /&gt; &lt;/rich:column&gt; In the above code I have proper id for datatable and I'm calling my ajax call using: &lt;rich:menuItem value="Add Manual Adjustment" id="addmanualadjust"&gt; &lt;a4j:support event="onclick" action="#{myBean.addNewDataItem}" reRender="bookIncome"&gt; &lt;f:param name="rowNum" value="#{item.serialNum}"&gt;&lt;/f:param&gt; &lt;/a4j:support&gt; &lt;/rich:menuItem&gt; It's hitting the server and calling proper method and updating the required list, but it's not showing any response. Why is it not rendering? It does not show any exception on console either.
tagged with: richfaces
type: UnansweredQuestion
tagged with: jsf
tagged with: ajax4jsf
tagged with: java
has title: reRendering is not happening in jsf using data table
has answer: http://stackoverflow.com/a/2774488
has answer: http://stackoverflow.com/a/2792197

http://stackoverflow.com/a/2738908
answers question: http://stackoverflow.com/q/2674325
has body: I changed one of the compilation option in eclipse and the problem disappeared. Under workspace properties: Java Compiler -> Errors/Warnings -> Change 'Unused import' from 'Warning' to 'Ignore'.
score: 0
type: AcceptedAnswer
type: Answer
accepted answer of: http://stackoverflow.com/q/2674325
has comment: http://stackoverflow.com/comment/2768292

http://stackoverflow.com/q/2654055
score: 0
has body: I try to create an page of the following structure: MainPage { DateSelector {} TabGroup { Tab0 {...} Tab1 {...} Tab2 {...} } } DateSelector is a component (extending Panel) that enables the user to select a timespan (startDate, endDate). TabGroup extending "AjaxTabbedPanel". The tabs shown in the TabGroup should use the selected timespan to display content. So if the user selects a timespan in the selector the content in the selected tab should update. For this I implement a method the user of the DateSelector could override to update its contents. I have the feeling that my approch is against the framework. Could I utilise a model in some way to enhance the implementation? What is 'wrong' with this? Can the tabs share the timespan with the DateSelector, such that they update if teh timespan change? Without the callback? The DateSelector is implemented like this: abstract public class TimespanSelectionPanel extends Panel { public TimespanSelectionPanel(String id, Timespan timespan) { super(id, new CompoundPropertyModel&lt;Timespan&gt;(timespan)); final DateTextField fromTextField = DateTextField.forDatePattern("from", "dd.MM.yyyy"); fromTextField.setOutputMarkupId(true); fromTextField.add(new DatePicker()); final DateTextField toTextField = DateTextField.forDatePattern("to", "dd.MM.yyyy"); toTextField.setOutputMarkupId(true); toTextField.add(new DatePicker()); fromTextField.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { } }); toTextField.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { } }); add(new AjaxLink&lt;String&gt;("today") { @Override public void onClick(AjaxRequestTarget target) { updateComponent(fromTextField, toTextField, target, Timespan.today()); } }); add(new AjaxLink&lt;String&gt;("yesterday") { @Override public void onClick(AjaxRequestTarget target) { updateComponent(fromTextField, toTextField, target, Timespan.y…
answer count: 1
has answer: http://stackoverflow.com/a/2678263
accepted answer: http://stackoverflow.com/a/2678263
tagged with: wicket
type: AnsweredQuestion
tagged with: java
type: Question
has title: How to use the model in wicket?

http://stackoverflow.com/comment/2701298
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2679112
has text: There is a difference because you do not want to expose the implementation of the class. By creating a public setter for the internal property 'a' you've just blown it. Now you can't change your implementation because the world might depend on access to 'a'.

http://stackoverflow.com/q/2779791
possible better answer: http://stackoverflow.com/a/2779892
has answer: http://stackoverflow.com/a/2779821
tagged with: serialization
type: Question
answer count: 2
has body: I have class which is seralized and does convert a very large amount of data object to blob to save it to database.In the same class there is decode method to convert blob to the actual object.Following is the code for encode and decode of the object. private byte[] encode(ScheduledReport schedSTDReport) { byte[] bytes = null; try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(schedSTDReport); oos.flush(); oos.close(); bos.close(); //byte [] data = bos.toByteArray(); //ByteArrayOutputStream baos = new ByteArrayOutputStream(); //GZIPOutputStream out = new GZIPOutputStream(baos); //XMLEncoder encoder = new XMLEncoder(out); //encoder.writeObject(schedSTDReport); //encoder.close(); bytes = bos.toByteArray(); //GZIPOutputStream out = new GZIPOutputStream(bos); //out.write(bytes); //bytes = bos.toByteArray(); } catch (Exception e) { _log.error("Exception caught while encoding/zipping Scheduled STDReport", e); } decode(bytes); return bytes; } /* * Decode the report definition blob back to the * ScheduledReport object. */ private ScheduledReport decode(byte[] bytes) { ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ScheduledReport sSTDR = null; try { ObjectInputStream ois = new ObjectInputStream(bais); //GZIPInputStream in = new GZIPInputStream(bais); //XMLDecoder decoder = new XMLDecoder(in); sSTDR = (ScheduledReport)ois.readObject();//decoder.readObject(); //decoder.close(); } catch (Exception e) { _log.error("IOException caught while decoding/unzipping Scheduled STDReport", e); } return sSTDR; } The problem here is whenver I change something else in this class means any other method,a new class version is created and so the new version the class is unable to decode the originally encoded blob object. The object which I am passing for encode is also seralized object but this problem exists. Any ideas thanks
has title: Blob object not working properly even though the class is seralized
accepted answer: http://stackoverflow.com/a/2779821
score: 0
tagged with: java
tagged with: object
tagged with: blob
has answer: http://stackoverflow.com/a/2779892
type: AnsweredQuestion

http://stackoverflow.com/q/2680513
type: AnsweredQuestion
score: 1
tagged with: java
has body: i have a really basic java program just one .java/.class file (.java uncompiled .class compiled i guess) how do i make something that i can have run on someone elses computer?
answer count: 6
accepted answer: http://stackoverflow.com/a/2680547
linked to: http://stackoverflow.com/q/2272107
downvote count: 0
has answer: http://stackoverflow.com/a/2680537
has answer: http://stackoverflow.com/a/2680533
has answer: http://stackoverflow.com/a/2682218
favorite count: 0
has answer: http://stackoverflow.com/a/2680542
possible better answer: http://stackoverflow.com/a/2680533
tagged with: exe
has title: how do i create a .exe that runs a java program?
has answer: http://stackoverflow.com/a/2680526
has answer: http://stackoverflow.com/a/2680547
upvote count: 1
type: Question

http://stackoverflow.com/comment/2731418
comment on: http://stackoverflow.com/a/2704092
has text: It works with gone instead of magic numbers. Seems like another bug. Tnx
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/q/2610055
type: Question
downvote count: 0
has title: How can I make a ListView touch-sensitive in its full width for clicking an item?
accepted answer: http://stackoverflow.com/a/2610165
tagged with: android-listview
score: 3
tagged with: android
answer count: 1
favorite count: 0
has body: I have a ListView in a ListActivity populated with strings. However, only the text-part of a list item is clickable, and when it is clicked, only the text-part is highlighted (orange on black background). I would like to make the full line clickable, and when selected, the full line should be marked as selected. How can I do that? This is my layout XML: <?xml version="1.0" encoding="utf-8"?>
upvote count: 3
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2610165
tagged with: java

http://stackoverflow.com/q/2622555
tagged with: authorization
favorite count: 0
tagged with: security
type: Question
tagged with: jaas
has body: We are programming a three tier application with a rich GUI client using swing and we need to add some authentication and authorization control. I'm completely new in this topic so I made a bit research in the web. My first intention was to use JAAS for this feature, but as far as I can see, JAAS only contains functionality to execute privileged methods/actions, but there seems to be no functionality to determine whether the access is granted for some "Actions" to control the GUI. e.g. hide/disable some menus etc. Do I understand this wrong or is my approach wrong? Are there any alternatives to JAAS? Does any "best practice" exist to add authentication and authorization to GUI applications? Thanks for help, Eny
upvote count: 2
answer count: 3
tagged with: authentication
has answer: http://stackoverflow.com/a/2631332
tagged with: java
type: UnansweredQuestion
has title: Authentication and authorization frameworks for java GUI applications
has answer: http://stackoverflow.com/a/2631350
score: 2
downvote count: 0
has answer: http://stackoverflow.com/a/2624221

http://stackoverflow.com/a/2637787
has comment: http://stackoverflow.com/comment/2652688
has body: I would recommend keeping your sources separate from the eclipse workspace, and then use the function: Import existing project into workspace. That way you can keep your project under source control, while leaving Eclipse manage its workspace (located elsewhere) on its own. If you have only sources (anywhere you want), but no Eclipse project, all you need to do create a New Java project, and select your external directory as root directory for your sources. selecting "Create project from existing sources"
downvote count: 0
score: 10
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2652167
accepted answer of: http://stackoverflow.com/q/2637735
has comment: http://stackoverflow.com/comment/2652394
upvote count: 10
answers question: http://stackoverflow.com/q/2637735
type: Answer

http://stackoverflow.com/q/2773941
tagged with: java
has answer: http://stackoverflow.com/a/2775078
type: Question
score: 0
accepted answer: http://stackoverflow.com/a/2775078
answer count: 1
tagged with: equinox
tagged with: osgi
has title: OSGi Logging with spring-DM extender not logging
tagged with: spring
has body: My Setup: I am able to create a simple OSGi bundle with Log4J as my logging framework and when deployed to my OSGi container (Equinox) it works great my logging is configured very simply with a seperate bundle fragment that configures my logging. This setup does not have spring involved and it works really nicely. My Issue: I am converting over a spring application which uses log4j as its logging framework to OSGi, the first stage was creating various bundles for my spring application which I have now completed. The problem I have is that the OSGi logging fragment bundle that worked with the non spring applications does not configure my spring enabled bundles. I know the bundles are active as system.out.println does work however all my logging configuration is not working. I can see nothing in the console I do see a lot of spring output confirming my bundles services are exposed but no logging. Any suggestions appreciated.
tagged with: logging
type: AnsweredQuestion

http://stackoverflow.com/a/2761811
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2761047
answers question: http://stackoverflow.com/q/2761047
has body: There is SWTSwing, although it's not clear if it supports the Browser component. If you're looking for a native browser in Java, the jdic project can render Internet Explorer into a swing component. See https://jdic.dev.java.net/documentation/incubator/JDICplus/index.html Possibly more complete and current is the embedded browser support in NetBeans. http://wiki.netbeans.org/EmbeddedBrowserPlan68
type: Answer
upvote count: 1
score: 1
type: AcceptedAnswer

http://stackoverflow.com/comment/2832511
has text: The mantissa is actually 24 and 53 bits for float and double, respectively. It's just that the highest bit is not stored in the representation, because it's not needed (it is always 1).
type: Comment
comment on: http://stackoverflow.com/a/2781125
score: 12
type: AnswerComment

http://stackoverflow.com/a/17312386
score: 7
upvote count: 7
has comment: http://stackoverflow.com/comment/70673018
has comment: http://stackoverflow.com/comment/40683785
has comment: http://stackoverflow.com/comment/27175367
has comment: http://stackoverflow.com/comment/34538770
has body: For those who are still stumped with this problem (I tried all the above suggestions) -- If you're on a 64-bit version of Windows and you've installed the 32-bit JDK, besides adjusting PATH variables, you may need to adjust registry variables, too. I was pulling my hair out, having correctly set my PATH variables -- still to no avail -- and then only finding "vacated" Java entries in my registry, seemingly a deadend of fixing the "misfiring" Java Runtime Environment. By using Process Monitor to watch the program I was trying to get started, in order to sniff out where it was looking in the registry for Java (Runtime Environment), I triumphantly discovered that it's looking in the 32-bit version of registry entries, found in HKEY_LOCAL_MACHINE\SOFTWARE\**Wow6432Node**\JavaSoft\Java Runtime Environment. Within that key, you should find subkeys of different Java versions installed (past and/or present). Click on the subkey of the latest version (my subkey is currently 1.7.0_25, for example). After clicking on that subkey, you'll see registry string values listed on the right, and particularly, JavaHome and RuntimeLib. You need to modify the values of those two values to reflect the both the current folder and jvm.dll file, respectively. For example, in my case, the values were (previously) respectively set at C:\Program Files (x86)\Java\jre7 and C:\Program Files (x86)\Java\jre7\bin\client\jvm.dll which are nonexistent on my machine. I had to update these to the current folder and file of C:\Program Files (x86)\Java\jdk1.7.0_25\jre and C:\Program Files (x86)\Java\jdk1.7.0_25\jre\bin\client\jvm.dll. Again, this will depend entirely on both what version of Java (JDK and/or JRE) you have installed -- 32 or 64-bit -- and what type of operating system you're on -- 32 or 64-bit. Just know that they're reflected in different locations within the registry (like the Wow6432Node for 32 bit applications, in my case with the 32-bit JDK installed on a 64-bit machine). Now that I've …
downvote count: 0
answers question: http://stackoverflow.com/q/2619584
type: Answer

http://stackoverflow.com/a/2683465
upvote count: 15
score: 14
answers question: http://stackoverflow.com/q/2683182
has body: I put all of my custom exceptions into a com.company.project.exception package. I do this rather than putting them "close" to the locations where they crop up. Here's my reasoning: If a given exception is only cropping up within one or two service classes somewhere, it may not be a general enough exception to deserve its own class. Only if I see a common theme popping up in multiple places will I go to the trouble of creating a custom Exception class. And if it is popping up in multiple places, then there's no logical package to "attach" it to, so an exception-specific package seems like the right way to go.
downvote count: 1
type: Answer

http://stackoverflow.com/q/2646965
type: AnsweredQuestion
score: 2
downvote count: 0
tagged with: java
tagged with: jaxb
has answer: http://stackoverflow.com/a/2646995
type: Question
tagged with: jakarta-ee
has body: JAXB version 1 spec have a Validator object, in version 2 Validator object was deprecated and optional. What do I need to use instead Validator object?
upvote count: 2
has title: What to use instead validator in jaxb 2.0
answer count: 1
favorite count: 0
accepted answer: http://stackoverflow.com/a/2646995

http://stackoverflow.com/comment/2776418
type: AnswerComment
has text: It also surprise me, I would expect different from java.
type: Comment
score: 1
comment on: http://stackoverflow.com/a/2746782

http://stackoverflow.com/a/2707913
has comment: http://stackoverflow.com/comment/2735593
accepted answer of: http://stackoverflow.com/q/2707903
has comment: http://stackoverflow.com/comment/2735494
answers question: http://stackoverflow.com/q/2707903
has body: Welcome to JPA. If you use it, it means you will have huge problems if you update the database outside of JPA unless you know what you're doing and are very careful. This means you have to figure out how to flush any cached entities so they can be reloaded. Basically, don't update entities outside JPA if you can at all help it and if you do you will probably have to get into the workings of the caching model used by your particular JPA provider. If you need to update outside JPA a lot then JPA probably isn't the right choice for you.
has comment: http://stackoverflow.com/comment/2731922
score: 22
upvote count: 22
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2735649
has comment: http://stackoverflow.com/comment/2735481
has comment: http://stackoverflow.com/comment/2732042
type: Answer
has comment: http://stackoverflow.com/comment/106235571
has comment: http://stackoverflow.com/comment/2731904

http://stackoverflow.com/a/2786520
upvote count: 1
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/2786416
type: Answer
has body: Check java.util.ServiceLoader A service is a well-known set of interfaces and (usually abstract) classes. A service provider is a specific implementation of a service. The classes in a provider typically implement the interfaces and subclass the classes defined in the service itself. Service providers can be installed in an implementation of the Java platform in the form of extensions, that is, jar files placed into any of the usual extension directories. Providers can also be made available by adding them to the application's class path or by some other platform-specific means. This article explains the details.

http://stackoverflow.com/a/9492353
downvote count: 0
answers question: http://stackoverflow.com/q/2701100
type: Answer
score: 9
has body: I can change the default Java on CentOS using these steps: Add the IBM JDK: alternatives --install /usr/bin/java java /opt/WebSphere/AppServer/java/bin/java 3 Set the new IBM JDK as default: alternatives --config java (then select #3 in the list) Type java -version at the prompt to see the result.
upvote count: 9

http://stackoverflow.com/a/2728810
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2728793
score: 106
accepted answer of: http://stackoverflow.com/q/2728793
has comment: http://stackoverflow.com/comment/138995723
has comment: http://stackoverflow.com/comment/7188136
type: Answer
has comment: http://stackoverflow.com/comment/79318646
upvote count: 106
downvote count: 0
has body: Integer overflow This is due to integer overflow. When thisVal is very large and anotherVal is negative then subtracting the latter from the former yields a result that is bigger than thisVal which may overflow to the negative range.
has comment: http://stackoverflow.com/comment/85157026

http://stackoverflow.com/a/2769335
score: 3
upvote count: 3
has comment: http://stackoverflow.com/comment/2802526
downvote count: 0
answers question: http://stackoverflow.com/q/2769311
type: Answer
has body: It sounds like you're overthinking it. Why not just do String x = "abcde"; char y = x.charAt(x.length() - 1);

http://stackoverflow.com/q/2716749
accepted answer: http://stackoverflow.com/a/2716989
has answer: http://stackoverflow.com/a/3189355
has answer: http://stackoverflow.com/a/2716829
has answer: http://stackoverflow.com/a/2716891
has body: If a destructor throws in C++ during stack unwinding caused by an exception, the program terminates. (That's why destructors should never throw in C++.) Example: struct Foo { ~Foo() { throw 2; // whoops, already throwing 1 at this point, let's terminate! } }; int main() { Foo foo; throw 1; } terminate called after throwing an instance of 'int' This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. If a finally block is entered in Java because of an exception in the corresponding try block and that finally block throws a second exception, the first exception is silently swallowed. Example: public static void foo() throws Exception { try { throw new Exception("first"); } finally { throw new Exception("second"); } } public static void main(String[] args) { try { foo(); } catch (Exception e) { System.out.println(e.getMessage()); // prints "second" } } This question crossed my mind: Could a programming language handle multiple exceptions being thrown at the same time? Would that be useful? Have you ever missed that ability? Is there a language that already supports this? Is there any experience with such an approach? Any thoughts?
has answer: http://stackoverflow.com/a/2717067
has comment: http://stackoverflow.com/comment/2742426
downvote count: 0
possible better answer: http://stackoverflow.com/a/2716891
has answer: http://stackoverflow.com/a/3189946
favorite count: 0
has comment: http://stackoverflow.com/comment/2742442
tagged with: exception
has title: Throwing a new exception while throwing an old exception
has answer: http://stackoverflow.com/a/2716989
tagged with: c++
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2742466
has comment: http://stackoverflow.com/comment/2742597
has comment: http://stackoverflow.com/comment/2742382
tagged with: java
has answer: http://stackoverflow.com/a/2716841
type: Question
answer count: 8
has comment: http://stackoverflow.com/comment/2742468
has answer: http://stackoverflow.com/a/2716929
score: 5
has comment: http://stackoverflow.com/comment/2742531
upvote count: 5

http://stackoverflow.com/comment/2812432
comment on: http://stackoverflow.com/q/2774608
score: 4
type: QuestionComment
type: Comment
has text: You might find it better to use a key object that contains both the outer and inner key. Then you only have one map, and potentially a useful new type.

http://stackoverflow.com/q/2694517
has answer: http://stackoverflow.com/a/2694585
upvote count: 9
downvote count: 0
has comment: http://stackoverflow.com/comment/2719548
accepted answer: http://stackoverflow.com/a/2700374
possible better answer: http://stackoverflow.com/a/2700915
favorite count: 0
has answer: http://stackoverflow.com/a/2700915
has title: Lazy non-modifiable list in Google Collections
has comment: http://stackoverflow.com/comment/2718392
answer count: 4
type: AnsweredQuestion
tagged with: list
tagged with: guava
has answer: http://stackoverflow.com/a/2697682
tagged with: java
has answer: http://stackoverflow.com/a/2700374
tagged with: collections
has body: I was looking for a decent implementation of a generic lazy non-modifiable list implementation to wrap my search result entries. The unmodifiable part of the task is easy as it can be achieved by Collections.unmodifiableList() so I only need to sort out the the lazy part. Surprisingly, google-collections doesn't have anything to offer; while LazyList from Apache Commons Collections does not support generics. I have found an attempt to build something on top of google-collections but it seems to be incomplete (e.g. does not support size()), outdated (does not compile with 1.0 final) and requiring some external classes, but could be used as a good starting point to build my own class. Is anybody aware of any good implementation of a LazyList? If not, which option do you think is better: write my own implementation, based on google-collections ForwardingList, similar to what Peter Maas did; write my own wrapper around Commons Collections LazyList (the wrapper would only add generics so I don't have to cast everywhere but only in the wrapper itself); just write something on top of java.util.AbstractList; Any other suggestions are welcome. EDIT: explanation why I need a lazy list. I have got a Lucene search result (TopDocs) which is basically a bunch of pointers to Lucene documents. My search result class would take these pointers as an input and return a list of objects which are made of extracted and otherwise processed Lucene documents. By wrapping everything into a lazy list I want to ensure I am not doing expensive processing when unnecessary.
score: 9
type: Question

http://stackoverflow.com/comment/2788704
has text: @shil: can you qualify your own statement "hi i have problems in converting an XML document type into a `Document` object." -- which `Document` are you talking about here? Because if it's `javax.swing.text.Document` then unfortunately no, you can't cast it. You'd have to do a more elaborate conversion enabled by libraries (not by the Java language). See Michael's answer.
score: 0
comment on: http://stackoverflow.com/a/2757052
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/15655052
has text: @Vladimir I do not "flame". I am pointing out a very real possible cause of error in your application which may be very hard to find when it shows.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2663855
type: Comment

http://stackoverflow.com/a/2649331
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2665343
answers question: http://stackoverflow.com/q/2649216
type: Answer
accepted answer of: http://stackoverflow.com/q/2649216
has comment: http://stackoverflow.com/comment/2665521
has body: The problem is that you are writing out the String "String: " and then writing out control character \r, or carriage return, and then writing out the contents. The following version should work a bit better for you: FileWriter fout = new FileWriter("test.txt"); fout.write("Testing|10|true|two|false\n"); fout.write("Scanner|12|one|true|"); fout.close(); FileReader fin = new FileReader("test.txt"); Scanner src = new Scanner(fin).useDelimiter("[|\n]"); To really see what I am talking about with the \r, you should change your original program so the print code looks like this: } else { str = src.next().trim(); str = str.replace('\n', '_'); str = str.replace('\r', '_'); System.out.println("String: " + str); } You should see the output: String: false__Scanner
score: 0

http://stackoverflow.com/a/2686380
type: Answer
has comment: http://stackoverflow.com/comment/2706790
has comment: http://stackoverflow.com/comment/2707003
answers question: http://stackoverflow.com/q/2686236
has comment: http://stackoverflow.com/comment/2715953
has comment: http://stackoverflow.com/comment/2707067
upvote count: 1
accepted answer of: http://stackoverflow.com/q/2686236
score: 1
type: AcceptedAnswer
downvote count: 0
has body: In your loop: // while b2 not square while(!(isSqrt(b2, root))) { what is the purpose of the following instruction? root = root.add(b2.divide(root)).divide(TWO); I think that in order to check that b2 is a square, you should instead try to compute the square root (the above instruction is just one step of the canonical algorithm to compute square roots), with the method you already have: root = getIntSqrt(b2); The same observation applies to this code: // ?? final int bitLength = N.bitLength(); BigInteger root = BigInteger.ONE.shiftLeft(bitLength / 2); root = root.add(b2.divide(root)).divide(TWO); EDIT. The problem is that your sqrt() method needs an isSqrt() that checks whether root is an approximate root of n, whereas the loop in fermat() needs an exact check. I append some code that seems to pass your last test: import java.math.BigInteger; public class Fermat { private BigInteger a, b, N; private static final BigInteger TWO = BigInteger.valueOf(2); private static boolean isApproximateSqrt(BigInteger n, BigInteger root) { final BigInteger lowerBound = root.pow(2); final BigInteger upperBound = root.add(BigInteger.ONE).pow(2); return lowerBound.compareTo(n) &lt;= 0 &amp;&amp; n.compareTo(upperBound) &lt; 0; } private static BigInteger intSqrt(BigInteger n) { if (n.signum() &gt;= 0) { final int bitLength = n.bitLength(); BigInteger root = BigInteger.ONE.shiftLeft(bitLength / 2); while ( ! isApproximateSqrt(n, root) ) { root = root.add(n.divide(root)).divide(TWO); } return root; } else { throw new ArithmeticException("square root of negative number"); } } private void init() { a = intSqrt(N); // a &lt;- ceil(sqrt(N)) BigInteger b2, root; do { a = a.add(BigInteger.ONE); // a &lt;- a + 1 b2 = (a.multiply(a)).subtract(N); // b2 &lt;- (a * a) - N root = intSqrt(b2); } while( root.pow(2).compareTo(b2) != 0 ); // while b2 not exact sqrt b = root; } public void print() { BigInteger a2 = a.pow(2); BigInteger b2 = b.pow(2); BigInteger squareDifference = a2.subtract(b2); Syst…

http://stackoverflow.com/a/2756795
has comment: http://stackoverflow.com/comment/2794183
type: Answer
upvote count: 7
has comment: http://stackoverflow.com/comment/2788291
has comment: http://stackoverflow.com/comment/2788294
score: 7
answers question: http://stackoverflow.com/q/2756714
has body: To keep track of the count of each word, I would use a Map which maps a word to it's current count. String s[]={"cat","cat","dog","fox","cat","fox","dog","cat","fox"}; Map&lt;String, Integer&gt; counts = new HashMap&lt;String, Integer&gt;(); for (String word : s) { if (!counts.containsKey(word)) counts.put(word, 0); counts.put(word, counts.get(word) + 1); } To print the result, go through the keys in the map and get the final value. for (String word : counts.keySet()) System.out.println(word + ": " + (float) counts.get(word) / s.length);
has comment: http://stackoverflow.com/comment/2788406
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2756714
has comment: http://stackoverflow.com/comment/2788357

http://stackoverflow.com/a/2616364
answers question: http://stackoverflow.com/q/2616227
type: Answer
has body: I can only guess the reasons without seeing the full source code. I assume you are using CipherInput/OutputStream for your encryption. You should use separate instances of Cipher for each thread (each I/OStream). Every time you create a new connection or re-connect, run the init method of Cipher on both the client and server side and create new CipherInput/OutputStream instances. The cryptographic objects are stateful, therefore they cannot be shared between threads. Each thread and each connection should have its separate sets of stateful objects.
score: 0

http://stackoverflow.com/a/2713799
score: 2
downvote count: 0
answers question: http://stackoverflow.com/q/2713758
upvote count: 2
has body: For development purposes, I often use the Hypersonic SQL Database (HSQLDB). It's fast and lightweight, and good enough to get started. For a bigger application, I'd go for Derby, which supports more options.
type: Answer

http://stackoverflow.com/q/2716916
has answer: http://stackoverflow.com/a/5187765
tagged with: xsd
tagged with: http://stackoverflow.com/tag/xml
has answer: http://stackoverflow.com/a/2719834
has answer: http://stackoverflow.com/a/47874449
tagged with: java
tagged with: jaxb
possible better answer: http://stackoverflow.com/a/12929979
answer count: 4
upvote count: 9
has answer: http://stackoverflow.com/a/12929979
accepted answer: http://stackoverflow.com/a/2719834
type: AnsweredQuestion
downvote count: 0
has title: XML Schema to Java Classes with XJC
favorite count: 0
has body: I am using xjc to generate Java classes from the XML schema and the following is an excerpt of the XSD. <xs:element name="NameInfo"> <xs:complexType> <xs:sequence> <xs:choice> <xs:element ref="UnstructuredName"/> <xs:sequence> <xs:element ref="StructuredName"/> <xs:element ref="UnstructuredName" minOccurs="0"/> </xs:sequence> </xs:choice> <xs:element ref="SomethingElse" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> For the most part the generated classes are fine but for the above block I would get something like: public List<Object> getContent() { if (content == null) { content = new ArrayList<Object>(); } return this.content; } with the following comment above it: * You are getting this "catch-all" property because of the following reason: * The field name "UnstructuredName" is used by two different parts of a schema. See: * line XXXX of file:FILE.xsd * line XXXX of file:FILE.xsd * To get rid of this property, apply a property customization to one * of both of the following declarations to change their names: * Gets the value of the content property. I have placed a comment at the end of the two line in question. At the moment, I don't think it will be easy to change the schema since this was decided between vendors and I would not want to go this route (if possible) as it will slow down progress quite a bit. I searched and have found this page, is the external customization what I want to do? I have been mostly working with the generated classes so I'm not entirely familiar with the process that generates these classes. A simple example of the "property customization" would be great! Alternative method of generating the Java classes would be fine as long as the schema can still be used. EDIT: I should clarify that the two UnstructuredName are indeed the same element.
tagged with: xjc
score: 9
type: Question

http://stackoverflow.com/q/2695141
has title: JButton Layout Issue
has comment: http://stackoverflow.com/comment/2717125
has body: I'm putting together the basic layout for a contacts book, and I want to know how I can make the 3 test buttons span from edge to edge just as the arrow buttons do. private static class ButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { System.out.println("Code Placeholder"); } } public static void main(String[] args) { //down button ImageIcon downArrow = new ImageIcon("down.png"); JButton downButton = new JButton(downArrow); ButtonHandler downListener = new ButtonHandler(); downButton.addActionListener(downListener); //up button ImageIcon upArrow = new ImageIcon("up.png"); JButton upButton = new JButton(upArrow); ButtonHandler upListener = new ButtonHandler(); upButton.addActionListener(upListener); //contacts JButton test1Button = new JButton("Code Placeholder"); JButton test2Button = new JButton("Code Placeholder"); JButton test3Button = new JButton("Code Placeholder"); Box box = Box.createVerticalBox(); box.add(test1Button); box.add(test2Button); box.add(test3Button); JPanel content = new JPanel(); content.setLayout(new BorderLayout()); content.add(box, BorderLayout.CENTER); content.add(downButton, BorderLayout.SOUTH); content.add(upButton, BorderLayout.NORTH); JFrame window = new JFrame("Contacts"); window.setContentPane(content); window.setSize(400, 600); window.setLocation(100, 100); window.setVisible(true); }
answer count: 1
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2695232
has comment: http://stackoverflow.com/comment/2717050
has comment: http://stackoverflow.com/comment/2717098
has comment: http://stackoverflow.com/comment/2717127
type: UnansweredQuestion
score: 1
tagged with: java
upvote count: 1
tagged with: swing
type: Question
has comment: http://stackoverflow.com/comment/2717070

http://stackoverflow.com/comment/2817949
comment on: http://stackoverflow.com/q/2782780
score: 0
type: Comment
type: QuestionComment
has text: Also, can you tell us what error messages you get, etc.? What are you sending in System.in? (command line?)

http://stackoverflow.com/q/2775508
type: UnansweredQuestion
tagged with: swing
tagged with: java
has title: Java Swing: How does using a JTable work?
type: Question
tagged with: jtable
has body: I am trying to build a little Table to show appointments. Here is what I have so far. Maybe you can give me a hint about what I am doing wrong, or which way to go. public class AppointmentTable extends JFrame{ public static void main(String[] args) { JTable table = new JTable(new AppointmentTableModel(10, 6, new ArrayList&lt;Appointment&gt;())); JScrollPane scrollPane = new JScrollPane(table); table.setFillsViewportHeight(true); AppointmentTable frame = new AppointmentTable(); frame.add(scrollPane); frame.setVisible(true); } public class AppointmentTable extends JFrame{ public static void main(String[] args) { JTable table = new JTable(new AppointmentTableModel(10, 6, new ArrayList&lt;Appointment&gt;())); JScrollPane scrollPane = new JScrollPane(table); table.setFillsViewportHeight(true); AppointmentTable frame = new AppointmentTable(); frame.add(scrollPane); frame.setVisible(true); } } public class AppointmentTableModel extends AbstractTableModel { private int columns; private int rows; ArrayList&lt;Appointment&gt; appointments; public AppointmentTableModel(int columns, int rows, ArrayList&lt;Appointment&gt; appointments) { this.columns = columns; this.rows = rows; this.appointments = appointments; } @Override public int getColumnCount() { return columns; } @Override public int getRowCount() { return rows; } @Override public Object getValueAt(int rowIndex, int columnIndex) { return appointments.get(rowIndex).getByColumn(columnIndex); } } public class Appointment { private Date date; private Sample sample; private String comment; private ArrayList&lt;Action&gt; history; public Appointment(Date date, Sample sample, String comment) { this.date = date; this.sample = sample; this.comment = comment; this.history = new ArrayList&lt;Action&gt;(); } public Object getByColumn(int columnIndex) { switch (columnIndex) { case 0: return date; case 1: return date; case 2: return sample; case 3: return sample; case 4: return history; case 5: return comment; } return null; } } publi…
score: 0
answer count: 1
has comment: http://stackoverflow.com/comment/2813361
has answer: http://stackoverflow.com/a/2776174

http://stackoverflow.com/a/2689644
type: Answer
has body: Vinze is right - The usage of a Comparator is recommended here. In your case, the comparator is statefull; at construction time, you have to provide it with data regarding the votes of the different items (since they are not part of the items). Collections.sort(..) is a good idea if you want to make your list sorted. If on the other hand you decide to put your items into some kind of SortedSet (or SortedMap), make sure that the votes (and other fields used by the comparator) stay unchanged. Otherwise the data structure will become corrupted and will no longer preserve the right order of items.
score: 3
answers question: http://stackoverflow.com/q/2689455
downvote count: 0
has comment: http://stackoverflow.com/comment/2711225
upvote count: 3

http://stackoverflow.com/q/2701151
has answer: http://stackoverflow.com/a/2701180
type: Question
answer count: 1
tagged with: diacritics
favorite count: 0
upvote count: 3
has title: FTP server output and accents
has body: I've written this little test class to connect up to an FTP server. import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; public class FTPTest { public static void main(String[] args) { URL url = null; try { url = new URL("ftp://anonymous:Password@127.0.0.1"); } catch (MalformedURLException e) { e.printStackTrace(); } URLConnection conn = null; try { conn = url.openConnection(); } catch (IOException e) { e.printStackTrace(); } InputStream in = null; try { in = conn.getInputStream(); } catch (IOException e) { e.printStackTrace(); } BufferedInputStream bin = new BufferedInputStream(in); int b; try { while ((b = bin.read()) != -1) { char c = (char) b; System.out.print("" + (char) b); } } catch (IOException e) { e.printStackTrace(); } } } Here's the output: -rw-r--r-- 1 ftp ftp 4700 Apr 30 2007 premier.java -rw-r--r-- 1 ftp ftp 88576 Oct 23 2007 Serie1_1.doc -rw-r--r-- 1 ftp ftp 1401 Nov 21 2006 tp20061121.txt drwxr-xr-x 1 ftp ftp 0 Apr 23 20:04 rÃ©pertoire Notice the name of the directory at the end of the list. There should be an "é" (e with acute accent) instead of the double character "Ã©". This reminds me of an issue encountered previously with JSF where there was a mix-up between standards. I have little experience with character-encoding though so I'm not sure what's happening. I'm supposing that the server output is in ASCII so how do I adapt the output so it appears correctly in the console?
tagged with: ftp
downvote count: 0
accepted answer: http://stackoverflow.com/a/2701180
type: AnsweredQuestion
score: 3
tagged with: java
tagged with: character-encoding

http://stackoverflow.com/a/2744522
has body: Because you are not required to capture the return value of a method in Java, in which case the compiler can not decide which overload to use. E.g. boolean doSomething() { ... } int doSomething() { ... } doSomething(); // which one to call???
upvote count: 85
has comment: http://stackoverflow.com/comment/59569857
score: 82
type: AcceptedAnswer
downvote count: 3
type: Answer
accepted answer of: http://stackoverflow.com/q/2744511
answers question: http://stackoverflow.com/q/2744511
has comment: http://stackoverflow.com/comment/7501370

http://stackoverflow.com/a/2622072
answers question: http://stackoverflow.com/q/2622062
upvote count: 4
has body: If double-clicking the .jar file in Windows Explorer works, then you should be able to use this: start myapp.jar in your batch file. The Windows start command does exactly the same thing behind the scenes as double-clicking a file.
downvote count: 0
score: 4
has comment: http://stackoverflow.com/comment/2640311
type: Answer
has comment: http://stackoverflow.com/comment/2641110

http://stackoverflow.com/comment/83583444
comment on: http://stackoverflow.com/a/33583575
type: Comment
score: 30
has text: This works awesome, but for this sentence i got the output saying "I have a boyfriend" :-)
type: AnswerComment

http://stackoverflow.com/q/2638761
answer count: 5
has answer: http://stackoverflow.com/a/2638844
has answer: http://stackoverflow.com/a/2638860
has answer: http://stackoverflow.com/a/2638788
has body: I've something like this Object[] myObjects = ...(initialized in some way)... int[] elemToRemove = new int[]{3,4,6,8,...} What's the most efficient way of removing the elements of index position 3,4,6,8... from myObjects ? I'd like to implement an efficient Utility method with a signature like public Object[] removeElements(Object[] object, int[] elementsToRemove) {...} The Object[] that is returned should be a new Object of size myObjects.length - elemToRemove.length
has answer: http://stackoverflow.com/a/2638836
type: AnsweredQuestion
has title: Java - What's the most efficient way of removing a set of elements from an Array[]
tagged with: java
has answer: http://stackoverflow.com/a/2638805
type: Question
upvote count: 4
has comment: http://stackoverflow.com/comment/2653096
has comment: http://stackoverflow.com/comment/6839483
tagged with: arrays
downvote count: 0
possible better answer: http://stackoverflow.com/a/2638805
score: 4
accepted answer: http://stackoverflow.com/a/2638836
favorite count: 0

task
type: Tag
tag name: task
tags question: http://stackoverflow.com/q/2763897

http://stackoverflow.com/q/2702132
tagged with: java-native-interface
has comment: http://stackoverflow.com/comment/2730539
accepted answer: http://stackoverflow.com/a/2734652
answer count: 2
tagged with: windows
downvote count: 0
favorite count: 0
score: 8
upvote count: 8
tagged with: linux
has title: How can I include platform-specific native libraries in the .JAR file using Eclipse?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2734652
has body: I am just starting to learn JNI. I have been following a simple example, and I have created a Java app that calls a Hello World method in a native library. I'd like to target Win32 and Linux x86. My library resides in a DLL, and I can call it just fine using LoadLibrary when the DLL is added to the root of my Eclipse project. However, I can't figure out how to get Eclipse to export a runnable JAR that includes the DLL and the .SO file for Linux. So my question is basically; how would you go about creating a project in Eclipse and include several versions of the same native library? Thank you, Martin
tagged with: java
tagged with: cross-platform
type: Question
possible better answer: http://stackoverflow.com/a/2734614
has answer: http://stackoverflow.com/a/2734614

http://stackoverflow.com/comment/2653102
score: 0
type: AnswerComment
has text: so there is no difference between 1 and 3 ?
type: Comment
comment on: http://stackoverflow.com/a/2638814

http://stackoverflow.com/a/2599153
score: 6
upvote count: 6
type: AcceptedAnswer
downvote count: 0
has body: I think it's safe to use ':'. It is hardcoded in SimpleDateFormat. For example: if (text.charAt(++pos.index) != ':')
type: Answer
accepted answer of: http://stackoverflow.com/q/2599127
answers question: http://stackoverflow.com/q/2599127

http://stackoverflow.com/a/2643311
downvote count: 0
has body: Try setting the DISPLAY environment variable in your terminal before running: export DISPLAY=&lt;IP address&gt;:0.0 Where is the address of your host (or its hostname). If you aren't running under a GUI at all, you'll have to run a virtual frame buffer. Xvfb is the one I've used in the past. Just make sure it's installed: sudo apt-get xvfb Then execute the following commands before running your app: Xvfb :1 -ac -screen 0 1024x768x8 &amp; export DISPLAY=:1 Then run the app..
upvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/2664335
score: 2
has comment: http://stackoverflow.com/comment/2658266
has comment: http://stackoverflow.com/comment/2664001
answers question: http://stackoverflow.com/q/2643179

http://stackoverflow.com/q/2648145
score: 6
has body: I know this may be a recurring topic, but I have read a lot of articles and I still have doubts. Also, I would like to hear more recent opinions about this. The main requirements of my application server are: flexible configuration, support for a extremely high number of concurrent users. It will be a system for the mobile communications industry, so it must have high availability as well. I am going to develop a Java EE application and Open Source Applications Servers are my only option. I have used GlassFish for a very small project and I really liked it.
has answer: http://stackoverflow.com/a/2648232
upvote count: 6
has title: Choosing an Open Source Application Server for Java EE
tagged with: java
has answer: http://stackoverflow.com/a/2648412
has answer: http://stackoverflow.com/a/2650359
has comment: http://stackoverflow.com/comment/2664007
type: Question
tagged with: jakarta-ee
tagged with: open-source
has answer: http://stackoverflow.com/a/2649270
has answer: http://stackoverflow.com/a/2649378
downvote count: 0
tagged with: application-server
favorite count: 0
answer count: 5
type: UnansweredQuestion

http://stackoverflow.com/a/46276980
type: Answer
has comment: http://stackoverflow.com/comment/124486563
answers question: http://stackoverflow.com/q/2643901
score: 0
has body: (on Windows OS without Service) Spring Boot start/stop sample. run.bat @ECHO OFF IF "%1"=="start" ( ECHO start your app name start "yourappname" java -jar -Dspring.profiles.active=prod yourappname-0.0.1.jar ) ELSE IF "%1"=="stop" ( ECHO stop your app name TASKKILL /FI "WINDOWTITLE eq yourappname" ) ELSE ( ECHO please, use "run.bat start" or "run.bat stop" ) pause start.bat @ECHO OFF call run.bat start stop.bat: @ECHO OFF call run.bat stop

http://stackoverflow.com/q/2643822
tagged with: java
type: Question
upvote count: 15
has answer: http://stackoverflow.com/a/27864752
tagged with: xwpf
score: 15
has answer: http://stackoverflow.com/a/2644902
possible better answer: http://stackoverflow.com/a/13642129
downvote count: 0
has answer: http://stackoverflow.com/a/13642129
favorite count: 0
has body: I'm creating a docx generator with POI and would like to use predefined formats. Word includes several formats like Title, Heading 1..10 etc. These formats are predefined in every DOCX you create with Word. I would like to use them in my docx generator. I tried the following but the format was not applied: paragraph = document.createParagraph(); lastParagraph.setStyle("Heading1"); I also tried "heading 1", "heading1" and "Heading1" as style, but none of them worked. The API documentation doesn't show any details. I analysed a docx file created with Word 2007 and found out "Heading1" would be correct. Unfortunately, the style is not defined in the docx. Do I have to create this style manually? Can anyone point me to the correct solution?
tagged with: http://stackoverflow.com/tag/docx
has answer: http://stackoverflow.com/a/2643972
linked to: http://stackoverflow.com/q/28628815
answer count: 4
accepted answer: http://stackoverflow.com/a/2644902
type: AnsweredQuestion
tagged with: apache-poi
has title: How can I use predefined formats in DOCX with POI?

dicom
tag name: dicom
type: Tag
tags question: http://stackoverflow.com/q/2665190

http://stackoverflow.com/comment/2724092
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2698710
has text: just that it's about hibernate, not NH :)

http://stackoverflow.com/a/2614514
answers question: http://stackoverflow.com/q/2614457
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2614457
has comment: http://stackoverflow.com/comment/2643464
type: Answer
has body: On problem with this approach it that the user will need to "tab over" the divider column. You could use the Table Tabbing suggestion to make it more user friendly. Or if tabbing between the two tables isn't important, then maybe you can use use two tables and put whatever divider you want betweeen the two. The selection model can shared if required. Edit: As I suggested above sharing models is easier than writing custom listeners. To keep the scrolling in sync the code would be: jspa.getVerticalScrollBar().setModel( jspb.getVerticalScrollBar().getModel() ); You can also do the same with the selection model so that highlighting of rows is in sync.
upvote count: 9
downvote count: 0
has comment: http://stackoverflow.com/comment/2635923
score: 9

http://stackoverflow.com/a/2730924
accepted answer of: http://stackoverflow.com/q/2728859
score: 0
type: AcceptedAnswer
has body: The URL is the URL that will be called to execute the task. AppEngine is very URL-oriented, and the task that is executed by the task queue is referred to by a URL. From the docs: App Engine applications can perform background processing by inserting tasks (modeled as web hooks) into a queue. The key point here is web hooks. Google can help you with web hooks.
type: Answer
answers question: http://stackoverflow.com/q/2728859

http://stackoverflow.com/comment/2608901
type: QuestionComment
has text: Have you tried to attach jconsole to get a better look what is going on?
comment on: http://stackoverflow.com/q/2599973
type: Comment
score: 0

http://stackoverflow.com/comment/2689840
type: QuestionComment
comment on: http://stackoverflow.com/q/2670982
score: 0
type: Comment
has text: @Alexander, what if this particular Map needs safe concurrent access, then wouldn't Hashtable be the right choice?

http://stackoverflow.com/comment/139789563
type: AnswerComment
type: Comment
has text: Unfortunately the example has disappeared
comment on: http://stackoverflow.com/a/66383590
score: 0

http://stackoverflow.com/q/2702315
score: 3
has answer: http://stackoverflow.com/a/2702335
tagged with: java
has comment: http://stackoverflow.com/comment/2741743
accepted answer: http://stackoverflow.com/a/2702987
possible better answer: http://stackoverflow.com/a/2702335
downvote count: 0
has title: Intelligent search and generation of Java code, preferrably using Python?
has comment: http://stackoverflow.com/comment/2726068
has body: Basically, I do lots of one-off code generation, large-scale refactorings, etc. etc. in Java. My tool language of choice is Python, but I'll take whatever solutions you can offer. Here is a simplified illustration of what I would like, in a pseudocode Generating an implementation for an interface search within my project: for each Interface as iName: write class(name=iName+"Impl", implements=iName) search within the body of iName: for each Method as mName: write method(name=mName, body="// TODO implement this...") Basically, the tool I'm searching for would allow me to: parse files according to their Java structure ("search for interfaces") search for words contextualized by language elements and types ("variables of type SomeClass", "doStuff() method calls on SomeClass instances") to run searches with structural context ("within the body of the current result") easily replace or generate code (with helpers to generate, as above, or functions for replacing, "rename the interface to Foo", "insert the line Blah.Blah()", etc.) The point is, I don't want to spend a lot of time writing these things, as they are usually throwaway. But sometimes I need something just a little smarter than what grep offers. It wouldn't be too hard to write up a simplistic version of this, but if I'm going to use something like this at all, I'd expect it to be robust. Any suggestions of a tool/library that will help me accomplish this? Edit to add some clarification Python is definitely not necessary; I'll take whatever is that. I merely suggest it incase there are choices. This is to be used in combination with IDE refactoring; sometimes it just doesn't do everything I want. In instances where I'm using for code generation (as above), it's for augmenting the output of other code generators. e.g. a library we use outputs a tonne of interfaces, and we need to make standard implementations of each one to mesh it to our codebase.
favorite count: 0
answer count: 3
has answer: http://stackoverflow.com/a/2702357
tagged with: python
has answer: http://stackoverflow.com/a/2702987
tagged with: parsing
type: AnsweredQuestion
upvote count: 3
tagged with: code-generation
type: Question

http://stackoverflow.com/a/2724119
answers question: http://stackoverflow.com/q/2724035
has body: Possible solution: You can extend this class, override callWebsite (you have to make it protected for this purpose) - and the override method write some stub method implementation.
type: Answer
score: 10
upvote count: 10
accepted answer of: http://stackoverflow.com/q/2724035
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/2825125
upvote count: 0
score: -1
has body: package newstract; import java.io.File; import java.util.Date; import com.drew.imaging.jpeg.JpegMetadataReader; import com.drew.metadata.Directory; import com.drew.metadata.Metadata; import com.drew.metadata.exif.ExifDirectory; import java.text.SimpleDateFormat; import com.drew.metadata.exif.GpsDirectory; public class GetTagInfo { public static void main(String[] args) { System.out.println("Picture Tagged Details"); try{ File jpegFile = new File("DSC_0060.JPG"); Metadata metadata = JpegMetadataReader.readMetadata(jpegFile); Directory exifDirectory = metadata.getDirectory(ExifDirectory.class); SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss"); Date myDate = exifDirectory.getDate(ExifDirectory.TAG_DATETIME); System.out.println(sdf.format(myDate)); SimpleDateFormat sdf1 = new SimpleDateFormat("MM/dd/yyyy"); Date myDate1 = exifDirectory.getDate(ExifDirectory.TAG_DATETIME); System.out.println(sdf1.format(myDate1)); SimpleDateFormat sdf2 = new SimpleDateFormat("hh:mm:ss"); Date myDate3 = exifDirectory.getDate(ExifDirectory.TAG_DATETIME); System.out.println(sdf2.format(myDate3)); Directory gpsDirectory = metadata.getDirectory(GpsDirectory.class); // Boolean b = (gpsDirectory.containsTag(GpsDirectory.TAG_GPS_LATITUDE)); // System.out.println(GpsDirectory.TAG_GPS_LATITUDE);+ String s = gpsDirectory.getDescription(2); System.out.println(s); SplitString1 w = new SplitString1(); w.doit(s); Iterator directories = metadata.getDirectoryIterator(); while (directories.hasNext()) { GpsDescriptor directory = (GpsDescriptor) directories.next(); System.out.print(directory.getGpsLatitudeDescription()); } } // close of catch catch (Exception e) { System.err.println(e.getMessage()); //System.err.println(tag.getDirectoryName() + " " + tag.getTagName() + " (error)"); } } } class SplitString1 { public void doit(String lat) { String str = lat; String [] temp = null; String dtemp = null; //temp = str.split("[\"]|\"[\']"); temp = str.split("[\"]|[\']" ); dtemp = str.replace("\""…
answers question: http://stackoverflow.com/q/2779405
type: Answer
downvote count: 1

http://stackoverflow.com/a/2616375
downvote count: 0
has comment: http://stackoverflow.com/comment/2628076
score: 4
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2616260
type: Answer
upvote count: 4
has body: Try mvn -am -pl "module-name" instead (replace -amd with -am). The -amd flag tries to build projects that depend upon "module-name" whereas -am builds projects that "module-name" depends upon. I feel that the documentation on those flags is a little counter-intuitive, but I'm pretty sure that this will fix your problem.
answers question: http://stackoverflow.com/q/2616260

http://stackoverflow.com/comment/2676802
type: Comment
comment on: http://stackoverflow.com/a/2657833
score: 1
type: AnswerComment
has text: But it takes effort to be stupid enough to tie that rope around your own neck.

http://stackoverflow.com/comment/2699847
type: Comment
score: 0
type: AnswerComment
has text: The question however still remains. Is it possible to use generics to accomplish this so I do not have to force a cast at run-time?
comment on: http://stackoverflow.com/a/2676201

http://stackoverflow.com/comment/2808661
has text: Here's referred as an statement: http://java.sun.com/docs/books/tutorial/java/package/usepkgs.html :(
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2774747
score: 0

http://stackoverflow.com/q/2667996
has title: handling multiple buttons in a form in struts
tagged with: struts
score: 0
answer count: 1
has body: I am facing an issue while handling multiple buttons in a form using struts. I have three buttons add,delete and go .I have made forward as hidden and on click of a button i would get the name of the button. The problem is with go button on click of that i want to call a javascript and then call the action and return to the same page . Question is i am facing issue whicl calling javascript on click of a button and returning to the same page.Please tell me a proper way to handle multiple buttons in a form and its action
has answer: http://stackoverflow.com/a/2668037
type: UnansweredQuestion
tagged with: java
type: Question

http://stackoverflow.com/q/2631644
tagged with: logging
has body: I have java webapp (written in spring mvc) and running on tomcat. I want to log user's behavior into a separate log file (separate from what we're logging right now to catalina.out). We're currently using Apache commons logging to obtain Log instances in our classes: protected final Log logger = LogFactory.getLog(getClass()); I prefer to keep use LogFactory to access my customized logger (hence not creating a dependency on a specific logging package). Yet, I need to create my own handler (so that I route usage events to a separate file. e.g. usage.out), also need a custom formatter to format the logs. I wonder what is the best way to achieve this? What is the common practice?
downvote count: 0
score: 1
tagged with: java
has title: Custom Logging in Tomcat (design pattern)
has answer: http://stackoverflow.com/a/2631905
type: Question
tagged with: tomcat
upvote count: 1
answer count: 1
has comment: http://stackoverflow.com/comment/2645603
has comment: http://stackoverflow.com/comment/2644994
favorite count: 0
type: UnansweredQuestion

http://stackoverflow.com/a/2638656
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2653275
has comment: http://stackoverflow.com/comment/2653182
upvote count: 3
has comment: http://stackoverflow.com/comment/2654072
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2638448
score: 3
has body: persistence.xml is loaded from the classpath; in the past, I've done exactly what you described. It's most likely an issue with maven. You can debug the maven classpath by running it with the -X option.
accepted answer of: http://stackoverflow.com/q/2638448

http://stackoverflow.com/comment/2760830
type: Comment
comment on: http://stackoverflow.com/a/2733011
type: AnswerComment
has text: -1, Firstly already gave the method to update individual cells, there is no need to repeat suggestions. Secondly, the addRow() method with not since TableModel does not support that method. You need to make sure you are using a model (like DefaultTableModel as I also suggested) that supports that method.
score: 0

http://stackoverflow.com/q/2742380
has body: I want to convert string Date into Timestamp in java. The following coding i have written.I have declare the date for date1 is: 7-11-11 12:13:14. SimpleDateFormat datetimeFormatter1 = new SimpleDateFormat( "yyyy-MM-dd hh:mm:ss"); Date lFromDate1 = datetimeFormatter1.parse(date1); System.out.println("gpsdate :" + lFromDate1); Timestamp fromTS1 = new Timestamp(lFromDate1.getTime()); I want to convert 7-11-11 12:13:14 this string date into timestamp. Now i got the output is 0007-11-11 00:13:14.000000 +05:30:00 but i want ( 7-11-11 12:13:14) this format Timestamp date. Can anyone please help me. Thank you.
tagged with: java
score: 40
downvote count: 1
has title: How to convert string date to Timestamp in java?
type: Question
has comment: http://stackoverflow.com/comment/34621645
linked to: http://stackoverflow.com/q/974973
answer count: 6
possible better answer: http://stackoverflow.com/a/33363603
has answer: http://stackoverflow.com/a/22716286
has answer: http://stackoverflow.com/a/33363603
has answer: http://stackoverflow.com/a/54582965
has answer: http://stackoverflow.com/a/2742398
favorite count: 0
has answer: http://stackoverflow.com/a/46609831
accepted answer: http://stackoverflow.com/a/2742398
upvote count: 41
has answer: http://stackoverflow.com/a/2742390
type: AnsweredQuestion

http://stackoverflow.com/q/2600360
score: 1
has answer: http://stackoverflow.com/a/2600486
favorite count: 0
type: UnansweredQuestion
tagged with: java
has body: For the following code, I am not able to set the column size to a custom size. Why is it so?Also the first column is not being displayed. import java.awt.BorderLayout; import java.awt.GridLayout; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTable; import javax.swing.table.TableColumn; public class Trial extends JFrame{ public void create(){ JPanel jp = new JPanel(); String[] string = {" ", "A"}; Object[][] data = {{"A", "0"},{"B", "3"},{"C","5"},{"D","-"}}; JTable table = new JTable(data, string); jp.setLayout(new GridLayout(2,0)); jp.add(table); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); TableColumn column = null; for (int i = 0; i &lt; 2; i++) { column = table.getColumnModel().getColumn(i); column.setPreferredWidth(20); //custom size } setLayout(new BorderLayout()); add(jp); } public static void main(String [] a){ Trial trial = new Trial(); trial.setSize(300,300); trial.setVisible(true); trial.setDefaultCloseOperation(Trial.EXIT_ON_CLOSE); trial.create(); } }
upvote count: 1
tagged with: swing
type: Question
has answer: http://stackoverflow.com/a/2600495
has title: How to change column width of a table
tagged with: jtable
answer count: 2
downvote count: 0

http://stackoverflow.com/a/2705026
score: 0
type: Answer
answers question: http://stackoverflow.com/q/2704965
has body: The usual way to set a bit in most languages is to 'or'(|) it with a bit mask with only that bit set, and the usual way to unset it is to 'and'(&amp;) it with a bit mask without that bit set. So make 8 set bit masks byte setbm1 = 1; //00000001 byte setbm2 = 1 &gt;&gt;1; byte setbm3 = 1&gt;&gt;2; ... ... byte setbm8 = 1&gt;&gt;7; //10000000 and 8 'and' bit masks byte unsetbm1 ^= setbm1; //11111110 .. .. byte unsetbm1 ^= setbm8; //01111111 To set the first bit use (assume array is a byte array and i is an integer) array[i] |= setbm1 to unset it array[i] ^= setbm1 Otherwise you can use http://java.sun.com/javase/6/docs/api/java/util/BitSet.html

http://stackoverflow.com/a/2754487
has body: you could use the HashSet class.
type: Answer
answers question: http://stackoverflow.com/q/2754339
upvote count: 1
score: 1
downvote count: 0

http://stackoverflow.com/comment/2715288
type: QuestionComment
comment on: http://stackoverflow.com/q/2692643
has text: It's not in the language spec but it appears to be part of at least some implementations. http://java.sun.com/docs/books/tutorial/java/package/managingfiles.html and
score: 0
type: Comment

http://stackoverflow.com/comment/2787020
type: Comment
has text: To clarify my above question: If I understand correctly you only get errors on the ones with joins ? All Finders work correctly in JBOSS ?
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/2691645

http://stackoverflow.com/comment/2678874
has text: The OP said specifically that he had 100 elements that he wanted to print, so in his case everything should work fine. Of course, to handle arbitrarily sized arrays, a different approach would have to be taken. I would print the newline when `(i!=0 && i%10==0)` and after the loop if `numbers.length != 0`.
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2661502

http://stackoverflow.com/q/2703608
favorite count: 0
has body: Is it possible to use a font not on the user's machine for text displayed in a java applet. Like linking to a ttf font file in the same location as the java applet almost in an @fontface fashion.
score: 2
upvote count: 2
tagged with: fonts
tagged with: truetype
has title: Using external fonts in a Java Applet
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2703642
tagged with: java
type: Question
answer count: 1
downvote count: 0
tagged with: applet
has answer: http://stackoverflow.com/a/2703642

http://stackoverflow.com/a/2779448
upvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/2814397
has body: I also noticed this. For me this issue was solved with changing layout manager (I've used Free Form Layout before) and it worked pretty well (system color painting). But eventually I switched back to FFL. Also some well known apps face this problem (f.e. SKYPE), but I actually don't mind it ...
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/2779035

http://stackoverflow.com/a/40587625
upvote count: 1
type: Answer
downvote count: 0
score: 1
has body: 1 - Clean your project by going to Project -> Clean. 2 - Make sure you check Project -> Build automatically. But before that, check the permissions on the src and target folders of your project, eclipse needs to read and write to those folders, then release the permissions for it. Your problem will be solved.
answers question: http://stackoverflow.com/q/2660961

http://stackoverflow.com/a/2602399
has body: Trove
type: Answer
answers question: http://stackoverflow.com/q/2602038
upvote count: 9
score: 9
downvote count: 0

http://stackoverflow.com/q/2778313
tagged with: deadlock
possible better answer: http://stackoverflow.com/a/22001169
has answer: http://stackoverflow.com/a/22001169
upvote count: 1
favorite count: 0
tagged with: synchronization
has body: I have a long-running process where, due to a bug, a trivial/expendable thread is deadlocked with a thread which I would like to continue, so that it can perform some final reporting that would be hard to reproduce in another way. Of course, fixing the bug for future runs is the proper ultimate resolution. Of course, any such forced interrupt/kill/stop of any thread is inherently unsafe and likely to cause other unpredictable inconsistencies. (I'm familiar with all the standard warnings and the reasons for them.) But still, since the only alternative is to kill the JVM process and go through a more lengthy procedure which would result in a less-complete final report, messy/deprecated/dangerous/risky/one-time techniques are exactly what I'd like to try. The JVM is Sun's 1.6.0_16 64-bit on Ubuntu, and the expendable thread is waiting-to-lock an object monitor. Can an OS signal directed to an exact thread create an InterruptedException in the expendable thread? Could attaching with gdb, and directly tampering with JVM data or calling JVM procedures allow a forced-release of the object monitor held by the expendable thread? Would a Thread.interrupt() from another thread generate a InterruptedException from the waiting-to-lock frame? (With some effort, I can inject an arbitrary beanshell script into the running system.) Can the deprecated Thread.stop() be sent via JMX or any other remote-injection method? Any ideas appreciated, the more 'dangerous', the better! And, if your suggestion has worked in personal experience in a similar situation, the best!
has title: Any way to interrupt, kill, or otherwise unwind (releasing synchronization locks) a single deadlocked Java thread allowing other threads to continue?
tagged with: interrupted-exception
downvote count: 0
type: AnsweredQuestion
score: 1
tagged with: java
accepted answer: http://stackoverflow.com/a/2778374
type: Question
answer count: 2
tagged with: gdb
has answer: http://stackoverflow.com/a/2778374

http://stackoverflow.com/comment/47780969
score: 0
comment on: http://stackoverflow.com/q/2685345
type: Comment
type: QuestionComment
has text: `R._1st` couldn't work? If you're talking about Android development, I think the `R` class is always there...

http://stackoverflow.com/a/2633161
downvote count: 0
has body: Here's my attempt at a branch-free version: long saturatedAdd(long x, long y) { // Sum ignoring overflow/underflow long s = x + y; // Long.MIN_VALUE if result positive (potential underflow) // Long.MAX_VALUE if result negative (potential overflow) long limit = Long.MIN_VALUE ^ (s &gt;&gt; 63); // -1 if overflow/underflow occurred, 0 otherwise long overflow = ((x ^ s) &amp; ~(x ^ y)) &gt;&gt; 63; // limit if overflowed/underflowed, else s return ((limit ^ s) &amp; overflow) ^ s; }
type: Answer
score: 5
upvote count: 5
answers question: http://stackoverflow.com/q/2632392

http://stackoverflow.com/a/2610054
type: Answer
accepted answer of: http://stackoverflow.com/q/2609998
upvote count: 3
answers question: http://stackoverflow.com/q/2609998
has body: You are seeing the whitespace text surrounding the childnode "lots" <?xml version="1.0" encoding="UTF-8" standalone="no"?> {txt1} 32342 52644 {txt2}
score: 3
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2620565

http://stackoverflow.com/a/2784657
downvote count: 0
answers question: http://stackoverflow.com/q/2784514
type: Answer
has comment: http://stackoverflow.com/comment/2819955
has body: Yes, that's possible for instance in this answer I sort by the property v of the class IndexValue // Sorting by property v using a custom comparator. Arrays.sort( array, new Comparator&lt;IndexValue&gt;(){ public int compare( IndexValue a, IndexValue b ){ return a.v - b.v; } }); If you notice here I'm creating a anonymous inner class ( which is the Java for closures ) and passing it directly to the sort method of the class Arrays Your object may also implement Comparable ( that's what String and most of the core libraries in Java does ) but that would define the "natural sort order" of the class it self, and doesn't let you plug new ones.
upvote count: 5
score: 5

http://stackoverflow.com/a/2721151
downvote count: 0
answers question: http://stackoverflow.com/q/2719667
type: Answer
has body: Hazelcast is super simple, open source clustering solution for java. Here is the quote from documentation. Hazelcast IdGenerator creates cluster-wide unique IDs. Generated IDs are long type primitive values between 0 and Long.MAX_VALUE . Id generation occurs almost at the speed of AtomicLong.incrementAndGet() . Generated IDs are unique during the life cycle of the cluster. If the entire cluster is restarted, IDs start from 0 again. import com.hazelcast.core.IdGenerator; import com.hazelcast.core.Hazelcast; IdGenerator idGenerator = Hazelcast.getIdGenerator("customer-ids"); long id = idGenerator.newId(); http://www.hazelcast.com/documentation.jsp#IdGenerator
upvote count: 2
score: 2

http://stackoverflow.com/comment/2715607
has text: @Jef — You are trying to produce a key store for the server, right? The server always needs a private key. Anyone can get the certificate; it's public. But without the private key, they couldn't impersonate the server. Following the steps above, the private key ("key.pem") that goes together with "cert.pem" is never imported to the Java key store. If you use Java 6, you can "import" a PKCS #12 key store (including private keys) created by OpenSSL into a "JKS" Java key store. Otherwise, it won't work.
score: 1
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2685931

http://stackoverflow.com/a/2685761
has comment: http://stackoverflow.com/comment/2706301
type: AcceptedAnswer
downvote count: 0
has body: Please take a look at this cheatsheet and this cheatsheet
upvote count: 2
type: Answer
accepted answer of: http://stackoverflow.com/q/2685399
score: 2
answers question: http://stackoverflow.com/q/2685399

http://stackoverflow.com/comment/2716334
has text: I've added `System.out.println(nodes.comparator())` and it returns `null`. So this means it's using natural ordering, which in this case means using `Node.compareTo()` correct? I've added my `compareTo()` method above.
comment on: http://stackoverflow.com/a/2694584
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/comment/2795387
comment on: http://stackoverflow.com/q/2763117
type: Comment
score: 5
has text: What do you want to do with these values?
type: QuestionComment

http://stackoverflow.com/comment/2784673
type: AnswerComment
has text: Was about to comment the previous answer to say that you need an association in HQL for out join. But the update is correct, this new query works.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2752079

http://stackoverflow.com/a/2633898
type: Answer
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/2633873
has body: Yes it will, because List.contains() use the equals() method of the object to be compared. And Integer.equals() does compare the integer value.
downvote count: 0

http://stackoverflow.com/q/2753795
has comment: http://stackoverflow.com/comment/2784787
has comment: http://stackoverflow.com/comment/45836643
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/2754098
accepted answer: http://stackoverflow.com/a/2754098
favorite count: 0
score: 8
has answer: http://stackoverflow.com/a/2753940
upvote count: 8
has title: Generating Ant build file for a project in eclipse
has body: I have a project written in Java using eclipse and I would like to generate an Ant build file for it. How can it be done? I constantly need to keep it synchronized with the source code, so that I could promote it along with the code to the common repository when with the project structure is modified. I'm sorry for a stupid question like this. I've browsed across the forums, but still no luck. Thanks in advance.
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/2784719
type: Question
possible better answer: http://stackoverflow.com/a/2753940
tagged with: ant
tagged with: eclipse

http://stackoverflow.com/a/2651587
has body: (see above explanations for more general GC.. this answers WHY new is cheaper to GC than old). The reason eden can be cleared faster is simple: the algorithm is proportional to the number of objects that will survive GC in the eden space, not proportional to the number of live objects in the whole heap. ie: if you have an average object death rate of 99% in eden (ie: 99% of objects do not survive GC, which is not abnormal), you only need to look at and copy that 1%. For "old" GC, all live objects in the full heap need to be marked/swept. That is significantly more expensive.
upvote count: 12
score: 12
downvote count: 0
answers question: http://stackoverflow.com/q/2620533
type: Answer
has comment: http://stackoverflow.com/comment/56911390

http://stackoverflow.com/a/2643013
answers question: http://stackoverflow.com/q/2642651
has comment: http://stackoverflow.com/comment/2667953
type: Answer
has body: If you make a copy of your object hello then you don't have to worry about changing back to the original object. Hello h = new Hello(); Hello copyH = h;
score: 0

http://stackoverflow.com/comment/2702223
has text: You may need to fully qualify references to the third-party listener if you also have a local Listener class/interface which is not a placeholder.
type: Comment
comment on: http://stackoverflow.com/a/2682535
type: AnswerComment
score: 0

http://stackoverflow.com/comment/95907914
type: Comment
has text: Call requires API level 24
type: AnswerComment
comment on: http://stackoverflow.com/a/34279142
score: 1

http://stackoverflow.com/a/44287442
score: 3
upvote count: 3
downvote count: 0
answers question: http://stackoverflow.com/q/2784514
has body: New since 1.8 is a List.sort() method instead of using the Collection.sort() so you directly call mylistcontainer.sort() Here is a code snippet which demonstrates the List.sort() feature: List&lt;Fruit&gt; fruits = new ArrayList&lt;Fruit&gt;(); fruits.add(new Fruit("Kiwi","green",40)); fruits.add(new Fruit("Banana","yellow",100)); fruits.add(new Fruit("Apple","mixed green,red",120)); fruits.add(new Fruit("Cherry","red",10)); // a) using an existing compareto() method fruits.sort((Fruit f1,Fruit f2) -&gt; f1.getFruitName().compareTo(f2.getFruitName())); System.out.println("Using String.compareTo(): " + fruits); //Using String.compareTo(): [Apple is: mixed green,red, Banana is: yellow, Cherry is: red, Kiwi is: green] // b) Using a comparable class fruits.sort((Fruit f1,Fruit f2) -&gt; f1.compareTo(f2)); System.out.println("Using a Comparable Fruit class (sort by color): " + fruits); // Using a Comparable Fruit class (sort by color): [Kiwi is green, Apple is: mixed green,red, Cherry is: red, Banana is: yellow] The Fruit class is: public class Fruit implements Comparable&lt;Fruit&gt; { private String name; private String color; private int quantity; public Fruit(String name,String color,int quantity) { this.name = name; this.color = color; this.quantity = quantity; } public String getFruitName() { return name; } public String getColor() { return color; } public int getQuantity() { return quantity; } @Override public final int compareTo(Fruit f) // sorting the color { return this.color.compareTo(f.color); } @Override public String toString() { return (name + " is: " + color); } } // end of Fruit class
type: Answer

http://stackoverflow.com/a/2786929
has body: You could use the Spring Resource interface (and especially the ServletContextResource): http://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/core/io/Resource.html
type: Answer
answers question: http://stackoverflow.com/q/2786426
score: 0

http://stackoverflow.com/comment/2801924
type: Comment
has text: @mgroves: yes, but this allows different battle scenarios: in different situations, different results might be wanted.
comment on: http://stackoverflow.com/a/2768865
score: 1
type: AnswerComment

http://stackoverflow.com/comment/2796761
type: Comment
has text: @polygenelubricants: the problem is not the backslashes he introduced. They end up just quoting the / following them, so shouldn't mess with the results (although they are of course superfluous).
type: AnswerComment
comment on: http://stackoverflow.com/a/2763804
score: 0

atomic
type: Tag
tags question: http://stackoverflow.com/q/2771214
tag name: atomic

http://stackoverflow.com/q/2719545
score: 0
has answer: http://stackoverflow.com/a/2809370
tagged with: tibco-rv
has body: I'm looking to contrast Tibco rv and Hessian in terms of performance - for a Java application. Any pointer to get me started appreciated. thanks.
has comment: http://stackoverflow.com/comment/2837222
type: AnsweredQuestion
tagged with: java
type: Question
answer count: 2
possible better answer: http://stackoverflow.com/a/2808076
tagged with: network-programming
accepted answer: http://stackoverflow.com/a/2809370
has answer: http://stackoverflow.com/a/2808076
has title: Hessian vs Tibco rv

http://stackoverflow.com/a/2607838
type: Answer
score: 0
accepted answer of: http://stackoverflow.com/q/2600523
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2600523
has body: I found the solution. It was a classpath problem. I needed the following jars on my classpath: weblogic.jar weblogic-container-binding.jar xbean.jar stax-api-1.0.1.jar webservices.jar ant.jar

http://stackoverflow.com/a/2708598
has body: You can use Key.getEncoded() to get the bytes of the key.
type: Answer
score: 0
answers question: http://stackoverflow.com/q/2708586

http://stackoverflow.com/q/2744806
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2744912
tagged with: oop
tagged with: refactoring
tagged with: java
has answer: http://stackoverflow.com/a/2744934
possible better answer: http://stackoverflow.com/a/2744904
type: Question
upvote count: 4
has answer: http://stackoverflow.com/a/2744904
downvote count: 0
answer count: 6
score: 4
has answer: http://stackoverflow.com/a/2744929
has answer: http://stackoverflow.com/a/2744935
has title: How to set default values to all wrong or null parameters of method?
has answer: http://stackoverflow.com/a/2744916
favorite count: 0
has body: At the moment I have this code (and I don't like it): private RenderedImage getChartImage (GanttChartModel model, String title, Integer width, Integer height, String xAxisLabel, String yAxisLabel, Boolean showLegend) { if (title == null) { title = ""; } if (xAxisLabel == null) { xAxisLabel = ""; } if (yAxisLabel == null) { yAxisLabel = ""; } if (showLegend == null) { showLegend = true; } if (width == null) { width = DEFAULT_WIDTH; } if (height == null) { height = DEFAULT_HEIGHT; } ... } How can I improve it? I have some thoughts about introducing an object which will contain all these parameters as fields and then, maybe, it'll be possible to apply builder pattern. But still don't have clear vision how to implement that and I'm not sure that it's worth to be done. Any other ideas?
accepted answer: http://stackoverflow.com/a/2744929

http://stackoverflow.com/comment/2819840
score: 0
type: AnswerComment
has text: @Jeyjey: What are you trying to do? Add your components to other panels, not the one you are painting on.
type: Comment
comment on: http://stackoverflow.com/a/2784098

geotools
type: Tag
tags question: http://stackoverflow.com/q/2642700
tag name: geotools

http://stackoverflow.com/comment/2647195
type: Comment
comment on: http://stackoverflow.com/q/2626981
type: QuestionComment
score: 1
has text: What do you have in those folders? .class files or .jar files? In order for Java to consider .jar files your codebases should end with /* or /- (for reference, see: http://mindprod.com/jgloss/policyfile.html)

http://stackoverflow.com/comment/2807626
has text: @Troubadour. Polymorphism is needed for the concrete strategy to work.
type: AnswerComment
comment on: http://stackoverflow.com/a/2769035
score: 0
type: Comment

http://stackoverflow.com/a/2606815
type: Answer
has body: If you really need an array of generic types, you can do this: Entry&lt;String, Integer&gt;[] array = new Entry[10]; It gives you a compilation warning though. You can read more about it here: http://www.devarticles.com/c/a/Java/Wildcards-Arrays-and-Generics-in-Java/2/
has comment: http://stackoverflow.com/comment/2616979
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/2616872
has comment: http://stackoverflow.com/comment/2617004
type: AcceptedAnswer
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2606766
answers question: http://stackoverflow.com/q/2606766

http://stackoverflow.com/comment/2623365
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2612213
type: AnswerComment
has text: In short, You really have to test whether adding threads improves performance, don't assume adding complexity makes a better solution because very often, it doesn't.

http://stackoverflow.com/comment/2696444
type: QuestionComment
has text: You should start by making a very very simple version of your program with absolutely minimal logic, but the function calls to the library. Does the library claim to be completely thread safe? There might be API calls that are not. Also, letting us know what library would help if it is the lib, since we may have had the same issue.
score: 2
comment on: http://stackoverflow.com/q/2677335
type: Comment

http://stackoverflow.com/comment/2699544
comment on: http://stackoverflow.com/q/2679759
score: 0
has text: How is the usage of GWT relevant ? Did I understand the question in my answer below ? If not can we steer each other in the right direction ?
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/2736306
comment on: http://stackoverflow.com/q/2702203
score: 0
has text: aioobe: It prints ASDF. However, if I press and hold A, S then W, it doesn't recognize the W.
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2653289
has answer: http://stackoverflow.com/a/2653529
has answer: http://stackoverflow.com/a/2653424
has answer: http://stackoverflow.com/a/2655350
downvote count: 0
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/2653344
type: Question
has title: Java library suggestions for implementing a custom web server
has body: I would like to create a web server that will serve/accept json files through REST. The JSON files being served will come from a database query and format the results into JSON. Any suggestions for a good java library. I have tried using Apache HTTPComponents. While maybe I can just create a servlet but I am not really allowed to install a servlet container in the server machine. EDIT: I was just thinking to create the program where I can just simply issue a simple java -jar Application.jar and everything is already started and functional. The application will listen on a certain port of the machine and respond to some requests from browser and/or another java program. Looks like Jetty will help me do it. As I have said, I have implemented something using HTTPComponents and I'm just simply parsing the URL from the requests and do something in the server based on the parsed URL.
tagged with: webserver
answer count: 6
has answer: http://stackoverflow.com/a/2655365
upvote count: 1
has answer: http://stackoverflow.com/a/2653315
has comment: http://stackoverflow.com/comment/2669539
favorite count: 0
type: UnansweredQuestion
tagged with: web-services

http://stackoverflow.com/a/35293165
upvote count: 2
score: 1
downvote count: 1
has body: Here is a simple example. this method will return a 2 dimensional tType array public tType[][] allocate(Class&lt;tType&gt; c,int row,int column){ tType [][] matrix = (tType[][]) Array.newInstance(c,row); for (int i = 0; i &lt; column; i++) { matrix[i] = (tType[]) Array.newInstance(c,column); } return matrix; } say you want a 2 dimensional String array, then call this function as String [][] stringArray = allocate(String.class,3,3); This will give you a two dimensional String array with 3 rows and 3 columns; Note that in Class&lt;tType&gt; c -> c cannot be primitive type like say, int or char or double. It must be non-primitive like, String or Double or Integer and so on.
has comment: http://stackoverflow.com/comment/73327622
answers question: http://stackoverflow.com/q/2707357
type: Answer

http://stackoverflow.com/comment/63863914
comment on: http://stackoverflow.com/a/25594467
type: Comment
score: 0
type: AnswerComment
has text: Just hit this exception. I am afraid Marco13's answer should be the correct answer. I may need to go though whole year code to fix all "asList" exception.

http://stackoverflow.com/comment/2624740
type: QuestionComment
comment on: http://stackoverflow.com/q/2613596
score: 1
has text: My guess is that the design is flawed anyway because, due to the operation in the constructor, you'll probably have a hard time testing with this class. see http://www.youtube.com/watch?v=RlfLCWKxHJ0 for a good explanation.
type: Comment

http://stackoverflow.com/q/2619016
upvote count: 2
has answer: http://stackoverflow.com/a/2621717
tagged with: swt
score: 2
type: AnsweredQuestion
tagged with: java
type: Question
answer count: 2
possible better answer: http://stackoverflow.com/a/2621717
downvote count: 0
has answer: http://stackoverflow.com/a/2625258
accepted answer: http://stackoverflow.com/a/2625258
tagged with: user-interface
has body: I am making a component in SWT that contains a text field and a list. Whenever text is entered it filters the list. So far everything is working great and I am just trying to add some nice usability features. What I want to do is listen for any key events in the List field, if it is Enter that is pressed I perform the 'ok' action (already done) but otherwise I want focus to change to the text field and have the key event triggered there. Basically, if the focus is on the List field and the user types something I want it to be automatically typed into the text field. Responding to the keyPressed or keyReleased event is fine for setting the focus to the text field, but I need to then repeat the keyEvent somehow so that whatever was typed is actually entered. Any ideas?
tagged with: events
has title: Java SWT: apply key events from List to Text field
favorite count: 0
tagged with: listener

remote-debugging
tag name: remote-debugging
type: Tag
tags question: http://stackoverflow.com/q/2673554

http://stackoverflow.com/a/2611552
upvote count: 3
type: Answer
has body: (a) Don't use PrintStream or PrintWriter over the network, as they suppress exceptions. They are really only for log files, or the console, where you don't care all that much. Over a network you are engaging in a protocol and you need to know about failures straight away. (b) Socket.isClosed() returns true if you've closed either its input or its output. NB it doesn't tell you whether the other guy has closed the connection - that's not its function. Only reading an EOS can tell you that.
score: 3
downvote count: 0
answers question: http://stackoverflow.com/q/2607515

http://stackoverflow.com/a/22359786
has comment: http://stackoverflow.com/comment/66634750
has body: Since technologies appear everyday, the answer will change in the time. I took a look at LambdaJ and seems very interesting. You can try solving these tasks with LambdaJ. You can find it here: http://code.google.com/p/lambdaj/ Here you have an example: Sort Iterative List&lt;Person&gt; sortedByAgePersons = new ArrayList&lt;Person&gt;(persons); Collections.sort(sortedByAgePersons, new Comparator&lt;Person&gt;() { public int compare(Person p1, Person p2) { return Integer.valueOf(p1.getAge()).compareTo(p2.getAge()); } }); Sort with lambda List&lt;Person&gt; sortedByAgePersons = sort(persons, on(Person.class).getAge()); Of course, having this kind of beauty impacts in the performance (an average of 2 times), but can you find a more readable code?
has comment: http://stackoverflow.com/comment/66638106
score: 15
type: Answer
upvote count: 15
answers question: http://stackoverflow.com/q/2784514
downvote count: 0
has comment: http://stackoverflow.com/comment/66651657

http://stackoverflow.com/a/2745351
score: 130
type: AcceptedAnswer
has body: Something like the standard Collection.toArray(T[]) should do what you need (note that ArrayList implements Collection): TypeA[] array = a.toArray(new TypeA[a.size()]); On a side note, you should consider defining a to be of type List&lt;TypeA&gt; rather than ArrayList&lt;TypeA&gt;, this avoid some implementation specific definition that may not really be applicable for your application. Also, please see this question about the use of a.size() instead of 0 as the size of the array passed to a.toArray(TypeA[])
upvote count: 131
answers question: http://stackoverflow.com/q/2745338
type: Answer
accepted answer of: http://stackoverflow.com/q/2745338
downvote count: 1

http://stackoverflow.com/comment/2788212
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2756672
has text: Like I've said in the above comment, this does not answer the question.

customvalidator
tag name: customvalidator
tags question: http://stackoverflow.com/q/2690206
type: Tag

http://stackoverflow.com/comment/57664198
score: 2
type: AnswerComment
has text: Doesn't work with SQL Server either.
comment on: http://stackoverflow.com/a/2683299
type: Comment

http://stackoverflow.com/q/2738677
type: Question
tagged with: ejb
has comment: http://stackoverflow.com/comment/2767268
downvote count: 0
score: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/2767303
has body: I have an EJB deployed under JBoss (we're moving a project to it from Weblogic), I can get an EJBHome reference to the EJB via a JNDI lookup. The login-config.xml application-policy contains several login modules (I don't know if these are ANDs or ORs?) - org.jboss.security.spi.BaseCertLoginModule, LdapLoginModule, RoleMappingLoginModule and ClientLoginModule. When my client code tries to invoke the create method via reflection, calling invoke, I get an InvocationException which wraps an AccessException, which wraps a final exception of javax.security.auth.login.FailedLoginException: Password Incorrect/Password Required at org.jboss.security.auth.spi.UsernamePasswordLoginModule.login(UsernamePasswordLoginModule.java:213).... Am I missing some client code to use BaseCertLoginModule, or one of the others in the login-config.xml, instead of UsernamePasswordLoginModule? Thanks in advance, any suggestions appreciated, apologies for not posting the entire stacktrace but it's on a secured network without internet access.
answer count: 0
type: UnansweredQuestion
upvote count: 1
has title: How do I fix this JBoss EJB client authentication issue?
has comment: http://stackoverflow.com/comment/2772841
tagged with: java
tagged with: jboss

http://stackoverflow.com/comment/2645176
has text: It seems this question is asked a lot here... I would consider closing it but after having read the others a little more this question does ask something different: is using a class loader + saving the exception in the runnable object viable?
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/2631791
score: 0

http://stackoverflow.com/comment/48378701
comment on: http://stackoverflow.com/a/2639159
type: AnswerComment
has text: @RomainGuy I'm still have the same problem although it only calls twice now rather than 5/6. I'm creating a `Listview` dynamically like this: `RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); listview.setLayoutParams(rlp); listview.setAdapter(customerAdpt);` What am I doing wrong? Thanks.
score: 0
type: Comment

http://stackoverflow.com/comment/2716345
type: Comment
type: AnswerComment
has text: @David: The updated code should still not compile. It should give the error `a is already defined`. That line should be removed.
comment on: http://stackoverflow.com/a/2694490
score: 0

http://stackoverflow.com/a/2604798
has comment: http://stackoverflow.com/comment/64631286
type: Answer
has comment: http://stackoverflow.com/comment/108092919
downvote count: 2
has comment: http://stackoverflow.com/comment/16424925
has comment: http://stackoverflow.com/comment/108092906
answers question: http://stackoverflow.com/q/2604169
has body: So you've probably read a bajillion different explanations of the visitor pattern, and you're probably still saying "but when would you use it!" Traditionally, visitors are used to implement type-testing without sacrificing type-safety, so long as your types are well-defined up front and known in advance. Let's say we have a few classes as follows: abstract class Fruit { } class Orange : Fruit { } class Apple : Fruit { } class Banana : Fruit { } And let's say we create a Fruit[]: var fruits = new Fruit[] { new Orange(), new Apple(), new Banana(), new Banana(), new Banana(), new Orange() }; I want to partition the list in to three lists, each containing oranges, apples, or bananas. How would you do it? Well, the easy solution would be a type-test: List&lt;Orange&gt; oranges = new List&lt;Orange&gt;(); List&lt;Apple&gt; apples = new List&lt;Apple&gt;(); List&lt;Banana&gt; bananas = new List&lt;Banana&gt;(); foreach (Fruit fruit in fruits) { if (fruit is Orange) oranges.Add((Orange)fruit); else if (fruit is Apple) apples.Add((Apple)fruit); else if (fruit is Banana) bananas.Add((Banana)fruit); } It works, but there are lots of problems with this code: For a start, its ugly. Its not type-safe, we won't catch type errors until runtime. Its not maintainable. If we add a new derived instance of Fruit, we need to do a global search for every place which performs a fruit type-test, otherwise we might miss types. Visitor pattern solves the problem elegantly. Start by modifying our base Fruit class: interface IFruitVisitor { void Visit(Orange fruit); void Visit(Apple fruit); void Visit(Banana fruit); } abstract class Fruit { public abstract void Accept(IFruitVisitor visitor); } class Orange : Fruit { public override void Accept(IFruitVisitor visitor) { visitor.Visit(this); } } class Apple : Fruit { public override void Accept(IFruitVisitor visitor) { visitor.Visit(this); } } class Banana : Fruit { public override void Accept(IFruitVisitor visitor) { visitor.Visit(this); } } It …
upvote count: 221
score: 219

http://stackoverflow.com/a/2687020
upvote count: 13
has comment: http://stackoverflow.com/comment/2708331
answers question: http://stackoverflow.com/q/2687012
has body: It will be difficult to get a regular expression to work in all cases, but to fix your immediate problem you can use a lookbehind: String sResult = "This is a test. This is a T.L.A. test."; String[] sSentence = sResult.split("(?&lt;=[a-z])\\.\\s+"); Result: This is a test This is a T.L.A. test. Note that there are abbrevations that do not end with capital letters, such as abbrev., Mr., etc... And there are also sentences that don't end in periods!
type: Answer
score: 13
downvote count: 0

http://stackoverflow.com/a/2610706
has comment: http://stackoverflow.com/comment/2621311
has comment: http://stackoverflow.com/comment/2621496
downvote count: 0
has comment: http://stackoverflow.com/comment/2621289
score: 8
has comment: http://stackoverflow.com/comment/2621253
upvote count: 8
answers question: http://stackoverflow.com/q/2610679
type: Answer
has comment: http://stackoverflow.com/comment/2621236
has comment: http://stackoverflow.com/comment/2621276
has body: Others have pointed out the bug, but your code is scary in other ways that will eventually trip you up: if (!(s&gt;=0 &amp;&amp; s&lt;=2)) System.out.println ("try again not a valid response") ; else r = true ; That's bad because you can easily intend more than one statement to run in the case of the if or else clause. Use curly braces and avoid placing conditional statements on a single line: if (!(s&gt;=0 &amp;&amp; s&lt;=2)) { System.out.println ("try again not a valid response"); } else { r = true; } It's easier to read and far less likely to introduce hard-to-see bugs.
has comment: http://stackoverflow.com/comment/2621489

http://stackoverflow.com/comment/16395413
has text: good one. thanks! If I may, why don't you use the machanism of the handlers, such as AuthenticationFailureHandler? I mean, why using the listener instead of the handler? any pros/cons?
type: Comment
score: 2
comment on: http://stackoverflow.com/a/2686268
type: AnswerComment

http://stackoverflow.com/comment/19997527
has text: Agree. If this was an actual interview question or homework assignment given to me, I'd put a marker into the Node class and do a trivial implementation of hasLoop(). Only if I'm explicitly not allowed to change the node implementation I'd bother with the more advanced cycle-finding algorithms.
comment on: http://stackoverflow.com/q/2663115
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2612325
type: Question
score: 0
accepted answer: http://stackoverflow.com/a/2612392
answer count: 2
possible better answer: http://stackoverflow.com/a/2612618
has answer: http://stackoverflow.com/a/2612618
tagged with: java
has title: AccessControlException: access denied - caller function failed to load properties file
has body: I am having a jar archive environment which is gonna call my class in a folder like this: java -jar "emarket.jar" ../tournament 100 My compiled class is deployed into the ../tournament folder, this command runs well. After I changed my code to load a properties file, it gets the following exception message: Exception in thread "main" java.security.AccessControlException: access denied (java.io.FilePermission agent.properties read) at java.security.AccessControlContext.checkPermission(Unknown Source) at java.security.AccessController.checkPermission(Unknown Source) at java.lang.SecurityManager.checkPermission(Unknown Source) at java.lang.SecurityManager.checkRead(Unknown Source) at java.io.FileInputStream.&lt;init&gt;(Unknown Source) at java.io.FileInputStream.&lt;init&gt;(Unknown Source) at Agent10479475.getPropertiesFromConfigFile(Agent10479475.java:110) at Agent10479475.&lt;init&gt;(Agent10479475.java:100) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at java.lang.Class.newInstance0(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at emarket.client.EmarketSandbox.instantiateClientObjects(EmarketSandbox.java:92) at emarket.client.EmarketSandbox.&lt;init&gt;(EmarketSandbox.java:27) at emarket.client.EmarketSandbox.main(EmarketSandbox.java:166) I am wondering why this security checking will fail. I issue the getPropertitiesFromConfigFile() function inside my class's default constructor, like this: public class Agent10479475 extends AbstractClientAgent { //default constructor public Agent10479475() { //set all properties to their default values in constructor FT_THRESHOLD = 400; FT_THRESHOLD_MARGIN = 50; printOut("Now loading properties from a config file...", ""); getPropertiesFromConfigFile(); printOut("Finished loadin…
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2612392

http://stackoverflow.com/comment/31984457
comment on: http://stackoverflow.com/a/2761019
score: 0
type: Comment
type: AnswerComment
has text: Actual implementation should be "new ArrayList<Integer>(Arrays.asList(new Object[]{1,2,3,5,8,13,21}));"

http://stackoverflow.com/comment/3988786
type: Comment
score: 0
type: AnswerComment
has text: @Tom: They should always be in some tree, in one of the currently visible top-level containers. If not, they are not being displayed.
comment on: http://stackoverflow.com/a/2656085

http://stackoverflow.com/a/43936962
has body: Here's another way: MaskFormatter fmt = new MaskFormatter("*-****"); fmt.setValueContainsLiteralCharacters(false); System.out.println(fmt.valueToString("12345"));
has comment: http://stackoverflow.com/comment/133294704
answers question: http://stackoverflow.com/q/2637021
type: Answer
upvote count: 0
downvote count: 1
score: -1

http://stackoverflow.com/q/2631368
score: 1
tagged with: java
has body: I am trying to display a JPEG image and a moving dot on a Java applet which I am using on a web based application. However, when I run the applet it works fine, but when I display the applet from the JSP page, I get the moving dot but not the JPEG image. Is there a specific folder where the JPEG needs to be? These are the 2 methods i use for drawing the picture and the moving dot on the screen. public class mapplet extends Applet implements Runnable { int x_pos = 10; int y_pos = 100; int radius = 20; Image img, img2; Graphics gr; URL base; MediaTracker m; @Override public void init() { mt = new MediaTracker(this); try { //getDocumentbase gets the applet path. base = getCodeBase(); img = getImage(base, "picture.jpg"); m.addImage(img, 1); m.waitForAll(); } catch (InterruptedException ex) { Logger.getLogger(movement.class.getName()).log(Level.SEVERE, null, ex); } public void paint (Graphics g) { g.drawImage(img, 0, 0, this); // set color g.setColor (Color.red); // paint a filled colored circle g.fillOval (x_pos - radius, y_pos - radius, 2 * radius, 2 * radius); } The code one below is the call from the jsp page &lt;applet archive="mapplet.jar" code="myapplets/mapplet.class" width=350 height=200&gt; &lt;/applet&gt; The jar file and the picture are in the same folder as the jsp page, and there is also a folder containing the contents of the class and image of the applet in the web section of the application. The applet loads fine however the picture doesn't display. I think it's not the code but the location of the picture that is causing a problem. Thanks
tagged with: image
upvote count: 2
answer count: 3
downvote count: 1
tagged with: jsp
tagged with: applet
favorite count: 0
has title: Images in Applet not showing in web page
has comment: http://stackoverflow.com/comment/6650488
has answer: http://stackoverflow.com/a/14069552
has answer: http://stackoverflow.com/a/2634844
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/5799337
has comment: http://stackoverflow.com/comment/2644682
type: Question
has comment: http://stackoverflow.com/comment/2644676

http://stackoverflow.com/a/2615753
downvote count: 0
score: 20
upvote count: 20
has body: text.indexOf(match); See the String javadoc
answers question: http://stackoverflow.com/q/2615749
type: Answer

http://stackoverflow.com/q/2678198
answer count: 3
has comment: http://stackoverflow.com/comment/2697998
score: 8
has comment: http://stackoverflow.com/comment/2697769
has comment: http://stackoverflow.com/comment/2697531
tagged with: intellij-idea
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2678289
downvote count: 0
has answer: http://stackoverflow.com/a/2678489
possible better answer: http://stackoverflow.com/a/2678262
tagged with: maven-2
favorite count: 0
has answer: http://stackoverflow.com/a/2678262
upvote count: 8
type: Question
has comment: http://stackoverflow.com/comment/2697496
has title: How to avoid wasting time during compilation during development?
has body: I'm working with a small team of developers. My job is to convert a Make project (with Intellij Idea 9.0) into a Maven 2 project. The problem is : we spend a lot of time during the development. With Make, only one complete build was required and then any change did not consume a lot of time (almost instantaneously). On the other hand, with Maven 2, a little change takes a lot of time to run. Any solution ? Thanks.
accepted answer: http://stackoverflow.com/a/2678289
tagged with: java

http://stackoverflow.com/comment/2733533
has text: Just edited the constructor. Furthermore: I actually like just to copy the reference of the objects - it's the goal ;)
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2709277

http://stackoverflow.com/a/3608278
downvote count: 0
type: Answer
score: 2
upvote count: 2
has body: If you want to change the Path variable on windows, you should take a look at JNI_Registry: http://www.trustice.com/java/jnireg/ It's a Java binding to the Windows Registry API and comes with a very small footprint. I have used it for my current project and it works just fine.
answers question: http://stackoverflow.com/q/2741175

http://stackoverflow.com/a/2849915
answers question: http://stackoverflow.com/q/2654653
has body: Osmek would be good solution as well. All you would have to do is write a java integration class.
score: 0
type: Answer

http://stackoverflow.com/q/2689811
has body: how can i set openjpa to flush before query. When i change some values in database i want to propagate these changes into application. I tried this settings in persistence.xml: &lt;property name="openjpa.FlushBeforeQueries" value="true" /&gt; &lt;property name="openjpa.IgnoreChanges" value="false"/&gt; false/true - same behavior to my case &lt;property name="openjpa.DataCache" value="false"/&gt; &lt;property name="openjpa.RemoteCommitProvider" value="sjvm"/&gt; &lt;property name="openjpa.ConnectionRetainMode" value="always"/&gt; &lt;property name="openjpa.QueryCache" value="false"/&gt; Any idea? Thanks
type: Question
upvote count: 2
downvote count: 0
answer count: 1
tagged with: persistence
accepted answer: http://stackoverflow.com/a/2776823
favorite count: 0
has answer: http://stackoverflow.com/a/2776823
tagged with: openjpa
has title: OpenJPA - not flushing before queries
score: 2
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/a/2642844
has body: DB2 does indeed support a rownum concept. Not knowing your database schema, this is an example: SELECT * FROM ( SELECT rownumber() OVER (order by column1, column2) AS number, column1, column2 FROM mytable ) temp WHERE number BETWEEN 20 AND 30 The subquery here obtains every row in your table, and the rownumber function is assigned based on the order specified. The "outside" query can use the rownumber to select the rows that you actually want for your batches.
downvote count: 1
score: -1
has comment: http://stackoverflow.com/comment/2762875
upvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2631124

queue
tags question: http://stackoverflow.com/q/2693860
type: Tag
tags question: http://stackoverflow.com/q/2644688
tags question: http://stackoverflow.com/q/2659267
tag name: queue
tags question: http://stackoverflow.com/q/2703984
tags question: http://stackoverflow.com/q/2758966
tags question: http://stackoverflow.com/q/2745580

http://stackoverflow.com/a/2768049
answers question: http://stackoverflow.com/q/2768032
score: 2
has body: Yes, absolutely. Its the same thing as doing this void move(Displaceable b){ b.move(); } //somewhere else move (new Circle(args)); move (new Square(args)); move (new Triangle(args)); If you think about it, its equivalent to have an abstract superclass Figure public abstract class Figure{ public abstract move(); } //Circle extends Figure; Figure f = new Circle(args); f.move();
downvote count: 0
upvote count: 2
type: Answer

http://stackoverflow.com/a/2761025
has comment: http://stackoverflow.com/comment/2794878
has comment: http://stackoverflow.com/comment/2792936
answers question: http://stackoverflow.com/q/2760995
score: 40
upvote count: 41
has body: Here is the closest you can get: ArrayList&lt;String&gt; list = new ArrayList(Arrays.asList("Ryan", "Julie", "Bob")); You can go even simpler with: List&lt;String&gt; list = Arrays.asList("Ryan", "Julie", "Bob") Looking at the source for Arrays.asList, it constructs an ArrayList, but by default is cast to List. So you could do this (but not reliably for new JDKs): ArrayList&lt;String&gt; list = (ArrayList&lt;String&gt;)Arrays.asList("Ryan", "Julie", "Bob")
downvote count: 1
type: Answer

gson
tags question: http://stackoverflow.com/q/2667683
tags question: http://stackoverflow.com/q/2732650
tag name: gson
tags question: http://stackoverflow.com/q/2774340
tags question: http://stackoverflow.com/q/2634863
tags question: http://stackoverflow.com/q/2598363
tags question: http://stackoverflow.com/q/2779251
type: Tag

http://stackoverflow.com/a/2699807
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/2699788
has body: There is no direct method in Java to check subclass. instanceof Event would return back true for any sub class objects The you could do getClass() on the object and then use getSuperclass() method on Class object to check if superclass is Event.
score: 1
downvote count: 0

http://stackoverflow.com/q/2728584
has title: How to flash a JFrame on the Windows taskbar when it needs attention
has comment: http://stackoverflow.com/comment/9890023
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/9890363
tagged with: notify
has answer: http://stackoverflow.com/a/7926562
score: 0
tagged with: taskbar
has body: I'm a computer science student working on a Yahoo! Messenger-like program implemented in Java. My problem is that whenever the JTextArea inside my frame contains new message updates, the user must be prompted even when his/her frame is minimized. Is there a workaround on how to make the JFrame on the taskbar blink when updates are received? In short, I need a way to notify the user that the frame has been updated even though it is minimized. How can I do that?
answer count: 1
linked to: http://stackoverflow.com/q/6423987
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/489255

http://stackoverflow.com/a/2713013
downvote count: 0
score: 298
has comment: http://stackoverflow.com/comment/100094563
has body: You should not need to access Maven-specific files to get the version information of any given library/class. You can simply use getClass().getPackage().getImplementationVersion() to get the version information that is stored in a .jar-files MANIFEST.MF. Unfortunately Maven does not write the correct information to the manifest as well by default! Instead one has to modify the configuration element of the maven-jar-plugin to set addDefaultImplementationEntries and addDefaultSpecificationEntries to true, like this: org.apache.maven.plugins maven-jar-plugin <addDefaultImplementationEntries>true</addDefaultImplementationEntries> <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries> Ideally this configuration should be put into the company pom or another base-pom. Detailed documentation of the element can be found in the Maven Archive documentation.
type: Answer
has comment: http://stackoverflow.com/comment/123643787
has comment: http://stackoverflow.com/comment/132668542
has comment: http://stackoverflow.com/comment/19140370
has comment: http://stackoverflow.com/comment/63957821
accepted answer of: http://stackoverflow.com/q/2712970
has comment: http://stackoverflow.com/comment/19155130
has comment: http://stackoverflow.com/comment/34279354
has comment: http://stackoverflow.com/comment/21738711
has comment: http://stackoverflow.com/comment/70901344
answers question: http://stackoverflow.com/q/2712970
has comment: http://stackoverflow.com/comment/75452991
has comment: http://stackoverflow.com/comment/19760527
upvote count: 298
has comment: http://stackoverflow.com/comment/132662804
type: AcceptedAnswer

http://stackoverflow.com/q/2632249
score: 17
answer count: 6
tagged with: class
has answer: http://stackoverflow.com/a/2632278
has answer: http://stackoverflow.com/a/2632403
possible better answer: http://stackoverflow.com/a/2632470
downvote count: 0
has answer: http://stackoverflow.com/a/2632470
favorite count: 0
has title: Java: exception-throwing class?
tagged with: exception
has body: I have classes DirReader and Search. The search uses DirReader. I want the search to know when DirReader throws exception. So how can I have class throwing exception? Currently, I use initCorrect -dummy var. Exception-style method may be more appropriate. Simplified Example Error $ javac ExceptionStatic.java ExceptionStatic.java:4: '{' expected public class ExceptionStatic throws Exception{ ^ 1 error Code import java.util.*; import java.io.*; // THIS PART NEEDS TO BE FIXED: public class ExceptionStatic throws Exception{ private static boolean initCorrect = false; public static String hello; static{ try{ hello = "hallo"; //some other conditionals in real code if( true) throw new Exception(); initCorrect=true; }catch(Exception e){ e.printStackTrace(); } } public static void main(String[] args){ if(initCorrect) System.out.println(hello); } }
accepted answer: http://stackoverflow.com/a/2632403
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2632305
has answer: http://stackoverflow.com/a/71187917
tagged with: error-handling
has answer: http://stackoverflow.com/a/56489930
upvote count: 17
type: Question
tagged with: java

http://stackoverflow.com/a/2770996
has comment: http://stackoverflow.com/comment/2804393
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2770965
answers question: http://stackoverflow.com/q/2770965
downvote count: 0
type: Answer
score: 3
upvote count: 3
has body: Have you looked at Guava's MapMaker class? I think it will do everything you need - although instead of providing a Future, you give the class a Function&lt;? super K, ? extends V&gt; which is used to compute the value. Looking back over your post, if you really need to put values in there rather than computing them, it won't work as well - but I'll leave the suggestion here in case a computing map is okay for you.

http://stackoverflow.com/comment/121609008
type: AnswerComment
comment on: http://stackoverflow.com/a/21068644
score: 0
has text: The best explaination I ever read on a subject. You can write a book on any subject...
type: Comment

http://stackoverflow.com/comment/15456305
type: Comment
comment on: http://stackoverflow.com/a/2601459
has text: Hi there, anyone have a working copy of LabelMaker? The link to the src in that blog post don't seem to be valid anymore.
type: AnswerComment
score: 0

http://stackoverflow.com/comment/2646127
has text: Um, `extends java.util.PropertyResourceBundle`.
comment on: http://stackoverflow.com/a/2630388
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/a/2783334
type: Answer
has body: If you just want simple text don't worry about filtering specific html tags. You want the equvilent to PHP's htmlspecialchars(). A good way to use this is print htmlspecialchars($var,ENT_QUOTES); This function will perform the following encodings: '&amp;' (ampersand) becomes '&amp;amp;' '"' (double quote) becomes '&amp;quot;' when ENT_NOQUOTES is not set. ''' (single quote) becomes '&amp;#039;' only when ENT_QUOTES is set. '&lt;' (less than) becomes '&amp;lt;' '&gt;' (greater than) becomes '&amp;gt;' This is solving the problem of XSS at the lowest level, and you don't need some complex library/regex that you don't understand (and is probably insecure after all complexity is the enemy of security). Make sure to TEST YOUR XSS FILTER by running a free xss scanner.
downvote count: 0
score: 3
answers question: http://stackoverflow.com/q/2781574
upvote count: 3

http://stackoverflow.com/comment/129070137
comment on: http://stackoverflow.com/a/52468697
score: 1
type: AnswerComment
has text: Thank you so very much for your answer. Your very concrete examples with the generic Lists and why we can and can't do certain operations finally made it click for me.
type: Comment

http://stackoverflow.com/q/2744011
tagged with: caching
upvote count: 2
has comment: http://stackoverflow.com/comment/54340022
downvote count: 0
favorite count: 0
type: UnansweredQuestion
tagged with: dns
score: 2
answer count: 0
tagged with: java
type: Question
has body: Struggling to find comprehensive documentation for JNDI and DNS. There is some here but it's rather limited. Specific question: Is it possible to control the caching behaviour of lookups against DNS using com.sun.jndi.dns.DnsContextFactory, for example to say 'do not cache'. Example code: Hashtable&lt;String, String&gt; env = new Hashtable&lt;String, String&gt;(); env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory"); env.put("java.naming.provider.url", "dns://mydns/mycompany.com"); .... DirContext ictx = new InitialDirContext(env); Additionally, is there some comprehensive API documentation that I haven't yet found?
tagged with: jndi
has title: Specify cache expiry for com.sun.jndi.dns.DnsContextFactory?

http://stackoverflow.com/comment/2757880
type: QuestionComment
has text: java Communications API - The Serial one works great, The Parallel port I could not get to work. http://java.sun.com/products/javacomm/
score: 0
comment on: http://stackoverflow.com/q/2729186
type: Comment

http://stackoverflow.com/comment/15748409
type: Comment
has text: I want to add any item at the end of list. then how can i do this?
comment on: http://stackoverflow.com/a/2639159
type: AnswerComment
score: 0

http://stackoverflow.com/a/2762638
type: Answer
has body: There is, but it's very new, so it's not widely available. The IntegrationService was introduced in 1.6.0u18. The method of interest is requestShortcut.
downvote count: 0
answers question: http://stackoverflow.com/q/2762492
score: 3
has comment: http://stackoverflow.com/comment/19031911
upvote count: 3
has comment: http://stackoverflow.com/comment/34107770
has comment: http://stackoverflow.com/comment/2794906

http://stackoverflow.com/comment/2701913
type: AnswerComment
score: 0
type: Comment
has text: no, because in my case I am accessing the fields directly rather than using getField(fieldIndex), i.e. based on my flag for what field was the last focussed I call either yesField.setFocus or noField.setFocus, both of which are standard RadioButtonFields. When I referred to CustomField above I was talking about the container (Manager class).
comment on: http://stackoverflow.com/a/2674449

http://stackoverflow.com/q/2663891
tagged with: wcf
has answer: http://stackoverflow.com/a/2849857
tagged with: silverlight-4.0
has title: silverlight 4 with java service
type: Question
type: AnsweredQuestion
tagged with: java
has body: i intent to replace wcf service with some java service . how should i design my wcf service such that it's gets replaced or can be replaced with the java service later such that i dont have to do any work or very little work on the client i.e on my silver light application . any idea's / suggestions? P.S 1. that is the reason i am not using RIA services. 2.my wcf service should work like wcf data services work. it should allow me to do CRUD operations on my entities.
possible better answer: http://stackoverflow.com/a/2669778
has answer: http://stackoverflow.com/a/2669778
answer count: 2
accepted answer: http://stackoverflow.com/a/2849857
score: 0
tagged with: silverlight
has comment: http://stackoverflow.com/comment/2683587
has comment: http://stackoverflow.com/comment/2681786

http://stackoverflow.com/comment/10533020
has text: Donal, it's helpful to tell others how you fixed your problem. Then others can benefit from your knowledge, in the same way you might benefit from theirs by asking questions on this site.
type: Comment
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/2599536

http://stackoverflow.com/a/2626751
type: Answer
has body: Based on what Hibernate in Action said and the workaround provided by your own answer, you could sort your collection at runtime to avoit your exception @Entity public class Aa { private List&lt;Bb&gt; bbList - new ArrayList&lt;Bb&gt;(); @OneToMany public List&lt;Bb&gt; getBbList() { return bbList; } @Transient public List&lt;Bb&gt; getBbListSortedBySomeProperty() { Collections.sort(bbList, new Comparator&lt;Bb&gt;() { public int compare(Bb o1, Bb o2) { return o1.getSomeProperty().compareTo(o2.getSomeProperty()); } }); return bbList; } } Be aware someProperty must implement Comparable ... @Entity public class Bb { private List&lt;Cc&gt; ccList - new ArrayList&lt;Cc&gt;(); @OneToMany public List&lt;Cc&gt; getCcList() { return ccList; } }
score: 0
answers question: http://stackoverflow.com/q/2622233
has comment: http://stackoverflow.com/comment/2640668

http://stackoverflow.com/comment/2752546
score: 1
comment on: http://stackoverflow.com/a/2725747
type: AnswerComment
has text: Wow. Java is actually pretty verbose ;)
type: Comment

http://stackoverflow.com/comment/2614886
score: 0
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/2604775
has text: better too much than too little, however it is best to come up with the smallest possible example that illustrates the issue :-)

http://stackoverflow.com/a/2719808
has body: What you are seeing is Java generics, which allows classes and methods to be parameterized by other classes. This is especially useful when creating container classes, since it saves you having to create separate classes for "a list of integers", "a list of strings", etc. Instead, you can have a single "list of some type T, where T is a variable" and then you can instantiate the list for some specific type T. Note that Java generics is not quite the same as template types in C++; Java generics actually use the same class definition but add implicit casting (generated by the compiler) and add additional type-checking. However, the different instantiations actually make use of the same exact type (this is known as erasure), where the parameterized types are replaced with Object. You can read more about this at the link.
answers question: http://stackoverflow.com/q/2719776
score: 0
type: Answer

http://stackoverflow.com/q/2622776
upvote count: 17
has answer: http://stackoverflow.com/a/2622796
answer count: 4
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2623043
downvote count: 0
favorite count: 0
score: 17
tagged with: character
possible better answer: http://stackoverflow.com/a/2622794
type: Question
has comment: http://stackoverflow.com/comment/2635198
has title: Regex to match four repeated letters in a string using a Java pattern
has answer: http://stackoverflow.com/a/2622794
has answer: http://stackoverflow.com/a/2622795
tagged with: regex
tagged with: java
has answer: http://stackoverflow.com/a/2623043
has body: I want to match something like aaaa, aaaad, adjjjjk. Something like ([a-z])\1+ was used to match the repeated characters, but I am not able to figure this out for four letters.

http://stackoverflow.com/q/2631301
tagged with: xalan
has answer: http://stackoverflow.com/a/2635901
score: 0
has body: I am working with an open source version of the Saxon XSLT processor "Saxon 9.0.0.2J from Saxonica" and am trying to make use of the java extensibility for the first time. I am running into an issue I suspect may be a limitation on the open source version, but wanted to check first whether there might be something I am just missing here. From the snippet below, my result is that the final value of $c1 does not change as a result of the call to greg:setTime() - i.e. the $c1 variable within Saxon appears to be unhooked from the underlying Java object and there is no apparent way to access the object as updated by the setTime() call. NOTE that all code in the snippet is tested and working otherwise - i.e. $c1 is properly instantiated by the getInstance() call, $startdate is of the proper format and $d1 is properly instantiated. Thoughts? &lt;xsl:transform ..... xmlns:sql="java:java.sql.Date" xmlns:greg="java:java.util.GregorianCalendar" ..... &gt; .... &lt;xsl:element name="JobExpireDate"&gt; &lt;xsl:variable name="c1" select="greg:getInstance()" /&gt; &lt;xsl:variable name="d1" select="sql:valueOf($startdate)" /&gt; &lt;xsl:variable name="void" select="greg:setTime($c1,$d1)" /&gt; &lt;xsl:value-of select="$c1" /&gt; &lt;/xsl:element&gt;
has comment: http://stackoverflow.com/comment/2649867
possible better answer: http://stackoverflow.com/a/2631530
tagged with: xslt
type: Question
type: AnsweredQuestion
has title: Cannot access updated Java object from Saxon XSLT processor
tagged with: java
tagged with: saxon
has comment: http://stackoverflow.com/comment/2649510
has answer: http://stackoverflow.com/a/2631530
accepted answer: http://stackoverflow.com/a/2635901
answer count: 2

http://stackoverflow.com/comment/2618640
score: 0
type: AnswerComment
has text: made it with the use of jdo2-api-2.3-ec.jar With this version installed in the Eclipse plugin folder, DN 2.x are recognized. Thanks!
type: Comment
comment on: http://stackoverflow.com/a/2599880

http://stackoverflow.com/q/2693223
has answer: http://stackoverflow.com/a/2693532
has comment: http://stackoverflow.com/comment/2715575
has body: I've got text file that contains 1 000 002 numbers in following formation: 123 456 1 2 3 4 5 6 .... 999999 100000 Now I need to read that data and allocate it to int variables (the very first two numbers) and all the rest (1 000 000 numbers) to an array int[]. It's not a hard task, but - it's horrible slow. My first attempt was java.util.Scanner: Scanner stdin = new Scanner(new File("./path")); int n = stdin.nextInt(); int t = stdin.nextInt(); int array[] = new array[n]; for (int i = 0; i &lt; n; i++) { array[i] = stdin.nextInt(); } It works as excepted but it takes about 7500 ms to execute. I need to fetch that data in up to several hundred of milliseconds. Then I tried java.io.BufferedReader: Using BufferedReader.readLine() and String.split() I got the same results in about 1700 ms, but it's still too many. How can I read that amount of data in less that 1 second? The final result should be equal to: int n = 123; int t = 456; int array[] = { 1, 2, 3, 4, ..., 999999, 100000 }; According to trashgod answer: StreamTokenizer solution is fast (takes about 1400 ms) but it's still too slow: StreamTokenizer st = new StreamTokenizer(new FileReader("./test_grz")); st.nextToken(); int n = (int) st.nval; st.nextToken(); int t = (int) st.nval; int array[] = new int[n]; for (int i = 0; st.nextToken() != StreamTokenizer.TT_EOF; i++) { array[i] = (int) st.nval; } PS. There is no need for validation. I'm 100% sure that data in ./test_grz file is correct.
upvote count: 19
possible better answer: http://stackoverflow.com/a/2693483
has answer: http://stackoverflow.com/a/2698772
tagged with: optimization
has comment: http://stackoverflow.com/comment/2715010
answer count: 7
has title: Read large amount of data from file in Java
favorite count: 0
has comment: http://stackoverflow.com/comment/2715479
has comment: http://stackoverflow.com/comment/2715364
has answer: http://stackoverflow.com/a/2693628
downvote count: 0
has answer: http://stackoverflow.com/a/2694507
tagged with: input
has comment: http://stackoverflow.com/comment/2715305
has comment: http://stackoverflow.com/comment/2714956
score: 19
has answer: http://stackoverflow.com/a/2693483
type: AnsweredQuestion
tagged with: performance
has comment: http://stackoverflow.com/comment/2714861
tagged with: java
has answer: http://stackoverflow.com/a/2693465
accepted answer: http://stackoverflow.com/a/2698772
linked to: http://stackoverflow.com/q/2080403
type: Question
has answer: http://stackoverflow.com/a/40830209

http://stackoverflow.com/comment/2798721
has text: Note that this will be case sensitive and confused by punctuation though.
type: AnswerComment
comment on: http://stackoverflow.com/a/2765603
score: 0
type: Comment

http://stackoverflow.com/q/2684885
has title: Safeguard against forgetting to configure transactions in spring
type: UnansweredQuestion
tagged with: spring
tagged with: java
type: Question
has body: Is there a way to make beans unavailable in spring framework? i would like to ensure that in case a developer forgot to wrap transaction around a service in spring framework, that service should become unavailable at run time. Thank you,
has comment: http://stackoverflow.com/comment/2705977
score: 0
has answer: http://stackoverflow.com/a/2685044
answer count: 1

http://stackoverflow.com/q/2751697
has answer: http://stackoverflow.com/a/2751720
upvote count: 3
tagged with: java
type: Question
tagged with: object
has answer: http://stackoverflow.com/a/2760624
has answer: http://stackoverflow.com/a/2751726
has title: Java: I've created a list of word objects to include the name and the frequency, but having trouble updating the frequency
downvote count: 0
has answer: http://stackoverflow.com/a/2760464
favorite count: 0
type: UnansweredQuestion
has body: I'm working on a project which has a dictionary of words and I'm extracting them and adding them to an ArrayList as word objects. I have a class called Word as below. What I'm wondering is how do I access these word objects to update the frequency? As part of this project, I need to only have one unique word, and increase the frequency of that word by the number of occurrences in the dictionary. Word(String word) { this.word = word; this.freq = 0; } public String getWord() { return word; } public int getFreq() { return freq; } public void setFreq() { freq = freq + 1; } This is how I am adding the word objects to the ArrayList...I think it's ok? String pattern = "[^a-zA-Z\\s]"; String strippedString = line.replaceAll(pattern, ""); line = strippedString.toLowerCase(); StringTokenizer st = new StringTokenizer(line); while (st.hasMoreTokens()) { String newWord = st.nextToken(); word.add(new Word(newWord)); count++; }
answer count: 4
score: 3

http://stackoverflow.com/a/48598607
score: 9
answers question: http://stackoverflow.com/q/2654839
upvote count: 9
type: Answer
has body: The Math.round function is overloaded When it receives a float value, it will give you an int. For example this would work. int a=Math.round(1.7f); When it receives a double value, it will give you a long, therefore you have to typecast it to int. int a=(int)Math.round(1.7); This is done to prevent loss of precision. Your double value is 64bit, but then your int variable can only store 32bit so it just converts it to long, which is 64bit but you can typecast it to 32bit as explained above.
downvote count: 0

http://stackoverflow.com/q/2782200
has answer: http://stackoverflow.com/a/11455318
has title: Java- screen capture behind the application
answer count: 3
has body: Is there a way to capture the screen but without the app itself getting shown. I know how to minimize or make a frame invisible but this has to be done real fast cos it's going to happen alot in each second (at least once every second). I want it to look something like the magnifier in Windows Vista/7. (The app can see behind itself.)
downvote count: 0
tagged with: awtrobot
accepted answer: http://stackoverflow.com/a/2782223
favorite count: 0
upvote count: 2
type: AnsweredQuestion
score: 2
tagged with: screenshot
tagged with: java
possible better answer: http://stackoverflow.com/a/2782303
has answer: http://stackoverflow.com/a/2782303
has answer: http://stackoverflow.com/a/2782223
type: Question

http://stackoverflow.com/comment/2693706
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2674754
has text: Varargs + foreach combo is best.
type: AnswerComment

http://stackoverflow.com/comment/87961949
has text: What about DST?
type: Comment
comment on: http://stackoverflow.com/a/2624669
score: 0
type: AnswerComment

http://stackoverflow.com/comment/52681346
type: Comment
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/2664989
has text: Five years later...how about http://cloud.spring.io/spring-cloud-config/

http://stackoverflow.com/q/2597736
upvote count: 4
type: AnsweredQuestion
downvote count: 0
has title: Java - Google App Engine - InvalidClassException when I change a class that was stored in session scope
tagged with: java
type: Question
tagged with: session
answer count: 1
score: 4
has body: I updated my User class, and now whenever someone that had the old version of the User class stored in their session scope accesses my site, I get an InvalidClassException. javax.servlet.ServletException: java.lang.RuntimeException: java.io.InvalidClassException: User; local class incompatible: stream classdesc serialVersionUID = 4949038118012519093, local class serialVersionUID = -971500502189813151 How do I stop this error from happening for those users? I could probably invalidate everyone's sessions every time I want to update a class that gets stored in session scope, but is there a better way, so that my user's don't have to login again?
has comment: http://stackoverflow.com/comment/14092741
has answer: http://stackoverflow.com/a/2597782
accepted answer: http://stackoverflow.com/a/2597782
favorite count: 0
tagged with: google-app-engine

excel
tags question: http://stackoverflow.com/q/2600876
tags question: http://stackoverflow.com/q/2609301
tag name: excel
tags question: http://stackoverflow.com/q/2604451
tags question: http://stackoverflow.com/q/2738257
tags question: http://stackoverflow.com/q/2649664
tags question: http://stackoverflow.com/q/2645566
type: Tag
tags question: http://stackoverflow.com/q/2785719

http://stackoverflow.com/comment/2656834
score: 0
comment on: http://stackoverflow.com/a/2638029
type: Comment
has text: I have executed this code and it doesn't seem to add data to the dataset after the view is shown. Am I wrong? Thanks
type: AnswerComment

http://stackoverflow.com/q/2732260
linked to: http://stackoverflow.com/q/1388602
has title: In Java, when I call OutputStream.close() do I always need to call OutputStream.flush() before?
tagged with: java
has answer: http://stackoverflow.com/a/38911375
has answer: http://stackoverflow.com/a/2732760
type: Question
has answer: http://stackoverflow.com/a/2732264
possible better answer: http://stackoverflow.com/a/2732760
accepted answer: http://stackoverflow.com/a/2732264
tagged with: file-io
has body: If I just call close() in a output stream, the output is guaranteed, or need I call flush() always?
downvote count: 0
favorite count: 0
score: 51
upvote count: 51
answer count: 4
has comment: http://stackoverflow.com/comment/35283966
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/36874583

http://stackoverflow.com/comment/57973585
has text: Brilliant. Thank you. If the argument is `long`, can this still work with boxing and `Long.class` ?
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/28330532
type: Comment

http://stackoverflow.com/q/2660061
type: Question
has comment: http://stackoverflow.com/comment/2677214
score: 0
answer count: 1
has answer: http://stackoverflow.com/a/2661174
has comment: http://stackoverflow.com/comment/2677583
has title: Java, swt and web
has body: How to retrieve all images from a site. I want to make desktop application which show images of a cars received by a web site.
has comment: http://stackoverflow.com/comment/52320614
type: UnansweredQuestion
tagged with: java

http://stackoverflow.com/comment/2641110
type: Comment
score: 0
has text: @Arivu2020: Are you in the right directory? Perhaps your batch file need to do `cd c:\path\to\my\stuff` before trying to run the jar file?
type: AnswerComment
comment on: http://stackoverflow.com/a/2622072

http://stackoverflow.com/a/52067724
answers question: http://stackoverflow.com/q/2636086
score: 0
has body: You can also use @code to escape the annotation, but you must do each one individually like this: /** * &lt;pre&gt; * public class Demo { * {@code @DemoAnnotation } * {@code @AnotherAnnotation } * public void demoMethod() { * } * } * &lt;/pre&gt; */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD}) public @interface DemoAnnotation { will render like this: public class Demo { @DemoAnnotation @AnotherAnnotation public void demoMethod() { } } Note: It will not work to simply wrap both annotations - or the entire code sample - in one @code block.
type: Answer

http://stackoverflow.com/a/2661495
has comment: http://stackoverflow.com/comment/122503979
has comment: http://stackoverflow.com/comment/117187448
answers question: http://stackoverflow.com/q/2654949
has comment: http://stackoverflow.com/comment/10449317
has body: I found the solution! Maybe its not so elegant, but... Here I will post two solutions: Prefferable, but not working Working one, but requires additional library First: I found a kind of solution here, but it throws exception. Solution: import java.io.*; import java.security.*; import java.security.interfaces.RSAPrivateCrtKey; import java.security.interfaces.RSAPublicKey; import java.security.spec.*; import javax.crypto.*; import javax.crypto.spec.*; /* * This class demonstrates how to import an encrypted RSA private key as * generated by openssl. The input file is presumed to be in DER * format. */ public class ImportEncryptedPrivateKey { public static byte[] readPK8FromFile(String fileName) throws IOException { File f = new File(fileName); DataInputStream dis = new DataInputStream(new FileInputStream(f)); byte[] theData = new byte[(int) f.length()]; dis.readFully(theData); return theData; } public static void main(String[] args) throws IOException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeySpecException, InvalidKeyException, InvalidAlgorithmParameterException { byte[] encryptedPKInfo = readPK8FromFile("rsapriv.pk8"); EncryptedPrivateKeyInfo ePKInfo = new EncryptedPrivateKeyInfo( encryptedPKInfo); char[] password = { 'p', 'a', 's', 's', 'w', 'o', 'r', 'd' }; Cipher cipher = Cipher.getInstance(ePKInfo.getAlgName()); PBEKeySpec pbeKeySpec = new PBEKeySpec(password); // Now create the Key from the PBEKeySpec SecretKeyFactory skFac = SecretKeyFactory.getInstance(ePKInfo .getAlgName()); Key pbeKey = skFac.generateSecret(pbeKeySpec); // Extract the iteration count and the salt AlgorithmParameters algParams = ePKInfo.getAlgParameters(); cipher.init(Cipher.DECRYPT_MODE, pbeKey, algParams); // Decrypt the encryped private key into a PKCS8EncodedKeySpec KeySpec pkcs8KeySpec = ePKInfo.getKeySpec(cipher); // Now retrieve the RSA Public and private keys by using an // RSA keyfactory. KeyFactory rsaKeyFac = KeyFactory.getInstance("RSA"); // First get the private…
has comment: http://stackoverflow.com/comment/5056416
downvote count: 1
has comment: http://stackoverflow.com/comment/138102716
upvote count: 9
type: Answer
score: 8
has comment: http://stackoverflow.com/comment/130380738

http://stackoverflow.com/q/2668997
type: Question
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/2669057
has title: How to add a spring application context to the java runtime to be used for integration tests within eclipse?
tagged with: eclipse
answer count: 2
has answer: http://stackoverflow.com/a/2671469
tagged with: junit
downvote count: 0
has body: I am trying to add a test spring application context to the java runtime, so that my beans can be wired properly for my integration tests.
favorite count: 0
accepted answer: http://stackoverflow.com/a/2669057
possible better answer: http://stackoverflow.com/a/2671469
score: 2
upvote count: 2
tagged with: spring

http://stackoverflow.com/comment/2787434
type: AnswerComment
score: 0
type: Comment
has text: +1, but I'd say it's almost always a bad idea, unless you know that it's exactly what you want to do.
comment on: http://stackoverflow.com/a/2756001

http://stackoverflow.com/q/2775306
tagged with: java
tagged with: swing
type: Question
score: 4
has body: When should I rather implement TableModel and when should I extend AbstractTableModel?
has answer: http://stackoverflow.com/a/2775351
answer count: 3
has answer: http://stackoverflow.com/a/2775374
accepted answer: http://stackoverflow.com/a/2775374
favorite count: 0
upvote count: 4
type: AnsweredQuestion
tagged with: tablemodel
has title: Java Swing: implement TableModel or extend AbstractTableModel?
possible better answer: http://stackoverflow.com/a/2775351
has answer: http://stackoverflow.com/a/2775362
downvote count: 0

http://stackoverflow.com/q/2633451
accepted answer: http://stackoverflow.com/a/2633780
favorite count: 0
tagged with: exception
has body: I was hoping to implement a single "ExceptionController" to handle exceptions that are thrown in execution of my other controllers' methods. I hadn't specified any HandlerExceptionResolver in my application context so according to the API documentation the AnnotationMethodHandlerExceptionResolver should be started. I verified it as such in the source. So why doesn't the following work? @Controller public class ExceptionController { @ExceptionHandler(NullPointerException.class) public ModelAndView handleNullPointerException(NullPointerException ex) { // Do some stuff log.error(logging stuff) return myModelAndView; } } @Controller public class AnotherController { @RequestMapping(value="/nullpointerpath") public String throwNullPointer() { throw new NullPointerException(); } } I see in the debug logs that the three default exception handlers are asked for handling of the exception, but nothing is done and I see "DispatcherServlet - Could not complete request". Followed by the user being displayed the stacktrace and a 500 Internal error.
possible better answer: http://stackoverflow.com/a/4552430
tagged with: spring-mvc
type: AnsweredQuestion
has title: Spring 3 controller exception handler implementation problems
has answer: http://stackoverflow.com/a/4552430
score: 7
tagged with: java
upvote count: 7
type: Question
has answer: http://stackoverflow.com/a/2633780
has answer: http://stackoverflow.com/a/2633610
answer count: 3
downvote count: 0

http://stackoverflow.com/a/2667576
type: Answer
has body: This seems self-referencing.. how can you choose to compile something in a way that is actually declared inside what you want to compile itself? When javac starts to compile it should already know what compliance level to use.. I think you can do it by using JavaCompiler interface (apidoc here) but you'll have to workout something that is not so simple..
answers question: http://stackoverflow.com/q/2667490
score: 0

http://stackoverflow.com/a/2734852
type: Answer
has body: If I understand correctly you are just trying to write to the target table in batches of 10 rows. There is no need to batch the reads into 10 rows. Just fire of the select statement then keep reading until you run out of data. On every 10th row you can invoke the writer. However most jdbc clients will perform this sort of optimisation under the covers so this will lprobably be no better than inserting rows one at a time. I have my doubts that a nieve multithreaded implementation will speed things up as the target database engine is doing most of the work anyway and it will be constrained by log writes and locking which multithreading does not help (or makes worse!). As far as I can see a simple single threaded "select"/"insert" process will easily outperform your multithreaded program. There are other ways to optimise this:- Tune you database clients so that network operations are batched up. Examine you "COMMIT" processing so that you commit after every 100 or so inserts.
score: 0
answers question: http://stackoverflow.com/q/2631124

http://stackoverflow.com/q/2755994
has body: I just about to learn Java programming. I already have jdk on my computer. Then, I found this Netbeans is quite popular and come with all I needs. My question is, will there be any conflict if I install full version of Netbeans while I already have jdk installed on same machine(windows vista)? I will appreciate your answers and advices, thanks.
type: Question
tagged with: windows-vista
has answer: http://stackoverflow.com/a/2756020
accepted answer: http://stackoverflow.com/a/2756020
score: 0
answer count: 3
has answer: http://stackoverflow.com/a/3274227
tagged with: installation
has answer: http://stackoverflow.com/a/2756011
has title: Can I install Netbeans while I already installed jdk.1.6.xx on same machine?
type: AnsweredQuestion
tagged with: java
possible better answer: http://stackoverflow.com/a/2756011

http://stackoverflow.com/q/2675462
answer count: 2
has title: Webwork actions, the lifecycle of variables declared in the action class
favorite count: 0
has body: I'm using the webwork framework (JIRA plugin development) and was wondering about the lifecycle of the variables in the action class. I have a few private variables in the action class that are set when during the doDefault() method. These are used in the input view to set up jqGrid columns and then when the user has entered some data they click submit which puts the grid data into a hidden input. The next thing that happens is the doValidation() method is called before the doExecute(), which displays the input view if there are any errors. The problem is that the variables set up in the doDefault() method are now null. Can anyone explain to me how the lifecycle of variables works in the webwork actions? Cheers
accepted answer: http://stackoverflow.com/a/2676425
score: 2
type: AnsweredQuestion
downvote count: 0
possible better answer: http://stackoverflow.com/a/2677518
has answer: http://stackoverflow.com/a/2677518
has answer: http://stackoverflow.com/a/2676425
tagged with: jira
type: Question
tagged with: java
tagged with: webwork
upvote count: 2

http://stackoverflow.com/comment/30988695
type: AnswerComment
type: Comment
has text: The benefit of assert vs if is that you can specify a condition at runtime, that causes the JVM to completely ignore all assert statements as if they didn't exist, for an obvious performance gain. This is especially helpful if your asserts do some heavy calculation to determine their true/false state. You should however not disable asserts because they fail. In this case you should fix the code!
comment on: http://stackoverflow.com/a/19425549
score: 1

http://stackoverflow.com/a/2761676
accepted answer of: http://stackoverflow.com/q/2761618
type: Answer
downvote count: 0
score: 7
has body: My guess is that the manager is reporting the values that were set as part of the connector defintions, and not reporting the values from the executor. The executor wil work as expected, it's just not reported correctly in the manager. The 200 value for the AJP connector is misleading here, since 200 is the default value for maxThreads (as defined here); because you didn't specify maxThreads for the AJP connector, this is the value that is used. The HTTP connector is reporting nonsense values because it's delegating its thread management to the executor. To check if this is all true, try changing the maxThreads value of the executor to a different value. You should see maxThreads of the AJP connector staying at 200 (because that's its default value).
upvote count: 7
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2761618

http://stackoverflow.com/comment/66467159
type: AnswerComment
comment on: http://stackoverflow.com/a/2609474
score: 0
has text: @ApoloRadomer The example is for an excel file (xls) but xlsx would be the same.
type: Comment

http://stackoverflow.com/a/2657537
has comment: http://stackoverflow.com/comment/2674554
answers question: http://stackoverflow.com/q/2657525
type: Answer
accepted answer of: http://stackoverflow.com/q/2657525
has comment: http://stackoverflow.com/comment/2674646
upvote count: 8
has comment: http://stackoverflow.com/comment/2674543
has comment: http://stackoverflow.com/comment/2674658
has comment: http://stackoverflow.com/comment/2675133
has body: Powers of two grows exponentially. If vowelCount is high, one array alone could easily cause OutOfMemoryError (2^32 = 4GB). You can try to tweak your VM maximum memory requirement (e.g. -Xmx512m), but do realize that your algorithm is requiring A LOT OF MEMORY. You may want to find a better algorithm if at all possible. See also Wikipedia: exponential growth Wheat and chessboard problem -- famous anecdote to show just how surprisingly quick powers of two can grow java application launcher command line options "-Xmxn : Specify the maximum size of the memory allocation pool." After edit: just as I expected, you're generating a huge array filled with all binary possibilities. You rarely need to actually store this whole array in memory. You can just generate each possible combination "on-the-fly" and feed it to whoever needs the 0s and 1s "just-in-time". Do keep in mind that this is still exponential growth, so even though you've taken care of your memory requirement from O(2^N) to just O(N), your time complexity is still O(2^N). each time this method is called, that array is getting created. Is it possible that the array is not getting released . Yes, that is very possible, if the reference to the array is ever leaked, and then something somewhere holds on to this reference. The garbage collector doesn't really care what you think is/isn't garbage; as long as an object is referred to by something (and it's not a weak reference etc), it's NOT garbage. After figuring out what you're trying to do, here's my solution. Note that it doesn't generate an array of bits at all. static void generate(String prefix, String suffix) { int i = suffix.replaceAll("[aeiou].*", "").length(); if (i == suffix.length()) { System.out.println(prefix + suffix); } else { generate(prefix + suffix.substring(0, i), suffix.substring(i + 1)); generate(prefix + suffix.substring(0, i+1), suffix.substring(i + 1)); } } // generate("", "apple"); It uses regex to find where the next vowel is. You can use …
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2674535
score: 8

http://stackoverflow.com/a/3632321
score: 0
type: Answer
answers question: http://stackoverflow.com/q/2760570
has body: If your source is a true flv stream (no odd codec info) then this should work. There are only two problems I can think of that would arise here: There is not enough meta data info coming in before the writer starts to encode. For instance the codecs have not been detected. The incoming video is causing the failure due to its being invalid for the mp3 container type. Write a media tool to ignore the video. Hope that helps

http://stackoverflow.com/q/2681357
has body: Is it possible to write a GUI in Java that would display Japanese fonts correctly regardless of the language settings of the OS it's being run on? I'd like to write a program which is able to do this but I'm not sure how to start going about this. Any advice would be a huge help!
downvote count: 0
has answer: http://stackoverflow.com/a/2681400
has answer: http://stackoverflow.com/a/2681372
favorite count: 0
upvote count: 8
has answer: http://stackoverflow.com/a/2681827
answer count: 5
has answer: http://stackoverflow.com/a/2681734
tagged with: internationalization
score: 8
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/38344694
tagged with: java
type: Question
has title: Japanese fonts in a Java GUI

http://stackoverflow.com/comment/2778047
has text: Thanks again for the update. Unfortunately I am not quite there yet, could you maybe check my updated original post? Thanks a lot.
type: AnswerComment
comment on: http://stackoverflow.com/a/2747080
score: 0
type: Comment

http://stackoverflow.com/comment/2793303
score: 0
has text: No, someone else did :) The downvote was a while after my update. The reason that the `-` is preferred is because the `+` is actually the "URL-safe" character for a space, not intended for SEO purposes. Look how Stackoverflow and another major sites do it.
type: Comment
comment on: http://stackoverflow.com/a/2753495
type: AnswerComment

http://stackoverflow.com/a/2700387
upvote count: 1
downvote count: 0
answers question: http://stackoverflow.com/q/2700363
has body: Because it is useful to "fallthrough" from one case to another. If you don't need this (as is often the case), a simple break will prevent this. On the other hand, if case didn't fallthrough by default, there wouldn't be any easy way to do that.
type: Answer
score: 1

http://stackoverflow.com/a/2707525
score: 0
has comment: http://stackoverflow.com/comment/2731774
type: Answer
has comment: http://stackoverflow.com/comment/2731403
answers question: http://stackoverflow.com/q/2707516
has body: The core EE application can run unchanged. The external configuration is application server specific.

http://stackoverflow.com/comment/2713885
type: AnswerComment
score: 0
type: Comment
has text: For the outputString line, shouldn't it be `sdf2.format(date)`?
comment on: http://stackoverflow.com/a/2692485

http://stackoverflow.com/comment/2887883
comment on: http://stackoverflow.com/q/2781797
type: Comment
type: QuestionComment
score: 2
has text: You need to describe what the allocation behaviour of the application is & specify what exactly you mean by latency & state what is low latency in this case (1, 10micros, 100micros??). When you say "it should take more time to garbage collect" then it sounds like you're really referring to pause time caused by a GC event as opposed to application latency. YG pauses times don't scale linearly with eden size.

http://stackoverflow.com/a/2759427
score: 2
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2791305
accepted answer of: http://stackoverflow.com/q/2758799
has comment: http://stackoverflow.com/comment/2791281
upvote count: 2
has body: MAYBE (So don't kill me, please) this is a solution: In the terminal, go to the root of your java project (so the default package, in your situation, the parent directory of the folder pacc). Then type: javac pacc.PackTest.java I don't use the compiler manually. My IDE does that work for me.
answers question: http://stackoverflow.com/q/2758799
type: Answer

http://stackoverflow.com/a/36936879
type: Answer
upvote count: 1
score: 1
downvote count: 0
answers question: http://stackoverflow.com/q/2663115
has body: // To detect whether a circular loop exists in a linked list public boolean findCircularLoop() { Node slower, faster; slower = head; faster = head.next; // start faster one node ahead while (true) { // if the faster pointer encounters a NULL element if (faster == null || faster.next == null) return false; // if faster pointer ever equals slower or faster's next // pointer is ever equal to slower then it's a circular list else if (slower == faster || slower == faster.next) return true; else { // advance the pointers slower = slower.next; faster = faster.next.next; } } }

http://stackoverflow.com/q/2630771
type: Question
answer count: 2
downvote count: 0
tagged with: file-io
has comment: http://stackoverflow.com/comment/2644150
has answer: http://stackoverflow.com/a/2630999
has answer: http://stackoverflow.com/a/2630801
has body: In Java, I'm working with code running under WinXP that creates a file like this: public synchronized void store(Properties props, byte[] data) { try { File file = filenameBasedOnProperties(props); if ( file.exists() ) { return; } File temp = File.createTempFile("tempfile", null); FileOutputStream out = new FileOutputStream(temp); out.write(data); out.flush(); out.close(); file.getParentFile().mkdirs(); temp.renameTo(file); } catch (IOException ex) { // Complain and whine and stuff } } Sometimes, when a file is created this way, it's just about totally inaccessible from outside the code (though the code responsible for opening and reading the file has no problem), even when the application isn't running. When accessed via Windows Explorer, I can't move, rename, delete, or even open the file. Under Cygwin, I get the following when I ls -l the directory: ls: cannot access [big-honkin-filename] total 0 ?????????? ? ? ? ? ? [big-honkin-filename] As implied, the filenames are big, but under the 260-character max for XP (though they are slightly over 200 characters). To further add to the sense that my computer just wants me to feel stupid, sometimes the files created by this code are perfectly normal. The only pattern I've spotted is that once one file in the directory "locks", the rest are screwed. Anybody ever run into something like this before, or have any insights into what's going on here?
favorite count: 0
possible better answer: http://stackoverflow.com/a/2630801
upvote count: 1
type: AnsweredQuestion
has title: Unable to access Java-created file -- sometimes
accepted answer: http://stackoverflow.com/a/2630999
score: 1
tagged with: java
tagged with: windows-xp
has comment: http://stackoverflow.com/comment/2644090

http://stackoverflow.com/a/2687254
type: Answer
upvote count: 4
score: 2
has body: Google for "particle system"
has comment: http://stackoverflow.com/comment/2708035
has comment: http://stackoverflow.com/comment/2708171
downvote count: 2
has comment: http://stackoverflow.com/comment/2707937
answers question: http://stackoverflow.com/q/2687234
has comment: http://stackoverflow.com/comment/2708665

http://stackoverflow.com/a/2757295
type: Answer
downvote count: 0
score: 1
upvote count: 1
has body: As suggested here you could (if you run the Sun JVM) perform the following steps: launch jconsole or jvisualvm (both present in the bin-directory of your JDK-installation, attach to the process you suspect has locked up go to the Threads pane. There is a "Detect Deadlock" button
answers question: http://stackoverflow.com/q/2757066

http://stackoverflow.com/comment/113636423
score: 0
type: Comment
comment on: http://stackoverflow.com/a/23723450
type: AnswerComment
has text: A lot of messages here say what not to do. It would be nice to at least mention what to look for. Right now I look for some information how to do things. What I know now is RSA is for encrypting key of symetric algorithm, AES for example.

http://stackoverflow.com/comment/46428543
has text: Similar question for C, which does not have overload either: http://stackoverflow.com/questions/6637005/what-is-the-purpose-of-the-unary-operator-in-c , and analogously to Java does type promotion.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2624410

http://stackoverflow.com/comment/2784845
comment on: http://stackoverflow.com/q/2753722
score: 1
type: QuestionComment
type: Comment
has text: What really limits and heavily penalize Scala is that they made it a major pain to "gradually add some Scala" to an existing Java project. If only they worked a bit on that... But of course that's probably more difficult than creating yet-another-programming-language-that-targets-the-JVM ;)

http://stackoverflow.com/a/2646024
has body: You could use BigInteger for this. Example: (new BigInteger(1,bytes)).toString(16) You will need to add an '0' at the beginning. A more elegant solution (taken from here) is: BigInteger i = new BigInteger(1,bytes); System.out.println(String.format("%1$06X", i)); You need to know the number of bytes in advance in order to use the correct formatter.
type: Answer
upvote count: 1
score: 1
has comment: http://stackoverflow.com/comment/2661265
answers question: http://stackoverflow.com/q/2645974
has comment: http://stackoverflow.com/comment/2661192
downvote count: 0

http://stackoverflow.com/comment/2789866
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2758324
type: AnswerComment
has text: Thanks for the hint, fixed that.

http://stackoverflow.com/q/2630717
score: 1
tagged with: java
has title: Side effect with the Alfresco content repository API?
has comment: http://stackoverflow.com/comment/6543299
type: Question
tagged with: api
downvote count: 0
has answer: http://stackoverflow.com/a/5717874
has body: I'm studying Alfresco and particularly it's content repository Java API. I am trying to train with an example from the SDK "First Foundation Client". I took the code, I manage to handle it a bit but when I restart my alfresco server I get ugly stacktrace like ERROR [web.context.ContextLoader] Context initialization failed org.alfresco.error.AlfrescoRuntimeException: 03130001 Failed to initialise org.alfresco.enterprise.license.LicenseComponent at org.alfresco.repo.descriptor.DescriptorServiceImpl.constructSpecialService(DescriptorServiceImpl.java:301) at org.alfresco.repo.descriptor.DescriptorServiceImpl.access$100(DescriptorServiceImpl.java:51) at org.alfresco.repo.descriptor.DescriptorServiceImpl$1$1.execute(DescriptorServiceImpl.java:181) at org.alfresco.repo.descriptor.DescriptorServiceImpl$1$1.execute(DescriptorServiceImpl.java:179) at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:327) at org.alfresco.repo.descriptor.DescriptorServiceImpl$1.doWork(DescriptorServiceImpl.java:175) at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:514) at org.alfresco.repo.descriptor.DescriptorServiceImpl.onBootstrap(DescriptorServiceImpl.java:168) at org.alfresco.util.AbstractLifecycleBean.onApplicationEvent(AbstractLifecycleBean.java:62) at org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:77) at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:75) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:246) at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:617) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplic…
tagged with: alfresco
answer count: 1
tagged with: repository
tagged with: server-side
favorite count: 0
type: UnansweredQuestion
upvote count: 1

http://stackoverflow.com/comment/2732011
type: Comment
has text: It's Java, not JAVA. Java is not an acronym.
score: 0
comment on: http://stackoverflow.com/q/2707995
type: QuestionComment

http://stackoverflow.com/a/2772163
answers question: http://stackoverflow.com/q/2772043
has body: Let's be quite clear. You're micro-optimizing here. It's a waste of time. Here are the rules for optimization: Don't do it. (For experts only!) Don't do it yet. Write to code to use good algorithms. Write the code to be clear. Check whether you still have a problem. Measure to find out where it is that the problem actually exists. Only optimize then, and only if you must. (And be aware that it can be exceptionally difficult to get good timing figures on modern computers, especially if you have non-trivial other things in memory such as an IDE.)
downvote count: 0
upvote count: 2
type: Answer
score: 2

http://stackoverflow.com/q/2654124
tagged with: spring-security
favorite count: 0
tagged with: spring-webflow
has body: Can i use Spring Webflow/MVC and Spring Security and Hibernate on Google App Engine? Is there a list/summary of java frameworks that can be used on the GAE?
has title: Can i use Spring on GAE?
type: Question
tagged with: google-app-engine
tagged with: spring
upvote count: 11
tagged with: java
answer count: 2
has answer: http://stackoverflow.com/a/2654176
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/8279062
score: 11
downvote count: 0

http://stackoverflow.com/comment/126815123
comment on: http://stackoverflow.com/a/3312392
has text: @mahee96, O(NlogN) for sort and O(N logN) for binary search N times will result in O(NlogN) complexity
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/40689923
score: 6
type: AnswerComment
comment on: http://stackoverflow.com/a/9259495
type: Comment
has text: `fields.getSelectedItem().toString()` is a shorter equivalent.

http://stackoverflow.com/a/2726701
score: 0
has body: Can't getListA1() and getListA2() just return List types in the first instance? List&lt;A&gt; getListA1(){...} List&lt;A&gt; getListA2(){...}
answers question: http://stackoverflow.com/q/2726681
type: Answer
has comment: http://stackoverflow.com/comment/2753740

http://stackoverflow.com/q/2744511
linked to: http://stackoverflow.com/q/35957019
tagged with: programming-languages
linked to: http://stackoverflow.com/q/442026
has body: I know this is not possible but can anyone provide a theory as to why Java chose not to support this? I am asking because I just ran into a situation where I think it would be nice to have.
favorite count: 0
answer count: 9
tagged with: return
has answer: http://stackoverflow.com/a/3056029
has answer: http://stackoverflow.com/a/2745051
has answer: http://stackoverflow.com/a/2744521
possible better answer: http://stackoverflow.com/a/6399269
has answer: http://stackoverflow.com/a/2744522
has answer: http://stackoverflow.com/a/2744607
has answer: http://stackoverflow.com/a/6399269
type: AnsweredQuestion
tagged with: overloading
has answer: http://stackoverflow.com/a/2744544
tagged with: java
score: 48
upvote count: 49
has answer: http://stackoverflow.com/a/10089072
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/51860846
accepted answer: http://stackoverflow.com/a/2744522
has title: Java - why no return type based method overloading?

http://stackoverflow.com/comment/48004751
has text: This answer is accepted and downvoted. Why? Can I use it? Is it safe? Is it correct? If you downvote a answer TELL US WHY! Have balls and show yourself.
type: Comment
comment on: http://stackoverflow.com/a/2693739
score: 0
type: AnswerComment

http://stackoverflow.com/comment/2720911
score: 0
type: AnswerComment
type: Comment
has text: This adresses the issue when you switch to a dialect that does not support the hash symbol. The hash symbol is used in many other tables in my database and I never got any issues. It is really with this table that I am having trouble. I might be facing a bug in hibernate. Thank you for helping.
comment on: http://stackoverflow.com/a/2692002

http://stackoverflow.com/comment/2765100
type: AnswerComment
comment on: http://stackoverflow.com/a/2736741
has text: Code shows only list creation. I guess OP doesn't want to create new list just to keep it on heap unused. :) Arraylists can be created with less overhead and are faster to access. Linked lists are better when you do many removals, or when you need to implement stack/queues, but that is not the case here.
score: 0
type: Comment

http://stackoverflow.com/a/7205319
has comment: http://stackoverflow.com/comment/21146008
has body: just adding (columnDefinition = "NUMBER(9,2)") works! @Column(name = "CREDIT_AMOUNT", columnDefinition = "NUMBER(9,2)") @Basic private double creditAmount;
upvote count: 6
answers question: http://stackoverflow.com/q/2625600
score: 6
type: Answer
downvote count: 0
has comment: http://stackoverflow.com/comment/25111141

http://stackoverflow.com/comment/124757560
type: Comment
has text: In my case, the missing piece ended up being to use https://stackoverflow.com/a/5488964/513038 to generate an X509Certificate from the KeyPair I had, then use `truststore.setEntry("dummy", new KeyStore.TrustedCertificateEntry(cert), null);` rather than `setKeyEntry`. (I'd been getting errors like "KeyStoreException: Key protection algorithm not found ... Unsupported key type".) If you already have a cert, like for a remote partner negotiating a connection, you should be able to use that cert in `TrustedCertificateEntry(cert)` instead of generating your own.
comment on: http://stackoverflow.com/q/2767047
score: 0
type: QuestionComment

http://stackoverflow.com/q/2783602
answer count: 2
favorite count: 0
has body: I have two tables with the many-to-many association. — DB fragment: loads Id Name sessions Id Date sessionsloads LoadId SessionId — Hibernate mapping fragments: /* loads.hbm.xml */ &lt;set name="sessions" table="sessionsloads" inverse="true"&gt; &lt;key column="LoadId" /&gt; &lt;many-to-many column="SessionId" class="Session" /&gt; &lt;/set&gt; … /* sessions.hbm.xml */ &lt;set name="loads" table="sessionsloads"&gt; &lt;key column="SessionId" /&gt; &lt;many-to-many column="LoadId" class="Load" /&gt; &lt;/set&gt; In order to remove one entry from the association table sessionsloads, I execute this code: Session session = sessionDao.getObject(sessionId); Load load = loadDao.getObject(loadId); load.getSessions().remove(session); loadDao.saveObject(load); But, after launching, this code change nothing. What's the right way to remove an association?
upvote count: 10
has title: Hibernate: delete many-to-many association
accepted answer: http://stackoverflow.com/a/2783947
type: AnsweredQuestion
downvote count: 0
possible better answer: http://stackoverflow.com/a/2783769
tagged with: java
tagged with: hibernate
tagged with: orm
has answer: http://stackoverflow.com/a/2783769
has answer: http://stackoverflow.com/a/2783947
type: Question
tagged with: many-to-many
score: 10

http://stackoverflow.com/comment/2788229
has text: I agree in C# you never need to do something by hand. Unfortunately the Java builders are not that advanced. netbeans does a great job, (I have not worked with IntelliJ Idea) but still there is a long way to go. It is still a commin practice to build a swing GUI by hand.
comment on: http://stackoverflow.com/a/2719367
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2819116
has text: Thats great. It will be very helpful. Thanks
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/2775824
score: 0

http://stackoverflow.com/a/2733916
has comment: http://stackoverflow.com/comment/2761961
type: Answer
downvote count: 0
score: 5
has body: You should not call alert.show() in onCreateDialog. Your onCreateDIalog returns dialog variable that is actually null, you don't initialize it. Please take a look at samples\ApiDemos\src\com\example\android\apis\app\AlertDialogSamples.java, it is done correctly there. You may also read this http://developer.android.com/guide/topics/ui/dialogs.html on correct onCreateDialog usage. Here's the fixed version of your onCreateDialog: protected Dialog onCreateDialog(int id) { switch(id) { case DIALOG_DELETEDB: // do the work to define the pause Dialog AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Are you sure you want to exit?") .setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Favs.this.finish(); } }) .setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); return alert; } return null; } Another approach is to display dialog directly: public boolean onMenuItemSelected(int featureId, MenuItem item) { switch(item.getItemId()) { case DELETE_DB_ID: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Are you sure you want to exit?") .setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Favs.this.finish(); } }) .setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); return true; } return super.onMenuItemSelected(featureId, item); }
accepted answer of: http://stackoverflow.com/q/2733750
type: AcceptedAnswer
answers question: http://stackoverflow.com/q/2733750
upvote count: 5

http://stackoverflow.com/comment/2773684
type: Comment
comment on: http://stackoverflow.com/a/2744544
has text: Confusing to developers AND compilers, especially if the call isn't used in a context where a return value is required.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/2659631
score: 0
has text: According to https://bugs.eclipse.org/bugs/show_bug.cgi?id=112999, this is a pending enhancement request. Please vote for it. :) But still would be good to have it as a plugin...
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/2644440

http://stackoverflow.com/comment/2704676
comment on: http://stackoverflow.com/a/2684003
has text: An NPE is the result of a programmer error. Even a perfect coder can't control whether they get an IOException. That's the difference.
type: AnswerComment
type: Comment
score: 2

http://stackoverflow.com/q/2763091
tagged with: abstract-syntax-tree
has answer: http://stackoverflow.com/a/2763138
favorite count: 0
has body: As the title says, I want to parse some Java source code in Java. I'm pretty sure there are other java libraries that already perform this, but I couldn't find any.
upvote count: 8
answer count: 5
tagged with: parsing
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2763138
has answer: http://stackoverflow.com/a/2763106
has answer: http://stackoverflow.com/a/2763109
downvote count: 1
has answer: http://stackoverflow.com/a/2763902
type: Question
has answer: http://stackoverflow.com/a/2764000
score: 7
tagged with: java
possible better answer: http://stackoverflow.com/a/2763109
has title: Best way to parse Java in Java

http://stackoverflow.com/comment/2662731
type: Comment
score: 1
type: AnswerComment
has text: @Claudio: _maybe_ the name hasn't spread widely yet, but it's used in _Effective Java_, which I believe is a widely read book. In any case, let's just start using the name rather than not naming it at all. We're using the pattern (good or bad), so rather than leaving it nameless, we might as well call it something. And what do you know, some people already did.
comment on: http://stackoverflow.com/a/2637469

http://stackoverflow.com/comment/2658668
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2643049
has text: Thanx camickr, this is great way to do :)

tcp
type: Tag
tags question: http://stackoverflow.com/q/2716600
tags question: http://stackoverflow.com/q/2692319
tags question: http://stackoverflow.com/q/2653262
tags question: http://stackoverflow.com/q/2619082
tags question: http://stackoverflow.com/q/2749664
tag name: tcp

http://stackoverflow.com/q/2687279
tagged with: jboss
answer count: 2
has answer: http://stackoverflow.com/a/2729988
favorite count: 0
has comment: http://stackoverflow.com/comment/63899682
has title: Very basic running of drools 5, basic setup and quickstart
has answer: http://stackoverflow.com/a/3406269
possible better answer: http://stackoverflow.com/a/2729988
accepted answer: http://stackoverflow.com/a/3406269
tagged with: rules
type: AnsweredQuestion
upvote count: 2
score: 1
downvote count: 1
type: Question
has body: Is there a more comprehensive quick start for drools 5. I was attempting to run the simple Hello World .drl rule but I wanted to do it through an ant script, possibly with just javac/java: I get the following error: Note: I don't am running completely without Eclipse or any other IDE: Is there a more comprehensive quick start for drools 5. I was attempting to run the simple Hello World .drl rule but I wanted to do it through an ant script, possibly with just javac/java: I get the following error: Note: I don't am running completely without Eclipse or any other IDE: test: [java] Exception in thread "main" org.drools.RuntimeDroolsException: Unable to load d ialect 'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java:org.drools.rule .builder.dialect.java.JavaDialectConfiguration' [java] at org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuild erConfiguration.java:274) [java] at org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurati onMap(PackageBuilderConfiguration.java:259) [java] at org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConf iguration.java:176) [java] at org.drools.compiler.PackageBuilderConfiguration.&lt;init&gt;(PackageBuilderCo nfiguration.java:153) [java] at org.drools.compiler.PackageBuilder.&lt;init&gt;(PackageBuilder.java:242) [java] at org.drools.compiler.PackageBuilder.&lt;init&gt;(PackageBuilder.java:142) [java] at org.drools.builder.impl.KnowledgeBuilderProviderImpl.newKnowledgeBuilde r(KnowledgeBuilderProviderImpl.java:29) [java] at org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilder(Knowledg eBuilderFactory.java:29) [java] at org.berlin.rpg.rules.Rules.rules(Rules.java:33) [java] at org.berlin.rpg.rules.Rules.main(Rules.java:73) [java] Caused by: java.lang.RuntimeException: The Eclipse JDT Core jar is not in the classpath [java] at org.drools.rule.builder.dialect.java.JavaDialectConfiguration.setCompil er(JavaDialectConfiguration.java:94) [java] at org.drools.rule.b…
tagged with: drools
tagged with: java

http://stackoverflow.com/comment/66384607
has text: I have a problem with `Gson` --> here http://stackoverflow.com/questions/39535222/problems-with-gson-library
type: Comment
comment on: http://stackoverflow.com/a/19700319
type: AnswerComment
score: 0

http://stackoverflow.com/comment/62277173
type: Comment
comment on: http://stackoverflow.com/a/2869948
score: 0
type: AnswerComment
has text: @jazzdev : We are facing the same issue in our Drools framework. Could you please more elaborate like where you have added bytecode 49.0 ?

http://stackoverflow.com/q/2780038
has comment: http://stackoverflow.com/comment/2842061
answer count: 1
downvote count: 1
has answer: http://stackoverflow.com/a/2883179
type: AnsweredQuestion
score: 1
favorite count: 0
has title: Java/Python: Integration, problem with looping updating text
has body: Basically I have a script in Python that grabs the text from an open window using getWindowText() and outputs it to the screen. The python loops so as the text in the window changes, it outputs the changes, so the output of the python will always be up to date with the window text. I'm trying to access this text in my Java program by executing the python script as a process and reading the text it outputs using a buffered reader. For some reason this works fine for the first block of text, but will not read any more after this, it wont read any updates to the text as the python outputs it. Can someone shed some light on this? I'm about to try and use Jython, but I'd really like to know what the problem is here... try { Runtime r = Runtime.getRuntime(); Process p = r.exec("cmd /c getText.py"); BufferedReader br = new BufferedReader( new InputStreamReader(p.getInputStream())); int line; while (true) { line = br.read(); System.out.print((char) line); } } catch (Exception e) { e.printStackTrace(); }
type: Question
upvote count: 2
tagged with: python
accepted answer: http://stackoverflow.com/a/2883179
tagged with: java

http://stackoverflow.com/a/71416372
type: Answer
answers question: http://stackoverflow.com/q/2730044
has body: JOptionPane is closed by calling its setValue method (Speaking of dirty side effects)
score: 0

http://stackoverflow.com/a/61441284
answers question: http://stackoverflow.com/q/2748910
score: -1
upvote count: 0
has body: when we compile java file the .class file of that program is generated that .class file contain the byte code.That byte code is platform independent,byte code can run on any operating system using java virtual machine. platform independence not about only operating system it also about the hardware. When you run you java application on a 16-bit machine that you made on 32-bit, you do not have to worry about converting the data types according to the target system. You can run your app on any architecture and you will get the same result in each.
type: Answer
downvote count: 1

http://stackoverflow.com/a/2668352
has body: Change the JSON to this format.. { "root": { "accountId": "1000", "Items":{"Item":{"cost": 0.1,"debit": 0.1,"cost": 0.2,"debit": 0.2} } } }
answers question: http://stackoverflow.com/q/2649597
type: Answer
score: 0

http://stackoverflow.com/q/2719039
type: Question
tagged with: flash
answer count: 1
downvote count: 0
tagged with: upload
has title: looking to scan documents directly to be uploaded to a webpage
has answer: http://stackoverflow.com/a/2719124
favorite count: 0
has body: I was hoping to do this from a flash plugin, kind of how flash accesses the microphone or webcam but it doesn't seem possible. Is this going to be possible using Java, or ActiveX, or some other strategy that I haven't looked at yet? The idea is to do it without a client install, or at least something lightweight and browser and platform independent, (and possibly the moon on a stick as welll ;-))
type: UnansweredQuestion
upvote count: 1
score: 1
tagged with: java

http://stackoverflow.com/q/2752226
tagged with: reflection
downvote count: 0
linked to: http://stackoverflow.com/q/2752224
has answer: http://stackoverflow.com/a/2752249
has answer: http://stackoverflow.com/a/2752234
type: Question
linked to: http://stackoverflow.com/q/2725037
tagged with: java
upvote count: 6
linked to: http://stackoverflow.com/q/909000
answer count: 3
has body: Is there a way to know the inner classes that a Class has through Reflection in Java?
favorite count: 0
has answer: http://stackoverflow.com/a/2752232
accepted answer: http://stackoverflow.com/a/2752232
score: 6
possible better answer: http://stackoverflow.com/a/2752234
type: AnsweredQuestion
has title: Is there a way to get the list of InnerClasses through Reflection in Java?

http://stackoverflow.com/comment/98787806
score: 1
type: AnswerComment
has text: so "can't be written as a stream unless you know the whole document first" is not really true. Some preparation is needed, but I was able to stream to an open OutputStream without knowing the document contents in advance. In fact I was dynamically generating the contents.
type: Comment
comment on: http://stackoverflow.com/a/43532092

http://stackoverflow.com/comment/2802037
type: Comment
has text: Sorry folks, I tried numerous times to figure out how to put the code into proper code formatting...but failed miserably.
comment on: http://stackoverflow.com/a/2766970
score: 0
type: AnswerComment

http://stackoverflow.com/a/2701201
has body: You have to type, or cast thing to the subclass. So: Subclass thing = new Subclass(); or: ((Subclass) thing).specialMethod();
downvote count: 0
score: 1
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/2701182

http://stackoverflow.com/a/2629333
downvote count: 1
score: 1
has body: When running a GWT app deployed on a remote server, the client part of your app will have been translated into javascript so I do not think you will be able to debug this from IntelliJ. The server side part of your app will still be Java code. You should be able to start up this remote server with java debugging parameters (things like a transporttype and a port to listen to). From IntelliJ, you should be able to start up a remote debugging session using the same transporttype and port. If you look into remote debugging, you should be able to find how to do this.
answers question: http://stackoverflow.com/q/2629297
upvote count: 2
type: Answer

http://stackoverflow.com/a/2674905
answers question: http://stackoverflow.com/q/2674867
score: 0
has body: There are several problems here. First of all, if you need to add at the beginning of the list, you need to add at index 0, not 1. Furthermore, if you have JVM 1.5+, you should be using generics. List catalogue = new ArrayList&lt;Movie&gt;(); .. ... catalogue.add(movie1); catalogue.add(movie2);//or (0,movie2)
type: Answer

http://stackoverflow.com/a/2765189
has comment: http://stackoverflow.com/comment/2797622
has comment: http://stackoverflow.com/comment/2797681
type: AcceptedAnswer
downvote count: 0
has body: Note: this answer was made for the revisions 1 and 2 of the question. It's not an Awt error, it's a NullPointerException. Your field l is null, because on the moment you thought you created it, you actually masked it with a local variable. JPanel p = new JPanel(new GridLayout(2, 1)); JPanel l = new JPanel(new FlowLayout()); JPanel k = new JPanel(new FlowLayout()); Should be: p = new JPanel(new GridLayout(2, 1)); l = new JPanel(new FlowLayout()); k = new JPanel(new FlowLayout()); Read again the error, with the stack trace. It tells you which line is the problem, and the type of the error tells you what happened, in this case.
answers question: http://stackoverflow.com/q/2765127
has comment: http://stackoverflow.com/comment/2797776
type: Answer
upvote count: 6
accepted answer of: http://stackoverflow.com/q/2765127
score: 6

http://stackoverflow.com/comment/2659249
has text: Please correct "without" to "thus", it should read "...copying memory thus creating another instance of..."
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2644201
type: Comment

http://stackoverflow.com/a/2654873
upvote count: 3
has comment: http://stackoverflow.com/comment/2671840
has body: Or use java.sql.Timestamp. Calendar is kinda heavy,I would recommend against using it in production code. Joda is better. import java.sql.Timestamp; public class DateTest { /** * @param args */ public static void main(String[] args) { System.out.println(new Timestamp(System.currentTimeMillis())); } }
downvote count: 1
has comment: http://stackoverflow.com/comment/88913555
type: Answer
answers question: http://stackoverflow.com/q/2654025
score: 2

http://stackoverflow.com/comment/120237280
score: 0
has text: This was the case for me. Thanks it helped and saved my time
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/2605337

http://stackoverflow.com/comment/2705729
comment on: http://stackoverflow.com/a/2685298
score: 0
type: Comment
has text: I don't know where R.raw comes from unfortunately, I have no Android experience, but it doesn't sound like a local variable, so you could probably put it anywhere you want.
type: AnswerComment

http://stackoverflow.com/comment/2730081
has text: I've thought about Double Dispatch, but that gives me an infinite recursion. I'm probably not using it correctly though, please check the updated question.
type: Comment
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2706308

http://stackoverflow.com/a/2768150
type: Answer
answers question: http://stackoverflow.com/q/2768032
score: 4
has body: Yes. Displaceable b says what can be done to b. The compiler can (and does) check whether that method is available on that type (Displaceable) at compile time. How this is done is not necessarily clear at compile time. It's up to the implementation, at run-time, to just do it (move). At compile time, the promise (I can move!) is checked. At runtime, the code has to prove that it really can :) Even if Displaceable were a class and not an interface, and implemented move itself, the actual move called run-time would still be the implementation (if that implementation, Circle, would have overridden the Displaceable implementation). The only time there is a compile-time binding of a call (to e.g. move) to the actual implementation is when a method is defined as being static. That's also why static methods can't be defined in interfaces, as they don't hold implementation.
upvote count: 4
downvote count: 0

http://stackoverflow.com/comment/2723480
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2692324
has text: I currently am working around this by doing some careful analysis of existing objects in the getPermit method, but ideally I would rather use the beforePhaseSummary call.
score: 0

http://stackoverflow.com/q/2746062
tagged with: post
type: Question
answer count: 2
downvote count: 0
has title: Java: Read POST data from a socket on an HTTP server
has answer: http://stackoverflow.com/a/2746269
tagged with: httpwebrequest
favorite count: 0
upvote count: 1
tagged with: web-services
tagged with: http
has answer: http://stackoverflow.com/a/2746153
type: AnsweredQuestion
has body: I have a website (python/django) that needs to use a load of Java resources that may or may not be on the same server. Therefore I am writing a mini webserver in Java that will receive a request and then when processing is finished, POST some data back to a url on the site. I have got the java code receiving connections on sockets and responding with some simple HTML. My problem is that I will POST data to the Java server and that code needs to act on the data. How do I go about reading the data that is posted in the HTML request, if it is even possible. If not, is there any other way you would do this. If you think I am going about this in completely the wrong way then please tell me and I will consider another method, but after conversing with some Java developers, this seemed like the best way for what I was doing. Thanks
accepted answer: http://stackoverflow.com/a/2746269
score: 1
tagged with: java
possible better answer: http://stackoverflow.com/a/2746153

http://stackoverflow.com/comment/2635977
type: AnswerComment
has text: I doubt both your your claims. Can you cite sources?
type: Comment
comment on: http://stackoverflow.com/a/2623431
score: 0

http://stackoverflow.com/a/2601333
has comment: http://stackoverflow.com/comment/2613242
score: 0
has body: I solved this issue by using dependency version ranges to fetch the newest versions automatically. foo.xyzzy bar [1.0.0,2.0.0) It might make sense to use a version range such as [1.0,) to include the newest version after 1.0. The trick to make this work is to have dev and prod profiles that include and exclude the snapshot repos for your commons and to use hudson to automatically build projects when a dependency is re-built.
has comment: http://stackoverflow.com/comment/2617664
has comment: http://stackoverflow.com/comment/2612065
answers question: http://stackoverflow.com/q/2598614
type: Answer
has comment: http://stackoverflow.com/comment/2611339

http://stackoverflow.com/q/2625546
type: Question
upvote count: 51
possible better answer: http://stackoverflow.com/a/2627764
has answer: http://stackoverflow.com/a/2627764
answer count: 4
accepted answer: http://stackoverflow.com/a/2626960
has comment: http://stackoverflow.com/comment/2638511
tagged with: java
has comment: http://stackoverflow.com/comment/2638400
has answer: http://stackoverflow.com/a/2628352
has comment: http://stackoverflow.com/comment/5399214
score: 51
has comment: http://stackoverflow.com/comment/2638459
has comment: http://stackoverflow.com/comment/17473404
has comment: http://stackoverflow.com/comment/2639506
has answer: http://stackoverflow.com/a/2626960
has body: I have read somewhere that using the class instances as below is not a good idea as it might cause memory leaks. Can someone tell me if that is a valid statement? Or are there any problems using them this way? Map<Class<?>,String> classToInstance = new HashMap(); classToInstance.put(String.class,"Test obj");
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2625576
downvote count: 0
has title: Is using the Class instance as a Map key a best practice?
has comment: http://stackoverflow.com/comment/2640010
favorite count: 0

http://stackoverflow.com/comment/2703972
type: Comment
comment on: http://stackoverflow.com/a/2677614
has text: I sense something very wrong with this. Typically, a library would have no more than 3-4 jars. javax.jsp isn't related to ADF - it's something ADF depends on. Maven would handle these dependencies automatically.
type: AnswerComment
score: 0

http://stackoverflow.com/comment/114528804
has text: I wonder where this wrong meme (that java does not have pointers) came from. This created so much confusion. People which claimed this, should not be allowed to write software,
type: AnswerComment
comment on: http://stackoverflow.com/a/38942190
score: 0
type: Comment

http://stackoverflow.com/a/11660538
downvote count: 0
type: Answer
score: 25
has body: I have used the UAgentInfo.java class you can download here (http://code.google.com/p/mobileesp/source/browse/Java/UAgentInfo.java): private boolean isRequestComingFromAMobileDevice(final HttpServletRequest request){ // http://www.hand-interactive.com/m/resources/detect-mobile-java.htm final String userAgent = request.getHeader("User-Agent"); final String httpAccept = request.getHeader("Accept"); final UAgentInfo detector = new UAgentInfo(userAgent, httpAccept); return detector.detectMobileQuick(); } The UAgentInfo class has a bunch of methods to detect particular devices as well. Just replace detector.detectMobileQuick() for, for instance, detector.detectIphoneOrIpod(), detector.detectKindle(), etc. UPDATE: If you use Spring, you might want to use its native implementation instead. Here is an example: http://spring.io/guides/gs/device-detection/
upvote count: 25
answers question: http://stackoverflow.com/q/2707374

http://stackoverflow.com/comment/2818255
score: 0
has text: @FRotthowe: I'm using JUnit to write regression tests and wrapper tests for existing components of the legacy code. I don't have much of my own code. the problem is that I want to catch these internal failures, especially as people maintain the internal code.
type: QuestionComment
comment on: http://stackoverflow.com/q/2783007
type: Comment

http://stackoverflow.com/a/2611842
score: 4
answers question: http://stackoverflow.com/q/2611827
type: Answer
has body: Rendering HTML in Swing is problematic. Swing components have some native support for HTML but it's not even HTML4. It's (limited!) HTML 3.2. If you use a different desktop library API you'll have much better options WebKit for SWT (ver. 0.6) for the Eclipse Standard Widget Tookit is an excellent option. As the name suggests, it plugs the WebKit rendering engine (which powers Chrome and Safari) into SWT; Netbeans Platform may have some options too. You may also want to look at Flying Saucer, which is: An XML/XHTML/CSS 2.1 Renderer (in 100% Java)
upvote count: 4
downvote count: 0

http://stackoverflow.com/comment/2665973
type: Comment
has text: I will look into WorkManager, do you know of any examples for this?
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2649746

http://stackoverflow.com/comment/71762743
type: AnswerComment
has text: I cannot update the comment anymore, so: Idea says: `org.hibernate.Session`.
type: Comment
comment on: http://stackoverflow.com/a/8257729
score: 1

des
tags question: http://stackoverflow.com/q/2727005
type: Tag
tag name: des

http://stackoverflow.com/q/2609227
answer count: 5
has answer: http://stackoverflow.com/a/2609274
has title: Does Java support dynamic method invocation?
possible better answer: http://stackoverflow.com/a/2609274
has answer: http://stackoverflow.com/a/2609281
tagged with: dynamic
upvote count: 3
has answer: http://stackoverflow.com/a/2609270
has answer: http://stackoverflow.com/a/33726849
type: AnsweredQuestion
score: 3
has body: class A { void F() { System.out.println("a"); }} class B extends A { void F() { System.out.println("b"); }} public class X { public static void main(String[] args) { A objA = new B(); objA.F(); } } Here, F() is being invoked dynamically, isn't it? This article says: ... the Java bytecode doesn’t support dynamic method invocation. There are three supported invocations modes : invokestatic, invokespecial, invokeinterface or invokevirtual. These modes allows to call methods with known signature. We talk of strongly typed language. This allows to to make some checks directly at compile time. On the other side, the dynamic languages use dynamic types. So we can call a method unknown at the compile time, but that’s completely impossible with the Java bytecode. What am I missing?
has comment: http://stackoverflow.com/comment/2619726
tagged with: java
type: Question
tagged with: bytecode
downvote count: 0
accepted answer: http://stackoverflow.com/a/2609270
tagged with: dynamic-method
has comment: http://stackoverflow.com/comment/2619657
favorite count: 0
has answer: http://stackoverflow.com/a/2609309

http://stackoverflow.com/q/2714985
favorite count: 0
has title: Which use cases make temporary JMS queues a better choice than persistent queues?
accepted answer: http://stackoverflow.com/a/2716985
type: AnsweredQuestion
score: 3
upvote count: 3
tagged with: java
type: Question
answer count: 2
has body: When you are designing a JMS application, which use cases make you pick temporary queues over persistent queues? We use temporary queues for response messages. We're having some issues maintaining connections to the temp queues, though, so I am testing persistent response queues, instead. One clear disadvantage of persistent queues is that your application has to "know" about them beforehand. If that's not a big deal, though, are there use cases where temp queues are the obvious choice?
downvote count: 0
has answer: http://stackoverflow.com/a/2716985
has answer: http://stackoverflow.com/a/2716814
possible better answer: http://stackoverflow.com/a/2716814
tagged with: jms

http://stackoverflow.com/a/2640904
score: 0
type: Answer
answers question: http://stackoverflow.com/q/2637377
has body: Yet another way to misuse interfaces? There are no obvious performance gain using interfaces. Conversely, it may have a negative performance impact due to RTTI (Based on your compiler's features)

http://stackoverflow.com/a/16077527
upvote count: 3
has body: Steps that help me to remove this error remove user libraries(external libraries). clean the project again add the external library build the project run the project. Hope this will be helpful to you. Thanks.
downvote count: 0
answers question: http://stackoverflow.com/q/2687773
type: Answer
score: 3

http://stackoverflow.com/a/2710595
score: 0
has body: It's rare that you would need to call either since its usually appropriate to let the user's keyboard/mouse actions determine focus. But transferFocus send focus away from your component and requestFocus brings focus to your component.
type: Answer
answers question: http://stackoverflow.com/q/2710564

http://stackoverflow.com/a/2616479
upvote count: 5
answers question: http://stackoverflow.com/q/2616448
type: Answer
has comment: http://stackoverflow.com/comment/2628761
downvote count: 0
has comment: http://stackoverflow.com/comment/2628849
has body: I am using SWT. Try it , it is really very nice java gui framework, eclipse is build around it. You can use also this plugin for eclipse to create your forms Instantiations.
has comment: http://stackoverflow.com/comment/2633562
score: 5

http://stackoverflow.com/comment/2701204
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2681509
has text: But how to get an Instrumentation instance?
type: AnswerComment

http://stackoverflow.com/comment/2795765
type: Comment
has text: If you plan to do something against the original design, you may modify its source code. Well, why not follow the design?
comment on: http://stackoverflow.com/q/2763416
score: 0
type: QuestionComment

http://stackoverflow.com/a/2608469
accepted answer of: http://stackoverflow.com/q/2608376
has body: The easiest way would be String query = "select LastModified from CacheTable where url = '" + url +"'"; You should use bind variables though: String query = "select LastModified from CacheTable where url = ?"; prepStmt = conn.prepareStatement(query); prepStmt.setString(1, url); rs = prepStmt.executeQuery();
has comment: http://stackoverflow.com/comment/2618778
score: 15
upvote count: 15
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2618746
answers question: http://stackoverflow.com/q/2608376
type: Answer
has comment: http://stackoverflow.com/comment/2618719

http://stackoverflow.com/comment/104602931
comment on: http://stackoverflow.com/a/31104211
type: Comment
score: 2
has text: @thisisananth a benchmark (if we dare to call the undocumented methodology a benchmark) of an operation that searches for a maximum in an `int[]` array, is entirely unrelated to an operation converting a collection of strings to lower case. A list of boxed ints would be a `List<Integer>`, by the way, but that linked article uses `int[]`, which is an array of primitive ints. And since that will yield an `IntStream`, a serious developer would use `max()` rather than `reduce(Integer.MIN_VALUE, Math::max)` for that.
type: AnswerComment

http://stackoverflow.com/a/2865041
type: Answer
answers question: http://stackoverflow.com/q/2686264
downvote count: 0
score: 1
has body: I began learning Android with an understanding of JavaScript from front end web development. I grabbed the Wrox Android book and used the tutorials at http://java.sun.com/docs/books/tutorial/index.html to help me through the Java parts. I suggest diving head first into Android and going back to Java reference/tutorials where needed.
upvote count: 1

http://stackoverflow.com/a/16196119
downvote count: 16
upvote count: 4
score: -12
has comment: http://stackoverflow.com/comment/72240983
has comment: http://stackoverflow.com/comment/76427463
type: Answer
answers question: http://stackoverflow.com/q/2758224
has body: assert is a keyword. It was introduced in JDK 1.4. The are two types of asserts Very simple assert statements Simple assert statements. By default all assert statements will not be executed. If an assert statement receives false, then it will automatically raise an assertion error.

http://stackoverflow.com/a/2622291
type: Answer
has body: It is generic parameter. If you write then string s = ...; clone(s); // will be expanded to string clone(string x)
answers question: http://stackoverflow.com/q/2622259
score: 0

http://stackoverflow.com/a/2773076
downvote count: 0
has comment: http://stackoverflow.com/comment/2806886
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/2772836
score: 1
has body: Although Set doesn't provide a method for a reverse iterator, Deque does. You can use descendingIterator() for an iterator in reverse order and iterator(), for an iterator in forwards order. (You can create a Deque from a Set via Deque&lt;T&gt; deque = new LinkedList&lt;T&gt;(set), where set is your Set and T the generic type you're using.)

http://stackoverflow.com/a/2622276
score: 0
answers question: http://stackoverflow.com/q/2622240
has body: If the method is not static then the Student's method will be called as others mentioned. Just be careful that if the method speak is static, then the Person's method will be called. This is called hiding.
type: Answer

http://stackoverflow.com/a/28149269
upvote count: 18
has body: The best approach would be to map a unique ID to each enum type, thus avoiding the pitfalls of ORDINAL and STRING. See this post which outlines 5 ways you can map an enum. Taken from the link above: 1&amp;2. Using @Enumerated There are currently 2 ways you can map enums within your JPA entities using the @Enumerated annotation. Unfortunately both EnumType.STRING and EnumType.ORDINAL have their limitations. If you use EnumType.String then renaming one of your enum types will cause your enum value to be out of sync with the values saved in the database. If you use EnumType.ORDINAL then deleting or reordering the types within your enum will cause the values saved in the database to map to the wrong enums types. Both of these options are fragile. If the enum is modified without performing a database migration, you could jeopodise the integrity of your data. 3. Lifecycle Callbacks A possible solution would to use the JPA lifecycle call back annotations, @PrePersist and @PostLoad. This feels quite ugly as you will now have two variables in your entity. One mapping the value stored in the database, and the other, the actual enum. 4. Mapping unique ID to each enum type The preferred solution is to map your enum to a fixed value, or ID, defined within the enum. Mapping to predefined, fixed value makes your code more robust. Any modification to the order of the enums types, or the refactoring of the names, will not cause any adverse effects. 5. Using Java EE7 @Convert If you are using JPA 2.1 you have the option to use the new @Convert annotation. This requires the creation of a converter class, annotated with @Converter, inside which you would define what values are saved into the database for each enum type. Within your entity you would then annotate your enum with @Convert. My preference: (Number 4) The reason why I prefer to define my ID's within the enum as oppose to using a converter, is good encapsulation. Only the enum type should know of its ID, and only the entity s…
answers question: http://stackoverflow.com/q/2751733
downvote count: 0
score: 18
has comment: http://stackoverflow.com/comment/68583235
type: Answer

http://stackoverflow.com/comment/2690965
type: QuestionComment
score: 0
has text: I don't think the player should own the party; the player belongs to a party, the same as NPCs do.
type: Comment
comment on: http://stackoverflow.com/q/2672172

http://stackoverflow.com/q/2784063
type: UnansweredQuestion
tagged with: swing
has answer: http://stackoverflow.com/a/2784098
score: 4
tagged with: java
has comment: http://stackoverflow.com/comment/2819361
has comment: http://stackoverflow.com/comment/2819331
has answer: http://stackoverflow.com/a/2784115
type: Question
upvote count: 4
tagged with: graphics
has body: The problem is how can I delete the old lines? I mean, make only the current x and y lines appear on the screen, make the intersection between both lines "follow" the mouse pointer. This is the updated code: import javax.swing.*; import javax.*; import java.awt.*; import java.awt.Color; import java.awt.Graphics.*; import java.awt.event.*; import javax.swing.UIManager; public class SimpleGUI extends JFrame { public SimpleGUI() { this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) ; } public void go() { Drawpanel = new Mypanel(); JFrame frame = new JFrame("Chasing Line"); JButton mybutton1 = new JButton("Please"); JButton mybutton2 = new JButton("Help"); JButton mybutton3 = new JButton("Me!!"); Drawpanel.add(mybutton1); Drawpanel.add(mybutton2); Drawpanel.add(mybutton3); frame.getContentPane().add(BorderLayout.CENTER, Drawpanel); frame.setSize(300,300); frame.setVisible(true); Drawpanel.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() { public void mouseMoved(java.awt.event.MouseEvent evt) { DrawpanelMouseMoved(evt); } }); } public void DrawpanelMouseMoved(java.awt.event.MouseEvent evt) { xpos=evt.getX(); ypos=evt.getY(); System.out.println("Coordinates : X :"+ xpos+"Y: "+ypos); Drawpanel.paintImage(xpos,ypos); } class Mypanel extends JPanel { public void paintImage(int xpost,int ypost){ Graphics d = getGraphics(); d.clearRect(0,0, this.getWidth(), this.getHeight()); d.setColor(Color.black); d.drawLine(xpost, 0, xpost, this.getHeight()); d.setColor(Color.red); d.drawLine(0, ypost, this.getWidth(),ypost); this.validate(); } } // end the inner class public static void main(String[] args){ try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch(Exception e) { System.err.println("Look and feel not set"); } SimpleGUI win = new SimpleGUI(); win.go(); } Mypanel Drawpanel; private int xpos=0; private int ypos=0; } // close SimpleGUI class The question is how can I keep those 3 buttons with out altering their state?
answer count: 3
downvote count: 0
has title: How to delete Drawn Line in java?
has answer: http://stackoverflow.com/a/2784511
favorite count: 0

http://stackoverflow.com/q/2719936
has answer: http://stackoverflow.com/a/2720069
upvote count: 2
score: 2
type: AnsweredQuestion
tagged with: rmi
tagged with: java
has answer: http://stackoverflow.com/a/2772536
has title: java.security.AccessControlException: access denied Exception
type: Question
has body: I'm trying to do a simple program for RMI. But, I'm getting the following exception while running the line Naming.rebind("interfacename",Remoteserverobject); java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve) My Code is as follows: public static void main(String[] args) throws Exception { if(System.getSecurityManager()==null) { System.setSecurityManager(new RMISecurityManager()); } Remoteserver objremoteserver=new Remoteserver(); objremoteserver.setmsg("Hello! How are you?"); System.out.println(objremoteserver.getmsg()); try { Naming.rebind("Remotemethod", objremoteserver); System.out.println("Server Started"); } catch(RemoteException re) { System.out.println(re.getLocalizedMessage()); } finally { System.out.println("Unknown Exception Occured!!!!"); } } How to overcome this problem. Thanks in advance
downvote count: 0
possible better answer: http://stackoverflow.com/a/2720426
has answer: http://stackoverflow.com/a/2720426
answer count: 3
accepted answer: http://stackoverflow.com/a/2772536
favorite count: 0

http://stackoverflow.com/a/5979031
type: Answer
upvote count: 14
score: 14
has body: If all you want to do is get rid of invalid hostname errors you can just do: HttpClient httpClient = new DefaultHttpClient(); SSLSocketFactory sf = (SSLSocketFactory)httpClient.getConnectionManager() .getSchemeRegistry().getScheme("https").getSocketFactory(); sf.setHostnameVerifier(new AllowAllHostnameVerifier());
has comment: http://stackoverflow.com/comment/7226216
downvote count: 0
answers question: http://stackoverflow.com/q/2703161

http://stackoverflow.com/q/2740452
type: Question
has body: I need to have a file for database configuration outside of EAR file of my EJB application. Even if I define a datasource and call it via JNDI, I still have some properties that I want to change, like hibernate.dialect or hibernate.show_sql, for example. I tried using: &lt;property name="hibernate.ejb.cfgfile" value="some-file.xml" /&gt; and it works fine when some-file.xml is in jar file, but how to call it from another location. I tried file:/// but didn´t work. thanks
answer count: 1
tagged with: jpa
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2740751
type: UnansweredQuestion
score: 1
tagged with: java
tagged with: hibernate
tagged with: orm
upvote count: 1
has title: How to use an external file for database configuration in EJB environment

http://stackoverflow.com/q/2694005
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/2715756
score: 3
accepted answer: http://stackoverflow.com/a/2694042
has comment: http://stackoverflow.com/comment/2715762
has body: I can't figure out how to write a Binary Search Tree to file recursively. I open a BufferWriter with the file to wrtie too, in the Tree class. I then send the BufferWriter to the Node class to traverse the tree inorder and write to file. But it doesn't work. public void write(String filePath) { if(root != null) { try { BufferedWriter out = new BufferedWriter(new FileWriter(filePath)); root.write(out); } catch (IOException e) { } } } public void write(BufferedWriter out) { if (this.getLeft() != null) this.getLeft().write(out); out.write(this.data()); if (this.getRight() != null) this.getRight().write(out); }
answer count: 1
downvote count: 0
favorite count: 0
has title: Write to file. (Binary Search Tree)
tagged with: binary-search-tree
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2694042
upvote count: 3

http://stackoverflow.com/q/2751633
has answer: http://stackoverflow.com/a/2751901
type: Question
has title: Why doesn't linking work in my Xtext-based DSL?
possible better answer: http://stackoverflow.com/a/2751901
tagged with: eclipse
tagged with: eclipse-emf
answer count: 2
has answer: http://stackoverflow.com/a/2755285
accepted answer: http://stackoverflow.com/a/2755285
upvote count: 1
favorite count: 0
tagged with: dsl
tagged with: xtext
type: AnsweredQuestion
downvote count: 0
has body: The following is the Xtext grammar for my DSL. Model: variableTypes=VariableTypes predicateTypes=PredicateTypes variableDeclarations= VariableDeclarations rules=Rules; VariableType: name=ID; VariableTypes: 'var types' (variableTypes+=VariableType)+; PredicateTypes: 'predicate types' (predicateTypes+=PredicateType)+; PredicateType: name=ID '(' (variableTypes+=[VariableType|ID])+ ')'; VariableDeclarations: 'vars' (variableDeclarations+=VariableDeclaration)+; VariableDeclaration: name=ID ':' type=[VariableType|ID]; Rules: 'rules' (rules+=Rule)+; Rule: head=Head ':-' body=Body; Head: predicate=Predicate; Body: (predicates+=Predicate)+; Predicate: predicateType=[PredicateType|ID] '(' (terms+=Term)+ ')'; Term: variable=Variable; Variable: variableDeclaration=[VariableDeclaration|ID]; terminal WS: (' ' | '\t' | '\r' | '\n' | ',')+; And, the following is a program in the above DSL. var types Node predicate types Edge(Node, Node) Path(Node, Node) vars x : Node y : Node z : Node rules Path(x, y) :- Edge(x, y) Path(x, y) :- Path(x, z) Path(z, y) The following is my subclass of the generated Switch class that demonstrates the getPredicateType() returns null on a Predicate node. public class ModelPrinter extends MyDSLSwitch&lt;Object&gt; { protected Object visitChildren(EObject object) { for (EObject eobj : object.eContents()) { doSwitch(eobj); } return object; } @Override public Object casePredicate(Predicate object) { System.out.println(object.getPredicateType()); return object; } @Override public Object defaultCase(EObject object) { return visitChildren(object); } } When I used the ModelPrinter class to traverse the EMF object model corresponding to the above program, I realized that the nodes are not linked together properly. For example, the getPredicateType() method on a Predicate node returns null. Having read the Xtext user's guide, my impression is that the Xtext default linking semantics should work for my DSL. But, for some reason, the AST nodes of my DSL don't get li…
score: 1
tagged with: java

http://stackoverflow.com/q/2739539
tagged with: java
has comment: http://stackoverflow.com/comment/2768132
possible better answer: http://stackoverflow.com/a/13603840
has title: Starting memory allocation for JVM
type: Question
has answer: http://stackoverflow.com/a/2739587
upvote count: 3
accepted answer: http://stackoverflow.com/a/2739605
tagged with: jvm
favorite count: 0
has answer: http://stackoverflow.com/a/13603840
has body: I'm beginning use the -Xmx option on the java command to allow my processes to use a little more memory (256Mb, though I think I'm currently using less than 128Mb). I've also noticed the -Xms option for starting memory, with a default value of 2Mb. What should I set this value to and why? Reference: Java
has answer: http://stackoverflow.com/a/2739605
answer count: 4
tagged with: jvm-arguments
has answer: http://stackoverflow.com/a/2739786
type: AnsweredQuestion
score: 3
downvote count: 0

http://stackoverflow.com/q/2755492
upvote count: 1
type: Question
has answer: http://stackoverflow.com/a/2755517
has title: Convert hexadecimal notation into latitudinal hours and minutes
answer count: 3
possible better answer: http://stackoverflow.com/a/2755509
has answer: http://stackoverflow.com/a/2755510
downvote count: 0
favorite count: 0
tagged with: hex
has answer: http://stackoverflow.com/a/2755509
has comment: http://stackoverflow.com/comment/2786747
type: AnsweredQuestion
has body: Given: 0x12E7 represents 48°39' 0x3026 represents 123°26' What is the most efficient way to convert the representation of those latitudes into two variables: hours minutes Where the first example would be: hours = 48 minutes = 39 And the second example: hours = 123 minutes = 26 Edit Latitude is an int.
accepted answer: http://stackoverflow.com/a/2755517
score: 1
tagged with: java

http://stackoverflow.com/a/2691780
downvote count: 0
has comment: http://stackoverflow.com/comment/2713265
type: Answer
has comment: http://stackoverflow.com/comment/2713052
has comment: http://stackoverflow.com/comment/2713148
answers question: http://stackoverflow.com/q/2691730
upvote count: 4
score: 4
has comment: http://stackoverflow.com/comment/2714335
has comment: http://stackoverflow.com/comment/2713198
has body: First, you need to connect to a database, then read data from it, then massage the result into JList. To connect to oracle from Java you need to use JDBC, tutorial for which is conveniently located here: http://java.sun.com/docs/books/tutorial/jdbc/index.html. Then once you have the data, you need to put this into a JList, which has setListData method, which will do all the magic. While iterating over the data from JDBC you just need to make sure you're putting the output of your SQL query into a Vector, documented here: http://java.sun.com/j2se/1.4.2/docs/api/java/util/Vector.html.

http://stackoverflow.com/comment/2715682
comment on: http://stackoverflow.com/a/2693920
type: Comment
has text: In sink or in sync? Keeping your data structures with the dirty dishes clogs up the garbage collector with food particles...or something... :D
score: 3
type: AnswerComment

http://stackoverflow.com/q/2701357
has answer: http://stackoverflow.com/a/2701792
accepted answer: http://stackoverflow.com/a/2701792
type: AnsweredQuestion
has body: In Facebook: How to get User's list_ of_friends_ ID when User is offline[not Sign In]. We are Integrating facebook application in our website. Our website development in Java's GWT[Googlw Web Toolkit] FrameWork. We are refering "Gwittit" sample code We open facebook account for our website and want to show all users[friends] photo conected to Website's FACEBOOK account when FB A/C is offline [not sign in]. We have used apiclient.getFriendList() in that we get list of all user id [with photo]connected to Our website's fb a/c.But Problem is that we have to sign in first and we don't want that Is there any way to solve this problem?
possible better answer: http://stackoverflow.com/a/2713091
tagged with: java
has answer: http://stackoverflow.com/a/2713091
answer count: 2
score: 0
tagged with: facebook
has title: In Facebook: How to get User's list_ of_friends_ ID when User is offline[not Sign In]
type: Question

http://stackoverflow.com/a/3109912
has comment: http://stackoverflow.com/comment/8112877
upvote count: 9
has comment: http://stackoverflow.com/comment/8127084
has comment: http://stackoverflow.com/comment/7995126
downvote count: 0
score: 9
type: Answer
answers question: http://stackoverflow.com/q/2643791
has body: The "correct" way according to the Java EE architecture would be to have a JCA connector to do inbound/outbound connection with the SMTP server. The JCA connector can do whatever you want, including threading and connection to external systems with sockets. Actually JMS is just a special kind of JCA connector that connects to JMS broker and delivers message to "regular" MDB. A JCA connector can then poll the SMTP server and delivers the message to a custom MDB. The best document about JCA is Creating Resource Adapters with J2EE Connector Architecture 1.5, and it does actually use the example of email delivery. Luck you :) I suggest you have a look at it. The code can be found as part of the Java EE samples and uses JavaMail, but I don't know if it's production ready. Related: Java EE architecture suggestions for a service/daemon? Java EE application which listen to a socket request.
has comment: http://stackoverflow.com/comment/52786136

oop
tags question: http://stackoverflow.com/q/2683735
tags question: http://stackoverflow.com/q/2777701
tags question: http://stackoverflow.com/q/2599440
tags question: http://stackoverflow.com/q/2744806
tags question: http://stackoverflow.com/q/2752529
tags question: http://stackoverflow.com/q/2747721
tags question: http://stackoverflow.com/q/2777678
tags question: http://stackoverflow.com/q/2758474
tags question: http://stackoverflow.com/q/2637912
tags question: http://stackoverflow.com/q/2685626
tags question: http://stackoverflow.com/q/2768748
tag name: oop
tags question: http://stackoverflow.com/q/2693329
tags question: http://stackoverflow.com/q/2609236
tags question: http://stackoverflow.com/q/2601286
tags question: http://stackoverflow.com/q/2601639
tags question: http://stackoverflow.com/q/2652295
tags question: http://stackoverflow.com/q/2606624
tags question: http://stackoverflow.com/q/2601616
tags question: http://stackoverflow.com/q/2699774
tags question: http://stackoverflow.com/q/2672172
tags question: http://stackoverflow.com/q/2662043
tags question: http://stackoverflow.com/q/2651819
tags question: http://stackoverflow.com/q/2723899
tags question: http://stackoverflow.com/q/2659496
tags question: http://stackoverflow.com/q/2783135
tags question: http://stackoverflow.com/q/2717348
tags question: http://stackoverflow.com/q/2681359
tags question: http://stackoverflow.com/q/2755142
tags question: http://stackoverflow.com/q/2719107
tags question: http://stackoverflow.com/q/2758879
tags question: http://stackoverflow.com/q/2664687
tags question: http://stackoverflow.com/q/2712445
tags question: http://stackoverflow.com/q/2726119
tags question: http://stackoverflow.com/q/2721419
tags question: http://stackoverflow.com/q/2773717
tags question: http://stackoverflow.com/q/2674323
tags question: http://stackoverflow.com/q/2676078
type: Tag
tags question: http://stackoverflow.com/q/2752717

linux
tags question: http://stackoverflow.com/q/2618507
tags question: http://stackoverflow.com/q/2761928
tags question: http://stackoverflow.com/q/2724725
tags question: http://stackoverflow.com/q/2702132
tags question: http://stackoverflow.com/q/2775799
tags question: http://stackoverflow.com/q/2694443
tags question: http://stackoverflow.com/q/2732414
tags question: http://stackoverflow.com/q/2776780
tags question: http://stackoverflow.com/q/2601146
tags question: http://stackoverflow.com/q/2617762
type: Tag
tags question: http://stackoverflow.com/q/2690768
tags question: http://stackoverflow.com/q/2689453
tags question: http://stackoverflow.com/q/2707793
tags question: http://stackoverflow.com/q/2717936
tags question: http://stackoverflow.com/q/2643179
tag name: linux
tags question: http://stackoverflow.com/q/2601124
tags question: http://stackoverflow.com/q/2772310
tags question: http://stackoverflow.com/q/2691509
tags question: http://stackoverflow.com/q/2757043
tags question: http://stackoverflow.com/q/2666041
tags question: http://stackoverflow.com/q/2746334
tags question: http://stackoverflow.com/q/2636144
tags question: http://stackoverflow.com/q/2613674
tags question: http://stackoverflow.com/q/2648110

http://stackoverflow.com/a/31660211
answers question: http://stackoverflow.com/q/2670956
has body: There's two simple answers to the question. This is the "Professional way": //This just terminates the program. System.exit(0); This is a more clumsier way: //This just terminates the program, just like System.exit(0). return;
type: Answer
upvote count: 3
downvote count: 3
has comment: http://stackoverflow.com/comment/60867677
score: 0

http://stackoverflow.com/a/40714946
has comment: http://stackoverflow.com/comment/68657360
answers question: http://stackoverflow.com/q/2642777
downvote count: 0
has body: Just adding -Dtrust_all_cert=true to VM arguments should do. This argument tells java to ignore certificate checks.
type: Answer
score: 2
upvote count: 2

http://stackoverflow.com/q/2642700
downvote count: 0
linked to: http://stackoverflow.com/q/6616055
has answer: http://stackoverflow.com/a/2643243
has title: Java.lang.reflect.Proxy returning another proxy from invocation results in ClassCastException on assignment
tagged with: proxy
score: 7
favorite count: 0
has answer: http://stackoverflow.com/a/39523486
has body: So I'm playing with geotools and I thought I'd proxy one of their data-access classes and trace how it was being used in their code. I coded up a dynamic proxy and wrapped a FeatureSource (interface) in it and off it went happily. Then I wanted to look at some of the transitive objects returned by the featureSource as well, since the main thing a FeatureSource does is return a FeatureCollection (FeatureSource is analogous to a sql DataSource and featurecollection to an sql statement). in my invocationhandler I just passed the call through to the underlying object, printing out the target class/method/args and result as I went, but for calls that returned a FeatureCollection (another interface), I wrapped that object in my proxy (the same class but a new instance, shouldn't matter should it?) and returned it. BAM! Classcast exception: java.lang.ClassCastException: $Proxy5 cannot be cast to org.geotools.feature.FeatureCollection at $Proxy4.getFeatures(Unknown Source) at MyClass.myTestMethod(MyClass.java:295) the calling code: FeatureSource&lt;SimpleFeatureType, SimpleFeature&gt; featureSource = ... // create the FS featureSource = (FeatureSource&lt;SimpleFeatureType, SimpleFeature&gt;) FeatureSourceProxy.newInstance(featureSource, features); featureSource.getBounds();// ok featureSource.getSupportedHints();// ok DefaultQuery query1 = new DefaultQuery(DefaultQuery.ALL); FeatureCollection&lt;SimpleFeatureType, SimpleFeature&gt; results = featureSource.getFeatures(query1); //&lt;- explosion here the Proxy: public class FeatureSourceProxy implements java.lang.reflect.InvocationHandler { private Object target; private List&lt;SimpleFeature&gt; features; public static Object newInstance(Object obj, List&lt;SimpleFeature&gt; features) { return java.lang.reflect.Proxy.newProxyInstance( obj.getClass().getClassLoader(), obj.getClass().getInterfaces(), new FeatureSourceProxy(obj, features) ); } private FeatureSourceProxy(Object obj, List&lt;SimpleFeature&gt; features) { this.tar…
tagged with: classcastexception
possible better answer: http://stackoverflow.com/a/39523486
accepted answer: http://stackoverflow.com/a/2643243
type: AnsweredQuestion
tagged with: reflection
tagged with: java
upvote count: 7
tagged with: geotools
type: Question
answer count: 2

http://stackoverflow.com/a/2736843
has body: You could also write the object's data into temporary Strings and ints, and pass them to the activity. Of course that way, you get the data transported, but not the object itself. But if you just want to display them, and not use the object in another method or something like that, it should be enough. I did it the same way to just display data from one object in another activity. String fName_temp = yourObject.getFname(); String lName_temp = yourObject.getLname(); String age_temp = yourObject.getAge(); String address_temp = yourObject.getAddress(); Intent i = new Intent(this, ToClass.class); i.putExtra("fname", fName_temp); i.putExtra("lname", lName_temp); i.putExtra("age", age_temp); i.putExtra("address", address_temp); startActivity(i); You could also pass them in directly instead of the temp ivars, but this way it's clearer, in my opinion. Additionally, you can set the temp ivars to null so that they get cleaned by the GarbageCollector sooner. Good luck! On a side note: override toString() instead of writing your own print method. As mentioned in the comments below, this is how you get your data back in another activity: String fName = getIntent().getExtras().getInt("fname");
has comment: http://stackoverflow.com/comment/38768703
downvote count: 3
score: 40
upvote count: 43
has comment: http://stackoverflow.com/comment/38979765
answers question: http://stackoverflow.com/q/2736389
has comment: http://stackoverflow.com/comment/10809713
has comment: http://stackoverflow.com/comment/52328559
has comment: http://stackoverflow.com/comment/52342689
type: Answer
has comment: http://stackoverflow.com/comment/4357909

http://stackoverflow.com/a/2676239
has comment: http://stackoverflow.com/comment/84190684
downvote count: 5
has comment: http://stackoverflow.com/comment/139522141
has body: Because the lookup table index must be 32 bits.
answers question: http://stackoverflow.com/q/2676210
has comment: http://stackoverflow.com/comment/2695161
has comment: http://stackoverflow.com/comment/117362570
type: Answer
upvote count: 11
has comment: http://stackoverflow.com/comment/2695697
score: 6

http://stackoverflow.com/a/2739619
answers question: http://stackoverflow.com/q/2739596
has comment: http://stackoverflow.com/comment/2768248
has body: You're trying to send mail over a connection that expects an encrypted connection (TLS in this case). This sun forum has several solutions that you might try: http://forums.sun.com/thread.jspa?threadID=617974
type: Answer
score: 0

http://stackoverflow.com/comment/2794325
type: Comment
has text: Oscar, did you see my updated question? Does it support repeated values?
type: AnswerComment
comment on: http://stackoverflow.com/a/2762137
score: 0

http://stackoverflow.com/comment/21738711
comment on: http://stackoverflow.com/a/2713013
score: 0
type: Comment
has text: @avithan this is relevant to me (and I have not seen what you report) - have you gotten detailed information yet?
type: AnswerComment

http://stackoverflow.com/comment/2691261
comment on: http://stackoverflow.com/a/2645251
type: Comment
has text: One more question i have is suppose i buy a domain over internet, then how i can i achieve this configuration ? i have temporarily locally configured this DNS but what if i want each node in internet to resolve this pattern , how can this reflect all DNS ?
score: 0
type: AnswerComment

http://stackoverflow.com/q/2778386
upvote count: 1
downvote count: 1
type: Question
has answer: http://stackoverflow.com/a/2778418
has answer: http://stackoverflow.com/a/2778415
has answer: http://stackoverflow.com/a/2778427
has title: Java Custom exception throw behaves differently between different Projects
has comment: http://stackoverflow.com/comment/2835288
score: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2798808
answer count: 5
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2798187
has body: I am attempting to call the following in my code: public void checkParticleLightRestriction(Particle parent) throws LightException { if ( parent == null ) { throw new LightException("quantum-particle-restrict.23", this); } In one Project the exception is thrown and the effect is similar to calling "return" whereby I am returned back to the point immediately succeeding where this method was called. However in another Project I get thrown completed out of the current package and to a point way prior to the point preceeding this method. It likes instead of being kicked out of a bar I am being deported all the way out of the country. My option are the wrap the throw in a try / catch but I am wondering why this difference in behaviour beween the 2 projects ? 09 May 2009 I've been playing with your suggestions but I still haven't solved this. The call to throw the custom exception simply does not appear to be called in this particular project whether the Exception class extends RuntimeException or just Exception. public class LightException extends Exception { ...etc public LightException(String errorCode, Object object) { super(errorCode == null ? null : errorStrings.getString(errorCode)); this.errorCode = errorCode; this.invalidObject = object; } public LightException(String errorCode, Object object, Exception exception) { this(errorCode, object); add(exception); } ... } Any ideas appreciated.
tagged with: java

http://stackoverflow.com/a/2639529
answers question: http://stackoverflow.com/q/2623726
score: 1
upvote count: 1
has body: ABSE and AtomWeaver form a code generation and model-driven-development framework where you can easily implement what you want. ABSE is a new methodology where you compose your code generator from smaller bits (called Atoms) and AtomWaver is an straightforward IDE that lets you implement, manipulate and use your generator models. It also allows non-programmers to build programs/configurations/whatever, made from already-built parts (Atoms you have previously prepared). This project is just being publicly launched now, and an alpha version is being made available now. ABSE is open, and AtomWeaver is free for personal and commercial use. Get more info here : http://www.abse.info (Disclaimer: I am the project lead)
has comment: http://stackoverflow.com/comment/2668150
downvote count: 0
type: Answer

http://stackoverflow.com/comment/93643035
type: QuestionComment
has text: How do you use nextval.org? The website is a bit strange and I don't know what's about. Is it some Unix command? Or some cloud service?
score: 0
comment on: http://stackoverflow.com/q/2671858
type: Comment

date
tags question: http://stackoverflow.com/q/2689379
tags question: http://stackoverflow.com/q/2692445
tags question: http://stackoverflow.com/q/2603638
tags question: http://stackoverflow.com/q/2725940
tag name: date
tags question: http://stackoverflow.com/q/2599102
tags question: http://stackoverflow.com/q/2597083
tags question: http://stackoverflow.com/q/2735023
tags question: http://stackoverflow.com/q/2655833
tags question: http://stackoverflow.com/q/2600604
tags question: http://stackoverflow.com/q/2742191
tags question: http://stackoverflow.com/q/2734659
tags question: http://stackoverflow.com/q/2784514
type: Tag
tags question: http://stackoverflow.com/q/2705548
tags question: http://stackoverflow.com/q/2603149
tags question: http://stackoverflow.com/q/2619691
tags question: http://stackoverflow.com/q/2728623
tags question: http://stackoverflow.com/q/2600581
tags question: http://stackoverflow.com/q/2723727
tags question: http://stackoverflow.com/q/2606562
tags question: http://stackoverflow.com/q/2735632
tags question: http://stackoverflow.com/q/2675666
tags question: http://stackoverflow.com/q/2727698
tags question: http://stackoverflow.com/q/2723838
tags question: http://stackoverflow.com/q/2775411
tags question: http://stackoverflow.com/q/2786379
tags question: http://stackoverflow.com/q/2654025
tags question: http://stackoverflow.com/q/2687081

http://stackoverflow.com/a/2622331
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2634764
has comment: http://stackoverflow.com/comment/2640112
type: Answer
has comment: http://stackoverflow.com/comment/2634841
upvote count: 6
score: 6
answers question: http://stackoverflow.com/q/2622257
has comment: http://stackoverflow.com/comment/2634876
accepted answer of: http://stackoverflow.com/q/2622257
has body: Actually, only the JTree is aware of the expansion state, there is no such information in the TreeNodes. The TreeNodes are on the "model" side, and have no pointer on the JTree (at least not default ones, you can of course make your own with a reference, but it breaks a bit the pattern). You should reconsider the place where you want to make this expansion for a place in which you have access to the JTree (provide maybe more details about your context, to know more what you want to do, and in which circumstances).

http://stackoverflow.com/a/2653170
accepted answer of: http://stackoverflow.com/q/2653118
has comment: http://stackoverflow.com/comment/2669449
downvote count: 2
upvote count: 1
has comment: http://stackoverflow.com/comment/2669523
has comment: http://stackoverflow.com/comment/2669381
has comment: http://stackoverflow.com/comment/2669464
score: -1
type: AcceptedAnswer
has body: What does your process method look like? Could it be returning before you want it to, hence releasing the semaphore before you want it to?
answers question: http://stackoverflow.com/q/2653118
has comment: http://stackoverflow.com/comment/2669487
type: Answer

http://stackoverflow.com/comment/77273341
type: Comment
comment on: http://stackoverflow.com/a/24725245
score: 0
type: AnswerComment
has text: +1 to put this in setenv.sh, for example on ubuntu, you might have /usr/share/tomcat7/bin/catalina.sh, and you can put instead that single line for CATALINA_OPTS in /usr/share/tomcat7/bin/setenv.sh

http://stackoverflow.com/a/2712783
type: Answer
has body: Try this: private boolean isBasicLatin(String input) { for (char c : input.toCharArray()) { if (!UnicodeBlock.BASIC_LATIN.equals(UnicodeBlock.of(c))) { return false; } } return true; }
answers question: http://stackoverflow.com/q/2712670
score: 0

http://stackoverflow.com/comment/2639849
score: 0
has text: This is `O(N^2)` due to shifts due to `insert`. And the way `sb` is shrinking after each iteration makes it overly complicated to evaluate the condition of termination.
type: Comment
type: AnswerComment
comment on: http://stackoverflow.com/a/2626737

http://stackoverflow.com/a/2709284
has comment: http://stackoverflow.com/comment/2733608
downvote count: 0
has body: Fowler has a great overview of GUI architectures: http://martinfowler.com/eaaDev/uiArchs.html I personally use the PresentationModel construct throughout my apps - it keeps the presentation side of things completely separate from the business logic.
type: Answer
score: 3
upvote count: 3
answers question: http://stackoverflow.com/q/2708725

http://stackoverflow.com/a/66447614
score: 7
upvote count: 7
answers question: http://stackoverflow.com/q/2607858
has body: The Google Mobile Vision is deprecated and replaced with ML Kit. https://developers.google.com/ml-kit/vision/barcode-scanning It provides sdks on both android and iOS and is getting actively improved with the latest google technology. For android, it provides sdks that can bundle the model and also provides SDK that can fetch model from Google play service automatically if you want to save your app's size.
downvote count: 0
type: Answer

http://stackoverflow.com/comment/10322996
has text: it's almost 2012, and there seems to have been an update in February 2011 and this issue still doesn't seem to have been fixed after reading the message board.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2688932

http://stackoverflow.com/comment/2669073
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2652819
has text: thank you Dav but when the "class loading" happens ? after compiling or when I want to make an instance from the class ?

http://stackoverflow.com/comment/2803745
type: QuestionComment
has text: Hi, I repeat that you need to provide additional info. You had mentioned this: "NULL Object when I invoke my JNDI lookup " The result of a JNDI lookup should be a reference or a NameNotFoundException. It should never return a null. Also i don't follow how a null can result in a ClassCastException. I can understand a NPE but not a ClassCastException.
comment on: http://stackoverflow.com/q/2758577
score: 0
type: Comment

http://stackoverflow.com/comment/2751273
has text: Ajax: ASP.NET MVC has great support for server-side services that can easily be called from client-side JavaScript (e.g. through JQuery).
score: 0
comment on: http://stackoverflow.com/q/2724615
type: Comment
type: QuestionComment

jpa
tags question: http://stackoverflow.com/q/2643641
tags question: http://stackoverflow.com/q/2610113
tags question: http://stackoverflow.com/q/2740452
tags question: http://stackoverflow.com/q/2614989
tags question: http://stackoverflow.com/q/2775507
tags question: http://stackoverflow.com/q/2707903
tags question: http://stackoverflow.com/q/2694215
tags question: http://stackoverflow.com/q/2770266
tags question: http://stackoverflow.com/q/2704914
tags question: http://stackoverflow.com/q/2638448
tags question: http://stackoverflow.com/q/2743023
tags question: http://stackoverflow.com/q/2617898
tags question: http://stackoverflow.com/q/2707118
tags question: http://stackoverflow.com/q/2777017
tags question: http://stackoverflow.com/q/2657554
tags question: http://stackoverflow.com/q/2666048
tags question: http://stackoverflow.com/q/2737420
tags question: http://stackoverflow.com/q/2744335
tags question: http://stackoverflow.com/q/2599116
tags question: http://stackoverflow.com/q/2759077
tags question: http://stackoverflow.com/q/2690955
tags question: http://stackoverflow.com/q/2597686
tags question: http://stackoverflow.com/q/2642806
tags question: http://stackoverflow.com/q/2628586
tags question: http://stackoverflow.com/q/2649145
tags question: http://stackoverflow.com/q/2639039
tags question: http://stackoverflow.com/q/2702661
tags question: http://stackoverflow.com/q/2746997
tags question: http://stackoverflow.com/q/2668449
tags question: http://stackoverflow.com/q/2752043
tags question: http://stackoverflow.com/q/2774720
tags question: http://stackoverflow.com/q/2642881
tags question: http://stackoverflow.com/q/2706421
type: Tag
tags question: http://stackoverflow.com/q/2598588
tags question: http://stackoverflow.com/q/2761543
tags question: http://stackoverflow.com/q/2673732
tags question: http://stackoverflow.com/q/2757350
tags question: http://stackoverflow.com/q/2773302
tags question: http://stackoverflow.com/q/2727382
tags question: http://stackoverflow.com/q/2779857
tags question: http://stackoverflow.com/q/2729168
tags question: http://stackoverflow.com/q/2713025
tags question: http://stackoverflow.com/q/2778295
tags question: http://stackoverflow.com/q/2781771
tags question: http://stackoverflow.com/q/2744286
tags question: http://stackoverflow.com/q/2620728
tags question: http://stackoverflow.com/q/2613347
tags question: http://stackoverflow.com/q/2749689
tags question: http://stackoverflow.com/q/2738787
tags question: http://stackoverflow.com/q/2779381
tags question: http://stackoverflow.com/q/2748039
tags question: http://stackoverflow.com/q/2762329
tags question: http://stackoverflow.com/q/2598393
tags question: http://stackoverflow.com/q/2748431
tags question: http://stackoverflow.com/q/2637063
tags question: http://stackoverflow.com/q/2735071
tags question: http://stackoverflow.com/q/2754793
tags question: http://stackoverflow.com/q/2687690
tags question: http://stackoverflow.com/q/2639669
tags question: http://stackoverflow.com/q/2686863
tag name: jpa
tags question: http://stackoverflow.com/q/2602757
tags question: http://stackoverflow.com/q/2711231
tags question: http://stackoverflow.com/q/2737633
tags question: http://stackoverflow.com/q/2741402
tags question: http://stackoverflow.com/q/2680714
tags question: http://stackoverflow.com/q/2753078
tags question: http://stackoverflow.com/q/2749923
tags question: http://stackoverflow.com/q/2681906
tags question: http://stackoverflow.com/q/2660485
tags question: http://stackoverflow.com/q/2772470
tags question: http://stackoverflow.com/q/2643605
tags question: http://stackoverflow.com/q/2759300
tags question: http://stackoverflow.com/q/2679759
tags question: http://stackoverflow.com/q/2715113
tags question: http://stackoverflow.com/q/2641732
tags question: http://stackoverflow.com/q/2751733
tags question: http://stackoverflow.com/q/2752780
tags question: http://stackoverflow.com/q/2673678

jasper-reports
tags question: http://stackoverflow.com/q/2730777
tags question: http://stackoverflow.com/q/2763273
tag name: jasper-reports
tags question: http://stackoverflow.com/q/2683264
tags question: http://stackoverflow.com/q/2655784
tags question: http://stackoverflow.com/q/2774789
tags question: http://stackoverflow.com/q/2733317
type: Tag
tags question: http://stackoverflow.com/q/2746561
tags question: http://stackoverflow.com/q/2684025
tags question: http://stackoverflow.com/q/2714275
tags question: http://stackoverflow.com/q/2741394
tags question: http://stackoverflow.com/q/2772352

http://stackoverflow.com/comment/10214767
score: 0
type: Comment
type: QuestionComment
has text: I have the same problem. This is not a big issue since it happens very rarely. Using show_sql is not practical since reproducing this behavior requires millions of transactions. However, because this happens repeatedly during a system test I run (that has gazillions of transactions) I suspect that there is a specific reason.
comment on: http://stackoverflow.com/q/2743130

http://stackoverflow.com/q/2752224
possible better answer: http://stackoverflow.com/a/2752251
has answer: http://stackoverflow.com/a/20726282
has answer: http://stackoverflow.com/a/2752251
has body: I want a static inner class that can't be instantiated even by the external class. Right now I just have a documentation that says "Please don't instantiate this object". Can I give a better signal?
has answer: http://stackoverflow.com/a/2752248
score: 2
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/2782799
type: Question
downvote count: 0
accepted answer: http://stackoverflow.com/a/2752248
favorite count: 0
tagged with: class
answer count: 3
has title: How do I make the Inner Class uninstantiable?
tagged with: inner-classes
upvote count: 2

http://stackoverflow.com/a/2736880
downvote count: 0
answers question: http://stackoverflow.com/q/2733688
has comment: http://stackoverflow.com/comment/2766732
has body: Firebird is very good database especially for desktop application There is good java driver.
upvote count: 3
type: Answer
score: 3

http://stackoverflow.com/q/2706008
has answer: http://stackoverflow.com/a/2706058
favorite count: 0
has comment: http://stackoverflow.com/comment/2729700
has body: When using imageio.imageio.read iget a can't create ImageInputStream. I have a catch exception around it so the program survives but i was wondering if theres a way to put an if statement round it that checks to see if it falied and then attempt to read it again if it did. basically asking if there is a test for exceptions?
downvote count: 0
tagged with: javax.imageio
type: AnsweredQuestion
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/2729693
type: Question
answer count: 1
accepted answer: http://stackoverflow.com/a/2706058
has comment: http://stackoverflow.com/comment/2729660
has title: Imageiio can't create imageinput stream
tagged with: exception
has comment: http://stackoverflow.com/comment/2729673
upvote count: 1

http://stackoverflow.com/comment/2649884
has text: Joachim Sauer, hear hear. It's Sun JVM specific package relying on some native code, it's still part of "Java" as a technology, but as far as Java language concerned there is no way of manipulating memory directly. SF's question was about modules and extensions and this is one of them.
type: Comment
type: QuestionComment
score: 0
comment on: http://stackoverflow.com/q/2629357

http://stackoverflow.com/a/14980735
has body: i had compile 'org.hibernate:hibernate-core:4.1.9' i replaced it with compile 'org.hibernate:hibernate-core:3.3.2.GA' this is gradle syntax, converting to maven isnt difficult
type: Answer
answers question: http://stackoverflow.com/q/2729521
score: 0

http://stackoverflow.com/comment/136164745
has text: you can set the fail message within same line, that is a plus Assert.assertTrue(isElementPresent(By.id("idOfElement")), "LogOut Button is not visible.");
comment on: http://stackoverflow.com/a/12832195
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/comment/18580180
has text: Doesn't seem to work for arrays. I'm trying to display an int[] as hex, but changing the primitives doesn't change it and I don't know what class to specify for eclipse to translate.
comment on: http://stackoverflow.com/a/2754800
score: 1
type: AnswerComment
type: Comment

http://stackoverflow.com/a/2647383
has body: This will return true if the filename has two dots in its name, separated by word characters: matches("\\w+\\.\\w+\\.\\w+") Matches the following: aaa.bbb.ccc aaa.bbb.ccc 111.aaa.bbb aaa.b_b.ccc a.b.c Does not match the following: aaa.bbb .. . ---.aaa.bbb aaa.bbb.ccc.ddd a-a.bbb.ccc
has comment: http://stackoverflow.com/comment/2667475
score: 5
has comment: http://stackoverflow.com/comment/2663076
upvote count: 5
has comment: http://stackoverflow.com/comment/2662906
type: Answer
has comment: http://stackoverflow.com/comment/2662885
has comment: http://stackoverflow.com/comment/2662978
downvote count: 0
has comment: http://stackoverflow.com/comment/2663107
has comment: http://stackoverflow.com/comment/2664641
answers question: http://stackoverflow.com/q/2647317

http://stackoverflow.com/a/2690644
score: 2
downvote count: 0
has comment: http://stackoverflow.com/comment/2712971
answers question: http://stackoverflow.com/q/2689916
has comment: http://stackoverflow.com/comment/2712418
upvote count: 2
has body: Why don't you use a CardLayout to switch from the 2D to 3D component? CardLayout is exactly done for this kind of purpose in my understanding. Another benefit would be that it will simplify your code.
type: Answer

http://stackoverflow.com/a/2770617
type: Answer
answers question: http://stackoverflow.com/q/2769797
has body: Is this what you looking for? public class Point { private final int x; private final int y; public Point(int x, int y) { this.x = x; this.y = y; } public int getX() { return x; } public int getY() { return y; } @Override public boolean equals(Object o) { return (o instanceof Point &amp;&amp; getX() == ((Point) o).getX() &amp;&amp; getY() == ((Point) o) .getY()); } } public class TestIndexOf { public static void main(String[] args){ Point p1 = new Point(10,30); Point p2 = new Point(20,40); Point p3 = new Point(50,40); Point p4 = new Point(60,40); List&lt;Point&gt; list = new ArrayList&lt;Point&gt;(); list.add(p1); list.add(p2); list.add(p3); list.add(p4); System.out.println(list.indexOf(p3)); } } If you just want to search on the x property, change the equals method to compare only the x values like: @Override public boolean equals(Object o) { return (o instanceof Point &amp;&amp; getX() == ((Point) o).getX()); }
downvote count: 0
score: 7
upvote count: 7

http://stackoverflow.com/q/2722324
favorite count: 0
accepted answer: http://stackoverflow.com/a/2726941
possible better answer: http://stackoverflow.com/a/2730475
score: 2
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2730475
has answer: http://stackoverflow.com/a/2726941
downvote count: 0
tagged with: multithreading
has title: Problem with a blocking network task
has body: I'm new in Java so please forgive any obscene errors that I may make :) I'm developing a program in Java that among other things it should also handle clients that will connect to a server. The server has 3 threads running, and I have created them in the following way : DaemonForUI du; DaemonForPort da; DaemonForCheck dc; da = new DaemonForPort(3); dc = new DaemonForCheck(5); du = new DaemonForUI(7); Thread t_port = new Thread(da); Thread t_check = new Thread(dc); Thread t_ui = new Thread(du); t_port.setName("v1.9--PORTd"); t_check.setName("v1.9-CHECKd"); t_ui.setName("v1.9----UId"); t_port.start(); t_check.start(); t_ui.start(); Each thread handles a different aspect of the complete program. The thread t_ui is responsible to accept asynchronous incoming connections from clients, process the sent data and send other data back to the client. When I remove all the commands from the previous piece of code that has to with the t_ui thread, everything runs ok which in my case means that the other threads are printing their debug messages. If I set the t_ui thread to run too, then the whole program blocks at the "accept" of the t_ui thread. After reading at online manuals I saw that the accepted connections should be non-blocking, therefore use something like that : public ServerSocketChannel ssc = null; ssc = ServerSocketChannel.open(); ssc.socket().bind(new InetSocketAddress(port)); ssc.configureBlocking(false); SocketChannel sc = ssc.accept(); if (sc == null) { ; } else { System.out.println("The server and client are connected!"); System.out.println("Incoming connection from: " + sc.socket().getRemoteSocketAddress()); in = new DataInputStream(new BufferedInputStream(sc.socket().getInputStream())); out = new DataOutputStream(new BufferedOutputStream(sc.socket().getOutputStream())); //other magic things take place after that point... The thread for t_ui is created as follows : class DaemonForUI implements Runnable{ private int cnt; private int rr; public ListenerForUI se…
type: Question
tagged with: network-programming
tagged with: java
has comment: http://stackoverflow.com/comment/2749570
upvote count: 2
answer count: 2

http://stackoverflow.com/a/3448792
upvote count: 6
type: Answer
answers question: http://stackoverflow.com/q/2728495
score: 6
has body: The only real difference between RPC and RMI is that there is objects involved in RMI: instead of invoking functions through a proxy function, we invoke methods through a proxy.
downvote count: 0

http://stackoverflow.com/q/2723397
tagged with: java
downvote count: 2
has title: What is PECS (Producer Extends Consumer Super)?
score: 918
has answer: http://stackoverflow.com/a/62171149
has answer: http://stackoverflow.com/a/19739576
type: Question
linked to: http://stackoverflow.com/q/24217586
tagged with: bounded-wildcard
has answer: http://stackoverflow.com/a/2723503
accepted answer: http://stackoverflow.com/a/2723538
linked to: http://stackoverflow.com/q/49124391
possible better answer: http://stackoverflow.com/a/19739576
has answer: http://stackoverflow.com/a/44032098
tagged with: pecs
has answer: http://stackoverflow.com/a/54576828
has answer: http://stackoverflow.com/a/59868129
has answer: http://stackoverflow.com/a/61294213
has answer: http://stackoverflow.com/a/26902970
has answer: http://stackoverflow.com/a/48863403
linked to: http://stackoverflow.com/q/1163465
tagged with: generics
answer count: 17
linked to: http://stackoverflow.com/q/2248390
favorite count: 0
has answer: http://stackoverflow.com/a/53394456
has answer: http://stackoverflow.com/a/71708416
has answer: http://stackoverflow.com/a/2723538
has comment: http://stackoverflow.com/comment/95370616
has answer: http://stackoverflow.com/a/52468697
has body: I came across PECS (short for Producer extends and Consumer super) while reading up on generics. Can someone explain to me how to use PECS to resolve confusion between extends and super?
has answer: http://stackoverflow.com/a/19231762
has answer: http://stackoverflow.com/a/31634364
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/64888058
linked to: http://stackoverflow.com/q/1368166
upvote count: 920
linked to: http://stackoverflow.com/q/48812254
tagged with: super
has answer: http://stackoverflow.com/a/78247810

http://stackoverflow.com/a/2706644
upvote count: 1
score: 1
has body: Why would you not inject the client into the back end bean? "Don't call us, we'll call you" - objects should be given their dependencies. That's what Spring and DI are all about.
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2706630

http://stackoverflow.com/comment/37849759
type: Comment
comment on: http://stackoverflow.com/a/2721672
type: AnswerComment
has text: I think the question here is "why". Why do generics require Objects? The consensus appears to be that it's less of a design choice and more caving in to backward compatibility. In my eyes, if generics can't handle primitives, that's a functionality deficit. As it stands, everything involving primitives has to be written for each primitive: instead of Comparator<t,t>, we have Integer.compare(int a, int b), Byte.compare(byte a, byte b), etc. That's not a solution!
score: 32

http://stackoverflow.com/q/2729580
accepted answer: http://stackoverflow.com/a/2729595
has answer: http://stackoverflow.com/a/2729907
downvote count: 0
linked to: http://stackoverflow.com/q/21455403
has title: How to get the parameter names of an object's constructors (reflection)?
answer count: 3
linked to: http://stackoverflow.com/q/2237803
favorite count: 0
tagged with: constructor
duplicate of: http://stackoverflow.com/q/2237803
has comment: http://stackoverflow.com/comment/63608015
has answer: http://stackoverflow.com/a/2729595
tagged with: parameters
type: AnsweredQuestion
score: 22
has answer: http://stackoverflow.com/a/7641718
tagged with: reflection
has body: Say I somehow got an object reference from an other class: Object myObj = anObject; Now I can get the class of this object: Class objClass = myObj.getClass(); Now, I can get all constructors of this class: Constructor[] constructors = objClass.getConstructors(); Now, I can loop every constructor: if (constructors.length &gt; 0) { for (int i = 0; i &lt; constructors.length; i++) { System.out.println(constructors[i]); } } This is already giving me a good summary of the constructor, for example a constructor public Test(String paramName) is shown as public Test(java.lang.String) Instead of giving me the class type however, I want to get the name of the parameter.. in this case "paramName". How would I do that? I tried the following without success: if (constructors.length &gt; 0) { for (int iCon = 0; iCon &lt; constructors.length; iCon++) { Class[] params = constructors[iCon].getParameterTypes(); if (params.length &gt; 0) { for (int iPar = 0; iPar &lt; params.length; iPar++) { Field fields[] = params[iPar].getDeclaredFields(); for (int iFields = 0; iFields &lt; fields.length; iFields++) { String fieldName = fields[i].getName(); System.out.println(fieldName); } } } } } Unfortunately, this is not giving me the expected result. Could anyone tell me how I should do this or what I am doing wrong? Thanks!
tagged with: java
linked to: http://stackoverflow.com/q/471693
type: Question
upvote count: 22
possible better answer: http://stackoverflow.com/a/2729907

http://stackoverflow.com/comment/2753222
score: 0
type: AnswerComment
type: Comment
has text: @Sanjay: Does it imply you must use "static" field in order to call super with the value from SearchToUSer?
comment on: http://stackoverflow.com/a/2726135

http://stackoverflow.com/a/2733435
score: 1
accepted answer of: http://stackoverflow.com/q/2733392
answers question: http://stackoverflow.com/q/2733392
upvote count: 1
type: AcceptedAnswer
type: Answer
has body: So what is the problem, creating a table or creating an SQL query? Read the section from the Swing tutorial on How to Use Tables. Read the tutorial on JDBC Database Access. Put the two together and you've got your problem solved. That is first create your query and create a ResultSet. Then you use the meta data to get the column names. Then you loop through the ResultSet and add rows of data to your table. You can use a DefaultTableModel for this.
downvote count: 0

http://stackoverflow.com/a/2641576
downvote count: 0
type: Answer
has body: Try using mysql_real_escape_string function on the string you want to store. It is the easiest way.
score: 2
answers question: http://stackoverflow.com/q/2641561
upvote count: 2

http://stackoverflow.com/q/2716647
downvote count: 0
has answer: http://stackoverflow.com/a/5710222
answer count: 3
has answer: http://stackoverflow.com/a/2716809
favorite count: 0
accepted answer: http://stackoverflow.com/a/2716809
has body: I wrote an implementation of the Mandelbrot set in Java using a JComponent but I'm getting strange results when I render it. Besides that everything compiles right. I'm just not for sure what I'm doing wrong with it. Any code review also would be appreciated. My source is posted on pastebin since it would take up too much room here: JMandelbrot.java Mandelbrat.java
upvote count: 2
tagged with: jcomponent
possible better answer: http://stackoverflow.com/a/2716767
has title: Help with rendering the Mandelbrot set in Java
has answer: http://stackoverflow.com/a/2716767
type: AnsweredQuestion
score: 2
tagged with: mandelbrot
tagged with: java
type: Question

http://stackoverflow.com/a/2643397
score: 12
upvote count: 12
downvote count: 0
type: Answer
has body: Generally you should also override hashCode() each time you override equals(), even if just for the performance boost. HashCode() decides which 'bucket' your object gets sorted into when doing a comparison, so any two objects which equal() evaluates to true should return the same hashCode value(). I cannot remember the default behavior of hashCode() (if it returns 0 then your code should work but slowly, but if it returns the address then your code will fail). I do remember a bunch of times when my code failed because I forgot to override hashCode() though. :)
answers question: http://stackoverflow.com/q/2642589

http://stackoverflow.com/a/2652318
downvote count: 0
score: 1
upvote count: 1
has body: Yeah, this is called: anonymous class. You can read more about it here: http://docstore.mik.ua/orelly/java-ent/jnut/ch03_12.htm
type: Answer
answers question: http://stackoverflow.com/q/2652295

http://stackoverflow.com/q/2772152
tagged with: arrays
upvote count: 94
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2772250
has answer: http://stackoverflow.com/a/78040648
has answer: http://stackoverflow.com/a/8297514
has answer: http://stackoverflow.com/a/2772176
linked to: http://stackoverflow.com/q/8526907
possible better answer: http://stackoverflow.com/a/2772214
has answer: http://stackoverflow.com/a/2772273
type: AnsweredQuestion
has body: I was surprised to see in the Java source that System.arraycopy is a native method. Of course the reason is because it's faster. But what native tricks is the code able to employ that make it faster? Why not just loop over the original array and copy each pointer to the new array - surely this isn't that slow and cumbersome?
has answer: http://stackoverflow.com/a/2772214
has title: Why is System.arraycopy native in Java?
type: Question
tagged with: java
accepted answer: http://stackoverflow.com/a/2772176
answer count: 6
tagged with: native
score: 94

http://stackoverflow.com/a/2711078
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/2711067
score: 22
answers question: http://stackoverflow.com/q/2711067
upvote count: 22
has body: There aren't any "variable variables" (that is variables with variable names) in Java, but you can create Maps or Arrays to deal with your particular issue. When you encounter an issue that makes you think "I need my variables to change names dynamically" you should try and think "associative array". In Java, you get associative arrays using Maps. That is, you can keep a List of your arrays, something like: List&lt;String[]&gt; kList = new ArrayList&lt;String[]&gt;(); for(int k = 0; k &lt; 5; k++){ kList.add(new String[3]); } Or perhaps a little closer to what you're after, you can use a Map: Map&lt;Integer,String[]&gt; kMap = new HashMap&lt;Integer,String[]&gt;(); for(int k = 0; k &lt; 5; k++){ kMap.put(k, new String[3]); } // access using kMap.get(0) etc..
type: AcceptedAnswer

http://stackoverflow.com/q/2770549
answer count: 1
has answer: http://stackoverflow.com/a/2774519
tagged with: lucene
accepted answer: http://stackoverflow.com/a/2774519
score: 0
has title: Lucene document Boosting
type: Question
type: AnsweredQuestion
tagged with: java
has body: I am having problem with lucene boosting, Iam trying to boost a particular document which matches with the (firstname)field specified I have posted the part of the code private static Document createDoc(String lucDescription,String primaryk,String specialString){ Document doc = new Document(); doc.add(new Field("lucDescription",lucDescription, Field.Store.NO, Field.Index.TOKENIZED)); doc.add(new Field("primarykey",primaryk,Field.Store.YES,Field.Index.NO)); doc.add(new Field("specialDescription",specialString, Field.Store.NO, Field.Index.UN_TOKENIZED)); doc.setBoost ((float)(0.00001)); if (specialString.equals("chris")) doc.setBoost ((float)(100000.1)); return doc; } why is this not working? public static String dbSearch(String searchString){ List&lt;String&gt; pkList = new ArrayList&lt;String&gt;(); String conCat="("; try{ String querystr = searchString; Query query = new QueryParser("lucDescription", new StandardAnalyzer()).parse(querystr); IndexSearcher searchIndex = new IndexSearcher("/home/athreya/docsIndexFile"); // Index of the User table--&gt; /home/araghu/aditya/indexFile. Hits hits = searchIndex.search(query); System.out.println("Found " + hits.length() + " hits."); for(int iterator=0;iterator&lt;hits.length();iterator++) { String primKey=hits.doc(iterator).get("primarykey"); System.out.println(primKey); pkList.add(primKey); } searchIndex.close(); Thank you in advance Athreya
tagged with: scoring

http://stackoverflow.com/q/2735023
favorite count: 0
score: 39
has answer: http://stackoverflow.com/a/2735198
has comment: http://stackoverflow.com/comment/2763227
accepted answer: http://stackoverflow.com/a/2735198
answer count: 4
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/74591656
possible better answer: http://stackoverflow.com/a/2735083
has body: I am storing the dates in a SQLite database in this format: d-MMM-yyyy,HH:mm:ss aaa When I retrieve the date with that format I am get every thing fine except the hour. The hour is always 00. Here is my output: String date---&gt;29-Apr-2010,13:00:14 PM After convrting Date---&gt;1272479414000--Thu Apr 29 00:00:14 GMT+05:30 2010 Here is the code: Date lScheduledDate = CalendarObj.getTime(); DateFormat formatter = new SimpleDateFormat("d-MMM-yyyy,HH:mm:ss aaa"); SomeClassObj.setTime(formatter.format(lScheduledDate)); String lNextDate = SomeClassObj.getTime(); DateFormat lFormatter = new SimpleDateFormat("d-MMM-yyyy,HH:mm:ss aaa"); Date lNextDate = (Date)lFormatter.parse(lNextDate); System.out.println("output here"+lNextDate); What am I doing wrong?
upvote count: 39
type: Question
linked to: http://stackoverflow.com/q/38922754
tagged with: date
tagged with: datetime-format
has answer: http://stackoverflow.com/a/2735068
downvote count: 0
has answer: http://stackoverflow.com/a/54604782
has title: Convert String to java.util.Date
has answer: http://stackoverflow.com/a/2735083

http://stackoverflow.com/a/39945441
upvote count: 1
answers question: http://stackoverflow.com/q/2604005
downvote count: 0
type: Answer
has body: 2016 Update Altho java events were added back in 2006, and this question is from 2010, these are still somehow "hidden" features in the Java API, reading the question I believe an alternative that does exactly what you want are Java events, but not the ones in AWT Java 6 events, that allows you to decouple your project modules and have JML like capabilities without a server, the only downside of the events compared to JMS, is that the listener must be running, or else the message will be lost into oblivion. from: https://dzone.com/articles/java-ee6-events-lightweight Yo create a message: public class LogMessage implements Serializable { private final String message; private final Level level; LogMessage(String message, Level level) { this.message = message; this.level = level; } public String getMessage() { return message; } public Level getLevel() { return level; } } You create a producer: @Inject Event&lt;LogMessage&gt; event; event.fire(new LogMessage("Log it baby!", Level.INFO)); and finally, you create a consumer: public class LogListener { private static final Logger LOGGER = Logger.getAnonymousLogger(); public void process(@Observes LogMessage message){ LOGGER.log(message.getLevel(), message.getMessage()); } } Check out the @Observes annotation. All this is done synchronously and well to be more jms/like you want to make this process in asynchronous fashion, for this just add: @Stateless @Asynchronous public class LogListener { private static final Logger LOGGER = Logger.getAnonymousLogger(); public void process(@Observes LogMessage message){ LOGGER.log(message.getLevel(), message.getMessage()); } }
score: 1

http://stackoverflow.com/q/2751631
type: UnansweredQuestion
tagged with: hashtable
has answer: http://stackoverflow.com/a/2751679
has answer: http://stackoverflow.com/a/2752422
upvote count: 6
has answer: http://stackoverflow.com/a/36564637
tagged with: java
score: 6
has title: Help using Horner's rule and hash functions in Java?
type: Question
has body: I am trying to use Horner's rule to convert words to integers. I understand how it works and how if the word is long, it may cause an overflow. My ultimate goal is to use the converted integer in a hash function h(x)=x mod tableSize. My book suggests, because of the overflow, you could "apply the mod operator after computing each parenthesized expression in Horner's rule." I don't exactly understand what they mean by this. Say the expression looks like this: ((14*32+15)*32+20)*32+5 Do I take the mod tableSize after each parenthesized expression and add them together? What would it look like with this hash function and this example of Horner's rule?
answer count: 3
downvote count: 0
favorite count: 0

http://stackoverflow.com/a/2770418
has body: If have an ArrayList&lt;String&gt; and assign it to List&lt;?&gt; list. Should I be able to ask list.contains("it")? It is very useful if I can.
has comment: http://stackoverflow.com/comment/2803811
score: 0
has comment: http://stackoverflow.com/comment/2803821
answers question: http://stackoverflow.com/q/2770394
type: Answer

http://stackoverflow.com/q/2694392
type: UnansweredQuestion
tagged with: android
upvote count: 15
has answer: http://stackoverflow.com/a/11536505
has comment: http://stackoverflow.com/comment/2716191
downvote count: 0
tagged with: java
duplicate of: http://stackoverflow.com/q/1334802
type: Question
has answer: http://stackoverflow.com/a/11536574
tagged with: jar
has title: Importing external .jar file to Android project
score: 15
has body: I have a standard Java project in which I've written code to parse some BBC Radio XML data from the internet. The project is called BBCSchedules and the class I'm interested in is called BBCChannel. I'm now trying to use the BBCChannel class in an Android application. How should I go about doing this? I've tried various things, following various bits of advice on the internet, and the place I've got to at the moment is compiling my BBCSchedules project to a .jar file, and importing that to the Android project using the Build Path/Library/Add External Jar option. However, Eclipse still doesn't recognise the BBCChannel class, and won't let me run the application because of this. I guess I've done something silly wrong, but what is it? UPDATE: I've tried the steps listed in How can I use external JARs in an Android project? and various other StackOverflow questions I can find that seem to be related to this, but absolutely nothing seems to work. Any other ideas? UPDATE: The discussions I've had with the author of the first answer below suggest that it is something to do with how I am using Eclipse to attach the .jar file. The project he sent me with the .jar file already attached didn't work. Any other ideas anyone?
answer count: 3
linked to: http://stackoverflow.com/q/1334802
favorite count: 0
has answer: http://stackoverflow.com/a/2694903
has comment: http://stackoverflow.com/comment/2716252

http://stackoverflow.com/comment/2688712
has text: +1 for the square root bound, that's where the big gain lies. Note that for integers comparing the square to the bound is somewhat faster and more robust than to compute a square root bound.
type: Comment
comment on: http://stackoverflow.com/a/2668812
score: 1
type: AnswerComment

http://stackoverflow.com/a/2651654
has comment: http://stackoverflow.com/comment/2667803
has comment: http://stackoverflow.com/comment/2679161
type: Answer
has comment: http://stackoverflow.com/comment/2667768
has comment: http://stackoverflow.com/comment/2667751
has comment: http://stackoverflow.com/comment/2667760
answers question: http://stackoverflow.com/q/2651632
downvote count: 0
has comment: http://stackoverflow.com/comment/2667777
has comment: http://stackoverflow.com/comment/2670688
has comment: http://stackoverflow.com/comment/2667780
has comment: http://stackoverflow.com/comment/2679527
score: 61
upvote count: 61
has body: Update: there are two possible scenarios here: You are determining if an object is a collection; You are determining if a class is a collection. The solutions are slightly different but the principles are the same. You also need to define what exactly constitutes a "collection". Implementing either Collection or Map will cover the Java Collections. Solution 1: public static boolean isCollection(Object ob) { return ob instanceof Collection || ob instanceof Map; } Solution 2: public static boolean isClassCollection(Class c) { return Collection.class.isAssignableFrom(c) || Map.class.isAssignableFrom(c); } (1) can also be implemented in terms of (2): public static boolean isCollection(Object ob) { return ob != null &amp;&amp; isClassCollection(ob.getClass()); } I don't think the efficiency of either method will be greatly different from the other.

http://stackoverflow.com/comment/2665754
has text: That's what I meant by ideally. That would be easy for migration across platform, rather than hardcoding it.
comment on: http://stackoverflow.com/a/2603982
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/a/2644077
has body: IzPack uses the command prompt to create installer and uninstaller for any java program. To create an installer open the command prompt and go to the IzPack installed path -> bin. Then execute the command "compile install.xml" here you should give the full path address of your xml file. Then it automatically generate the exe file with the same xml file name.
has comment: http://stackoverflow.com/comment/2659071
upvote count: 1
downvote count: 1
answers question: http://stackoverflow.com/q/2643327
score: 0
type: Answer

http://stackoverflow.com/q/2619584
has answer: http://stackoverflow.com/a/29413794
has title: How to set java_home on Windows 7?
has answer: http://stackoverflow.com/a/35221175
tagged with: system-variable
tagged with: windows-7
upvote count: 449
has comment: http://stackoverflow.com/comment/35506335
has comment: http://stackoverflow.com/comment/38590750
has answer: http://stackoverflow.com/a/35983825
tagged with: java
tagged with: java-home
has answer: http://stackoverflow.com/a/11999682
has comment: http://stackoverflow.com/comment/35506333
downvote count: 7
type: Question
has answer: http://stackoverflow.com/a/17142065
has answer: http://stackoverflow.com/a/54897136
has answer: http://stackoverflow.com/a/2619638
has answer: http://stackoverflow.com/a/2619590
has comment: http://stackoverflow.com/comment/35506331
has answer: http://stackoverflow.com/a/48136126
has answer: http://stackoverflow.com/a/5925055
has comment: http://stackoverflow.com/comment/35506332
has answer: http://stackoverflow.com/a/17312386
score: 442
has answer: http://stackoverflow.com/a/17685578
favorite count: 0
has body: I went to the Environment Variables in 'System' in the control panel and made two new variables, one for user variables and one for system variables. Both were named JAVA_HOME and both pointing to C:\Sun\SDK\jdk\bin But for some reason, I still get the below error when running a Java command... BUILD FAILED C:\Users\Derek\Desktop\eclipse\eclipse\glassfish\setup.xml:161: The following error occurred while executing this line: C:\Users\Derek\Desktop\eclipse\eclipse\glassfish\setup.xml:141: The following error occurred while executing this line: C:\Users\Derek\Desktop\eclipse\eclipse\glassfish\setup.xml:137: Please set java.home to a JDK installation Total time: 1 second C:\Users\Derek\Desktop\eclipse\eclipse\glassfish&gt;lib\ant\bin\ant -f setup.xml Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar Buildfile: setup.xml How can I fix this problem?
has answer: http://stackoverflow.com/a/3467370
has comment: http://stackoverflow.com/comment/35506334
has comment: http://stackoverflow.com/comment/35506330
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/34808710
has answer: http://stackoverflow.com/a/3024721
has answer: http://stackoverflow.com/a/6521412
has answer: http://stackoverflow.com/a/16717130
has answer: http://stackoverflow.com/a/35839476
answer count: 18

http://stackoverflow.com/comment/3912712
type: Comment
score: 1
has text: Check also the Better Swing Application Framework. Though not compile time, it throws exception at UI construction time, which is good enough for most cases: http://kenai.com/projects/bsaf/pages/Action_Annotation_HowTo
type: AnswerComment
comment on: http://stackoverflow.com/a/2607972

http://stackoverflow.com/comment/2694236
type: Comment
score: 1
has text: @Roman: Why doesn't it work? Update your question to include this (or people will keep suggesting it) and explain why this solution fails for you.
type: AnswerComment
comment on: http://stackoverflow.com/a/2675400

http://stackoverflow.com/comment/72282248
type: Comment
comment on: http://stackoverflow.com/a/2649374
has text: This has the disadvantage of swallowing the wrong exception. If the readLine fails for some reason it throws an IOException. The file is then closed inside the finally. If the file close also fails, a new IOException is thrown and the first exception, with a possibly valuable error message, is lost.
type: AnswerComment
score: 0

http://stackoverflow.com/a/2685846
has body: It might be a good idea to specify that your question relates to the Netbeans IDE, as opposed to the Netbeans Platform. The latter is the rich client platform on which the IDE is built (analogous to Eclipse RCP).
upvote count: 1
type: Answer
answers question: http://stackoverflow.com/q/2685399
downvote count: 0
score: 1

http://stackoverflow.com/q/2678299
tagged with: http://stackoverflow.com/tag/xml
has title: A simple way to remove headers from XML files
upvote count: 3
accepted answer: http://stackoverflow.com/a/2678381
type: AnsweredQuestion
score: 3
tagged with: java
type: Question
answer count: 2
possible better answer: http://stackoverflow.com/a/2678397
has body: I need remove non-xml tags from file generated by another program. The file is some like this: Executing Command - Blah.exe ... -----Command Output----- HTTP/1.1 200 OK Connection: close Content-Type: text/xml <?xml version="1.0"?> 7 4 0 0 Exit-Code: 15 How to remove the non-xml text easily in java?
downvote count: 0
has answer: http://stackoverflow.com/a/2678397
tagged with: text-processing
favorite count: 0
has answer: http://stackoverflow.com/a/2678381

http://stackoverflow.com/q/2758544
has comment: http://stackoverflow.com/comment/3290947
type: AnsweredQuestion
tagged with: java
has comment: http://stackoverflow.com/comment/2790574
has body: I know that utilities for backup and restore are in the GAE future roadmap, but until then I need to do some backup/restore operations on the data store of my GAE/J application. I found some info on how to enable the remote API for GAE/J applications by setting up the RemoteServlet in the application's web.xml and then you should be able to use the bulkloader.py tool from the python sdk to do backup/restore operation on the datastore of a GAE/J app (see here). I've added the remote API servlet in the web.xml, deployed it and the remote API seems to be active since I get the "This request did not contain a necessary header" message in the browser. However when trying to use the bulkloader.py tool with the remote url and my developer credentials, I get an message from the python tool: URLError: (urlopen error (10060, 'Operation timed out')) with the Authentication Failed info message. Did any one encountered this problem and managed to solve it? Some pointers would be very much appreciated. Thanks, Mihai
type: Question
accepted answer: http://stackoverflow.com/a/2764657
linked to: http://stackoverflow.com/q/2364310
score: 0
answer count: 2
possible better answer: http://stackoverflow.com/a/3190572
has answer: http://stackoverflow.com/a/3190572
has title: backup and restore options for GAE/J
tagged with: google-app-engine
has answer: http://stackoverflow.com/a/2764657

http://stackoverflow.com/comment/2750083
has text: Ridiculous tentative :) Maven doesn't force you more than Ant to restart anything.
comment on: http://stackoverflow.com/a/2723616
type: Comment
score: 1
type: AnswerComment

http://stackoverflow.com/a/2669895
answers question: http://stackoverflow.com/q/2669761
score: 2
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2669761
upvote count: 2
type: AcceptedAnswer
has body: Depends. I recently did app that displays large 2d datasets with JFreechart, but I ended making datasets smaller to have performance. I displayed matrices of points, that changed in time (when new data arrives) with 1 second refresh time (so every one second chart is repainted). For matries 256 x 256 it is OK on normal user computer. If the matrix is ~350 pts it gets rough (user sees lags in the GUI), but it is usable, if the matrix is 1024 x 1024 app is unusable. I did chart drawing ind EDT, but still even if I took it into different thread --- rendering would still eat processor power. So depending on data set size --- you might want to use JFreeChart.
type: Answer

http://stackoverflow.com/a/2606712
answers question: http://stackoverflow.com/q/2606653
score: 11
accepted answer of: http://stackoverflow.com/q/2606653
upvote count: 11
has body: I thing the connection URL may be wrong. Then try following connection, String Connectionurl="jdbc:sqlserver://localhost:1433;DatabaseName=YourDBName;user=UserName;Password=YourPassword"
type: AcceptedAnswer
type: Answer
downvote count: 0

http://stackoverflow.com/a/3042545
type: Answer
answers question: http://stackoverflow.com/q/2695767
has body: While this answer didn't work for me, I found this: http://forums.sun.com/thread.jspa?threadID=623669 (post written by 'inopia') Which works perfectly. As he says: "The problem here is that it can become a bit difficult to find an event that fires after both the ListModel, JList and JScrollPane have been updated."
score: 0
has comment: http://stackoverflow.com/comment/124813475

http://stackoverflow.com/a/2631497
has comment: http://stackoverflow.com/comment/2644943
has comment: http://stackoverflow.com/comment/2644869
has comment: http://stackoverflow.com/comment/2644853
accepted answer of: http://stackoverflow.com/q/2631390
score: 4
answers question: http://stackoverflow.com/q/2631390
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2645291
type: Answer
has comment: http://stackoverflow.com/comment/2644907
upvote count: 4
has body: Maybe you have time enough to take a look at this article. You probably won't need to read all of it, just the key points. I would emphasize some differences: Java cannot overload operators Java has nothing like Linq as far as I'm concerned Java has no delegates If you're going to develop GUI oriented software, you're entering a whole new world Java package structure is different from the namespace structure, although a little bit similar In Java you always have to catch exceptions. You cannot just ignore them Java does not have ref and out parameters Java does not have the using keyword In Java syntax you have to explicitly define getters and setters For example: public int getX() { return x; } public void setX(int x) { this.x = x; } Java has no goto
downvote count: 0

http://stackoverflow.com/q/2622716
score: 10
favorite count: 0
tagged with: serialization
type: Question
tagged with: exception
tagged with: java
has body: im writen a client-server app, and now i´m facing a problem that I dont know how to solve: This is the client: try { Socket socket = new Socket(ip, port); ObjectOutputStream ooos = new ObjectOutputStream(socket .getOutputStream()); SendMessage message = new SendMessage(); message.numDoc = value.numDoc; message.docFreq = value.docFreq; message.queryTerms = query; message.startIndex = startIndex; message.count = count; message.multiple = false; message.ips = null; message.ports = null; message.value = true; message.docFreq = value.docFreq; message.numDoc = value.numDoc; ooos.writeObject(message); ObjectInputStream ois = new ObjectInputStream(socket .getInputStream()); ComConstants mensajeRecibido; Object mensajeAux; String mensa = null; byte[] by = null; do { mensajeAux = ois.readObject(); if (mensajeAux instanceof ComConstants) { System.out.println("Thread by Thread has Search Results"); String test; ByteArrayOutputStream testo = new ByteArrayOutputStream(); mensajeRecibido = (ComConstants) mensajeAux; byte[] wag; testo.write( mensajeRecibido.fileContent, 0, mensajeRecibido.okBytes); wag = testo.toByteArray(); if (by == null) { by = wag; } else { int size = wag.length; System.arraycopy(wag, 0, by, 0, size); } } else { System.err.println("Mensaje no esperado " + mensajeAux.getClass().getName()); break; } } while (!mensajeRecibido.lastMessage); //ByteArrayInputStream bs = new ByteArrayInputStream(by.toByteArray()); // bytes es el byte[] ByteArrayInputStream bs = new ByteArrayInputStream(by); ObjectInputStream is = new ObjectInputStream(bs); QueryWithResult[] unObjetoSerializable = (QueryWithResult[])is.readObject(); is.close(); //AQUI TOCARIA METER EL QUICKSORT XmlConverter xce = new XmlConverter(unObjetoSerializable, startIndex, count); String serializedd = xce.runConverter(); tempFinal = serializedd; ois.close(); socket.close(); } catch (Exception e) { e.printStackTrace(); } i++; } And this is the sender: try { QueryWithResult[] outputLine; Operations op = new Operat…
has title: Java invalid stream header Problem
tagged with: stream
upvote count: 10
answer count: 1
linked to: http://stackoverflow.com/q/23262160
duplicate of: http://stackoverflow.com/q/23262160
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2622833
downvote count: 0

http://stackoverflow.com/comment/9613393
type: AnswerComment
has text: So there isn't a straightforward way :). Thanks anyway for the suggestion
type: Comment
comment on: http://stackoverflow.com/a/2601634
score: 1

http://stackoverflow.com/comment/2807956
comment on: http://stackoverflow.com/q/2774173
score: 1
has text: Please show how you approached the problem and where you are puzzled (in this case, it may be that you haven't thought of a good algorithm). I'd rather you either asked for an algorithm or showed difficulties you were having in implementing it in Java.
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2637912
has title: How would I create an object that uses String type behaviour for creation?
has body: I'd like to be able to create an object that is created like a String object, and when created verifies that the String value is an appropriate option. I.E. SpecificString can be "Bob" or "Jim". SpecificString BadName = "Sam" //Throws exception SpecificString GoodName = "Bob" //Does not throw exception. The most important functionality is that when it is accessed it must behave like a string when accessed. printf(SpecificString); // outputs Bob. Is this possible?
type: Question
has answer: http://stackoverflow.com/a/2638541
accepted answer: http://stackoverflow.com/a/2638541
has answer: http://stackoverflow.com/a/2637935
answer count: 6
upvote count: 1
has answer: http://stackoverflow.com/a/2637992
tagged with: string
favorite count: 0
has answer: http://stackoverflow.com/a/2638800
has comment: http://stackoverflow.com/comment/2652633
possible better answer: http://stackoverflow.com/a/2637948
has answer: http://stackoverflow.com/a/2637948
has answer: http://stackoverflow.com/a/2637941
type: AnsweredQuestion
tagged with: oop
downvote count: 0
score: 1
tagged with: java

http://stackoverflow.com/comment/31984438
has text: It will throw compilation error "The method asList(Object[]) in the type Arrays is not applicable for the arguments (int, int, int, int, int, int, int)"..
comment on: http://stackoverflow.com/a/2761019
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/comment/2835006
comment on: http://stackoverflow.com/q/2784218
type: Comment
has text: @aperkins: because you've never had to find the smallest x items in an array? :-/
score: 0
type: QuestionComment

http://stackoverflow.com/a/7805311
downvote count: 0
score: 34
has body: Had a need for similar functionality myself, so after much hair pulling I came up with the function below /** * Fetches angle relative to screen centre point * where 3 O'Clock is 0 and 12 O'Clock is 270 degrees * * @param screenPoint * @return angle in degress from 0-360. */ public double getAngle(Point screenPoint) { double dx = screenPoint.getX() - mCentreX; // Minus to correct for coord re-mapping double dy = -(screenPoint.getY() - mCentreY); double inRads = Math.atan2(dy, dx); // We need to map to coord system when 0 degree is at 3 O'clock, 270 at 12 O'clock if (inRads &lt; 0) inRads = Math.abs(inRads); else inRads = 2 * Math.PI - inRads; return Math.toDegrees(inRads); }
answers question: http://stackoverflow.com/q/2676719
upvote count: 34
type: Answer

http://stackoverflow.com/comment/91820311
type: Comment
has text: Works perfectly!
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2761019

http://stackoverflow.com/q/2602516
has answer: http://stackoverflow.com/a/4592637
has title: Glassfish OpenSSO instructions (where to download OpenSSO)?
type: Question
accepted answer: http://stackoverflow.com/a/2603406
downvote count: 0
tagged with: glassfish
has body: According to the tutorial, I should go to OpenSSO and download an "express build". However, the download links on the OpenSSO site for the "Express Build 7" appear to require logging in via an account with a paid support contract. How can one currently download the OpenSSO wars?
favorite count: 0
has answer: http://stackoverflow.com/a/2740106
tagged with: oracle-database
possible better answer: http://stackoverflow.com/a/2945316
answer count: 4
tagged with: opensso
has answer: http://stackoverflow.com/a/2945316
score: 5
has answer: http://stackoverflow.com/a/2603406
type: AnsweredQuestion
tagged with: saml
upvote count: 5
tagged with: java

http://stackoverflow.com/a/2667745
has comment: http://stackoverflow.com/comment/2685740
upvote count: 25
type: AcceptedAnswer
downvote count: 1
has body: You get that exception when you use the JAXBContext.newInstance(String) factory method, where you pass in the package name as the argument. This does require the ObjectFactory to be there, otherwise, JAXB doesn't know which classes to process. If you don't have an ObjectFactory, you need to JAXBContext.newInstance(Class...) instead, passing in the explicit list of annotated classes to add to the context.
type: Answer
accepted answer of: http://stackoverflow.com/q/2667724
answers question: http://stackoverflow.com/q/2667724
has comment: http://stackoverflow.com/comment/2685876
score: 24

http://stackoverflow.com/a/2677505
upvote count: 9
type: Answer
accepted answer of: http://stackoverflow.com/q/2677419
answers question: http://stackoverflow.com/q/2677419
downvote count: 5
has body: It means the default character encoding of the JVM that you're running on, To check the default encoding you can do the following: System.getProperty("file.encoding"); that will return the default encoding (and the one used by getBytes() above).
score: 4
has comment: http://stackoverflow.com/comment/135537621
has comment: http://stackoverflow.com/comment/2697374
type: AcceptedAnswer

http://stackoverflow.com/comment/2702807
score: 0
has text: Thanks for your input Eyal! I considered 1) at first but that would have made my array longer which I didn't want to do if there was another way - thus asking here :) I will refactor the code a little with methods and develop it graphically (MVC) but I felt a need to have the game logic done first as easy as possible and from that point on modify it more and more.
type: AnswerComment
comment on: http://stackoverflow.com/a/2682968
type: Comment

http://stackoverflow.com/comment/27616531
has text: @janb - I think the second replace is unnecessary, because the `decode` method will already convert any `%2B` it finds into `+`. The first replace is necessary to stop it converting `+` into spaces.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/6926987
score: 4

http://stackoverflow.com/comment/138272136
type: Comment
comment on: http://stackoverflow.com/a/78428121
type: AnswerComment
has text: Can you explain why your code checks whether the [map] key is `"j"` ? I don't understand how that is related to the posted question.
score: 0

http://stackoverflow.com/a/2616078
answers question: http://stackoverflow.com/q/2616050
downvote count: 0
score: 3
upvote count: 3
type: Answer
has body: As soon as that NumberFormatException is thrown, you jump out of the loop and down to the catch. If your try-catch block is inside your while loop, it'll have the effect you're looking for. You may need to adjust the condition on the loop.

http://stackoverflow.com/q/2603638
type: Question
score: 5
has answer: http://stackoverflow.com/a/58849826
upvote count: 5
tagged with: simpledateformat
has title: Why can't this SimpleDateFormat parse this date string?
tagged with: date
accepted answer: http://stackoverflow.com/a/2603666
has body: The SimpleDateFormat: SimpleDateFormat pdf = new SimpleDateFormat("MM dd yyyy hh:mm:ss:SSSaa"); The exception thrown by pdf.parse("Mar 30 2010 5:27:40:140PM");: java.text.ParseException: Unparseable date: "Mar 30 2010 5:27:40:140PM" Any ideas? Edit: thanks for the fast answers. You were all correct, I just missed that one key sentence in the SimpleDateFormat docs - I should probably call it a day.
downvote count: 0
favorite count: 0
tagged with: parsing
possible better answer: http://stackoverflow.com/a/2603676
has answer: http://stackoverflow.com/a/2603676
answer count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2603666
tagged with: java
has answer: http://stackoverflow.com/a/2603659

http://stackoverflow.com/comment/32367654
comment on: http://stackoverflow.com/a/2683388
type: AnswerComment
has text: @user949300 As I said, it's a _working (but brittle) solution_ which is _not great, though_ - so, I agree it's a bad solution! But the whole premise is flawed, generally one shouldn't work with arbitrary `Number`s. Best thing here probably would've been constraining the type parameter further, to `T extends Number & Comparable<T>`.
type: Comment
score: 3

http://stackoverflow.com/a/2661502
score: 1
upvote count: 1
has comment: http://stackoverflow.com/comment/2678874
type: Answer
has comment: http://stackoverflow.com/comment/2678818
downvote count: 0
answers question: http://stackoverflow.com/q/2661489
has body: All you are going to have to do is to print out a newline after every ten numbers. for (i = 0; i &lt; numbers.length; ++i) { System.out.print(number[i]); if (i % 10 == 9) { System.out.println(); } else { System.out.print(" "); } }

http://stackoverflow.com/a/2770147
answers question: http://stackoverflow.com/q/2770111
type: Answer
has body: You are creating a string every time you call +=. For example String theString = "1"; //Makes an immutable String object "1" theString +="2"; //Makes a new immutable String object "12" theString +="3"; //makes a new immutable String object "123" Using a string builder avoids this problem. StringBuilder sb = new StringBuilder("1"); //Makes a StringBuilder object holding 1 sb.append("2"); //The same StringBuilder object now has "12" in it. sb.append("3"); //The same StringBuidler object now has "123" in it. String theString = sb.toString(); //Creates a new String object with "123" in it Note how in the first example we made all of those intermediate strings where in the second example we only created the StringBuilder and the final String (in both examples we created "1" "2" and "3" when we used them as arguments). You can see that there are fewer objects created in the first example, and if you're doing a lot of appending to the String, you can imagine how that adds up!
downvote count: 0
score: 1
upvote count: 1

http://stackoverflow.com/comment/2638016
has text: Forgot to mention this is good too if your schemas are of different types (XSD, RNG, and DTD)
type: AnswerComment
comment on: http://stackoverflow.com/a/2624980
type: Comment
score: 1

http://stackoverflow.com/a/34808710
upvote count: 6
type: Answer
downvote count: 0
score: 6
answers question: http://stackoverflow.com/q/2619584
has body: Windows 7 Go to Control Panel\All Control Panel Items\User Accounts using Explorer (not Internet Explorer!) or click on the Start button click on your picture Change my environment variables New... (if you don't have enough permissions to add it in the System variables section, add it to the User variables section) Add JAVA_HOME as Variable name and the JDK location as Variable value > OK Test: open a new console (cmd) type set JAVA_HOME expected output: JAVA_HOME=C:\Program Files\Java\jdk1.8.0_60

http://stackoverflow.com/q/2605477
downvote count: 0
has comment: http://stackoverflow.com/comment/20434659
has answer: http://stackoverflow.com/a/2605497
has answer: http://stackoverflow.com/a/8728325
has answer: http://stackoverflow.com/a/69448560
linked to: http://stackoverflow.com/q/52154362
has body: I need help with lazy blob loading in Hibernate. I have in my web application these servers and frameworks: MySQL, Tomcat, Spring and Hibernate. The part of database config. ${jdbc.initialPoolSize} ${jdbc.minPoolSize} ${jdbc.maxPoolSize} ${jdbc.acquireRetryAttempts} ${jdbc.acquireIncrement} ${jdbc.idleConnectionTestPeriod} ${jdbc.maxIdleTime} ${jdbc.maxConnectionAge} ${jdbc.preferredTestQuery} ${jdbc.testConnectionOnCheckin} ${hibernate.dialect} <tx:annotation-driven transaction-manager="txManager" /> The part of entity class @Lob @Basic(fetch=FetchType.LAZY) @Column(name = "BlobField", columnDefinition = "LONGBLOB") @Type(type = "org.springframework.orm.hibernate3.support.BlobByteArrayType") private byte[] blobField; The problem description. I'm trying to display on a web page database records related to files, which was saved in MySQL database. All works fine if a volume of data is small. But the volume of data is big I'm recieving an error java.lang.OutOfMemoryError: Java heap space I've tried to write in blobFields null values on each row of table. In this case, application works fine, memory doesn't go out of. I have a conclusion that the blob field which is marked as lazy (@Basic(fetch=FetchType.LAZY)) isn't lazy, actually!
favorite count: 0
type: UnansweredQuestion
score: 32
has answer: http://stackoverflow.com/a/50948674
has answer: http://stackoverflow.com/a/70441135
upvote count: 32
has answer: http://stackoverflow.com/a/2615366
tagged with: lazy-loading
tagged with: java
tagged with: hibernate
tagged with: mysql
has title: Spring, Hibernate, Blob lazy loading
type: Question
answer count: 8
tagged with: blob
has answer: http://stackoverflow.com/a/38841810
has answer: http://stackoverflow.com/a/54136777

http://stackoverflow.com/a/2786737
upvote count: 3
score: 3
answers question: http://stackoverflow.com/q/2785333
has comment: http://stackoverflow.com/comment/2828560
accepted answer of: http://stackoverflow.com/q/2785333
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2822557
has body: Is this similar to this thread? I just figured out what was the problem. I was using an external target platform to run my plugins, where I had installed only the basic plugins. After I installed the sources org.eclipse.platform.source_2.1.0 and org.eclipse.platform.win32.source_2.1.0 also on the target platform, the manifest editor in the PDE was working normal again. (to be adapted to your Eclipse version) Also confirmed in this more recent thread: Your target platform (and the default will be your own eclipse install) needs to have the source bundles (which provide the schema files used by these menus). i.e. if I installed the runtime version, I will only get Generic in the menus but if I install the SDK version I will get real elements. Thank you very much for the answer. I "Add" source file to the platform (Preferences / Plugin development / Target platform) and got all menus!!
has comment: http://stackoverflow.com/comment/2822457
type: Answer

http://stackoverflow.com/comment/2662555
score: 0
type: Comment
type: QuestionComment
has text: Could you post some example code to illustrate the problem?
comment on: http://stackoverflow.com/q/2647154

http://stackoverflow.com/comment/2611233
type: Comment
comment on: http://stackoverflow.com/a/2601898
has text: @Jorn, in a sense, yes. But it is the outer class that does not have to be instantiated for the nested class to be used. That is consistent, if you squint just the right way.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/100266641
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/15990047
has text: in the switch statement I used the cRPM as if it was a const. quite right, considering the above. so yes i have removed the switch.

http://stackoverflow.com/comment/2698069
comment on: http://stackoverflow.com/a/2678132
score: 0
type: Comment
has text: This tutorial is a Constructors tutorial. I bet they assume that the instance variables already exist. Good luck!
type: AnswerComment

http://stackoverflow.com/comment/2738442
comment on: http://stackoverflow.com/a/2713493
type: AnswerComment
type: Comment
has text: We can also just use JPA. More convenient can't it be.
score: 0

http://stackoverflow.com/comment/2698475
score: 0
comment on: http://stackoverflow.com/q/2678812
type: Comment
type: QuestionComment
has text: Btw, I just found this: http://forums.sun.com/thread.jspa?threadID=5423031

http://stackoverflow.com/a/2623814
score: 1
downvote count: 0
has body: Use a transacted session and indicate successful message processing by invoking the Session class's commit() method. Check the section 19.4.5. Processing messages within transactions for the configuration. (you can use a DefaultMessageListenerContainer). Depending on what you're doing with the messages, you may need a JTA transaction manager.
type: Answer
upvote count: 1
answers question: http://stackoverflow.com/q/2623542

http://stackoverflow.com/q/2745796
downvote count: 0
has answer: http://stackoverflow.com/a/2747262
tagged with: string
favorite count: 0
has comment: http://stackoverflow.com/comment/2775112
answer count: 9
has answer: http://stackoverflow.com/a/78978305
has answer: http://stackoverflow.com/a/5428946
accepted answer: http://stackoverflow.com/a/5428946
has answer: http://stackoverflow.com/a/2745813
has answer: http://stackoverflow.com/a/2745836
score: 14
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/72416560
linked to: http://stackoverflow.com/q/1673841
upvote count: 14
tagged with: reflection
tagged with: java
has answer: http://stackoverflow.com/a/2745851
has body: Currently, I have a bunch of Java classes that implement a Processor interface, meaning they all have a processRequest(String key) method. The idea is that each class has a few (say, &lt;10) member Strings, and each of those maps to a method in that class via the processRequest method, like so: class FooProcessor implements Processor { String key1 = "abc"; String key2 = "def"; String key3 = "ghi"; // and so on... String processRequest(String key) { String toReturn = null; if (key1.equals(key)) toReturn = method1(); else if (key2.equals(key)) toReturn = method2(); else if (key3.equals(key)) toReturn = method3(); // and so on... return toReturn; } String method1() { // do stuff } String method2() { // do other stuff } String method3() { // do other other stuff } // and so on... } You get the idea. This was working fine for me, but now I need a runtime-accessible mapping from key to function; not every function actually returns a String (some return void) and I need to dynamically access the return type (using reflection) of each function in each class that there's a key for. I already have a manager that knows about all the keys, but not the mapping from key to function. My first instinct was to replace this mapping using if-else statements with a Map&lt;String, Function&gt;, like I could do in Javascript. But, Java doesn't support first-class functions so I'm out of luck there. I could probably dig up a third-party library that lets me work with first-class functions, but I haven't seen any yet, and I doubt that I need an entire new library. I also thought of putting these String keys into an array and using reflection to invoke the methods by name, but I see two downsides to this method: My keys would have to be named the same as the method - or be named in a particular, consistent way so that it's easy to map them to the method name. This seems WAY slower than the if-else statements I have right now. Efficiency is something of a concern because these methods will t…
has answer: http://stackoverflow.com/a/2745865
type: Question
has comment: http://stackoverflow.com/comment/2775270
has title: How can I map a String to a function in Java?
possible better answer: http://stackoverflow.com/a/2745836
has answer: http://stackoverflow.com/a/2748180
tagged with: functional-programming

http://stackoverflow.com/a/2736790
answers question: http://stackoverflow.com/q/2735743
downvote count: 0
has comment: http://stackoverflow.com/comment/2785238
has body: You can read/write memory addresses if some API is provided to do it. On the Sun/Oracle JRE sun.misc.Unsafe allows you to do this, although intentionally you have to go through hoops to get hold of an instance.
type: Answer
upvote count: 2
has comment: http://stackoverflow.com/comment/2785023
score: 2

http://stackoverflow.com/q/2707733
has title: Eager / auto loading of EJB / load EJB on startup (on JBoss)
type: Question
tagged with: jakarta-ee
type: AnsweredQuestion
tagged with: java
tagged with: jboss
answer count: 2
has answer: http://stackoverflow.com/a/2736067
downvote count: 0
score: 22
upvote count: 22
favorite count: 0
tagged with: ejb-3.0
has body: EJBs seem to be loaded lazily - whenever accessed. However, I want to initialize them eagerly - i.e. whenever the container starts-up. How is this achieved (in JBoss in particular) This topic gives some hints, but isn't quite satisfactory.
has answer: http://stackoverflow.com/a/2708427
possible better answer: http://stackoverflow.com/a/2736067
accepted answer: http://stackoverflow.com/a/2708427

http://stackoverflow.com/comment/2814373
has text: The format checking code does not work (68"62'65.9 passes, but -82"30'0. fails).
comment on: http://stackoverflow.com/a/2779421
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/q/2770382
tagged with: apache-commons-httpclient
type: AnsweredQuestion
score: 7
tagged with: java
upvote count: 7
linked to: http://stackoverflow.com/q/4915414
has answer: http://stackoverflow.com/a/2770595
type: Question
possible better answer: http://stackoverflow.com/a/9360099
has answer: http://stackoverflow.com/a/9360099
answer count: 3
has answer: http://stackoverflow.com/a/60757364
has title: Logs are filling up with httpclient.wire.content dumps. How can I turn it off?
downvote count: 0
accepted answer: http://stackoverflow.com/a/2770595
tagged with: tomcat
tagged with: log4j
has comment: http://stackoverflow.com/comment/24862019
favorite count: 0
has body: My catalina logs are filling up with gobs of statements like: /logs/catalina.out:2010-05-05 02:57:19,611 [Thread-19] DEBUG httpclient.wire.content - &gt;&gt; "[0x4] [0xc][0xd9][0xf4][0xa2]MA[0xed][0xc2][0x93][0x1b][0x15][0xfe],[0xe]h[0xb0][0x1f][0xff][0xd6][0xfb] [0x8f]O[0xd4][0xc4]0[0xab][0x80][0xe8][0xe4][0xf2][\r]I&amp;[0xaa][0xd2]BQ[0xdb](zq[0xcd]ac[0xa8] on and on forever. I searched every config file in both tomcat and apache for the statements that purportedly turn this on as described here: http://hc.apache.org/httpclient-3.x/logging.html And I don't see where this logging has been enabled. No other .war I deployed does this. The log4j configuration block in the app isn't doing it. I also tried to turn it off with statements like this: org.apache.commons.httpclient.wire=SEVERE or org.apache.commons.httpclient.wire.content=SEVERE or httpclient.wire.content=SEVERE in my tomcat/conf/logging.properties file, and that didn't stop it I'm using an S3 library for grails that may be the source for these. However when I run this application on my development machine (in both develop and deploy configs), I'm not seeing it. And a related question: When would I want to use these "wire logs?"

http://stackoverflow.com/a/2776112
downvote count: 0
type: Answer
accepted answer of: http://stackoverflow.com/q/2776011
answers question: http://stackoverflow.com/q/2776011
score: 4
upvote count: 4
has body: "Tuned" quicksort just means that some improvements are applied to the basic algorithm. Usually the improvements are to try and avoid worst case time complexity. Some examples of improvements might be to choose the pivot (or multiple pivots) so that there's never only 1 key in a partition, or only make the recursive call when a partition is above a certain minimum size. It looks like Java only uses merge sort when sorting Objects (the Arrays doc tells you which sorting algorithm is used for which sort method signature), so I don't think it ever really "decides" on its own, but the decision was made in advance. (Also, implementers are free to use another sort, as long as it's stable.)
type: AcceptedAnswer

http://stackoverflow.com/a/4907526
score: 1
has body: Just hit upon this thread, and even though it's almost a year old let me point you to the "jbarrier" library we developed at the University of Bonn a few months ago: http://net.cs.uni-bonn.de/wg/cs/applications/jbarrier/ The barrier package targets exactly the case where the number of worker threads is &lt;= the number of cores. The package is based on busy-wait, it supports not only barrier actions but also global reductions, and apart from a central barrier it offers tree-structured barriers for parallelizing the synchronization/reduction parts even further.
upvote count: 1
answers question: http://stackoverflow.com/q/2712232
type: Answer
downvote count: 0

http://stackoverflow.com/q/2644688
has answer: http://stackoverflow.com/a/2644994
has comment: http://stackoverflow.com/comment/2660325
type: Question
has comment: http://stackoverflow.com/comment/19749168
has comment: http://stackoverflow.com/comment/2660266
answer count: 8
has answer: http://stackoverflow.com/a/44871461
tagged with: performance
possible better answer: http://stackoverflow.com/a/2645142
tagged with: java
has answer: http://stackoverflow.com/a/2645201
tagged with: queue
has comment: http://stackoverflow.com/comment/2662640
downvote count: 0
has title: Java performance problem with LinkedBlockingQueue
score: 16
favorite count: 0
has answer: http://stackoverflow.com/a/2645090
has body: this is my first post on stackoverflow... I hope someone can help me I have a big performance regression with Java 6 LinkedBlockingQueue. In the first thread i generate some objects which i push in to the queue In the second thread i pull these objects out. The performance regression occurs when the take() method of the LinkedBlockingQueue is called frequently. I monitored the whole program and the take() method claimed the most time overall. And the throughput goes from ~58Mb/s to 0.9Mb/s... the queue pop and take methods ar called with a static method from this class public class C_myMessageQueue { private static final LinkedBlockingQueue&lt;C_myMessageObject&gt; x_queue = new LinkedBlockingQueue&lt;C_myMessageObject&gt;( 50000 ); /** * @param message * @throws InterruptedException * @throws NullPointerException */ public static void addMyMessage( C_myMessageObject message ) throws InterruptedException, NullPointerException { x_queue.put( message ); } /** * @return Die erste message der MesseageQueue * @throws InterruptedException */ public static C_myMessageObject getMyMessage() throws InterruptedException { return x_queue.take(); } } how can I tune the take() method to accomplish at least 25Mb/s, or is there a other class I can use which will block when the "queue" is full or empty. kind regards Bart P.S.: sorry for my bad english, I'm from Germany ;)
has answer: http://stackoverflow.com/a/2644743
has answer: http://stackoverflow.com/a/2645379
upvote count: 16
accepted answer: http://stackoverflow.com/a/2645379
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2644918
tagged with: multithreading
has answer: http://stackoverflow.com/a/2645142

http://stackoverflow.com/q/2738787
tagged with: orm
type: Question
tagged with: jpa
answer count: 1
accepted answer: http://stackoverflow.com/a/2741315
tagged with: eclipselink
has comment: http://stackoverflow.com/comment/2767648
tagged with: jpa-2.0
has title: JPA 2.0 Eclipse Link
has comment: http://stackoverflow.com/comment/2767572
has answer: http://stackoverflow.com/a/2741315
type: AnsweredQuestion
has body: I have this code @Column(updatable=false) @Enumerated(EnumType.STRING) private ExamType examType; However, I can still change the value when I update it via merge. Why?
has comment: http://stackoverflow.com/comment/2767604
score: 0
tagged with: java

http://stackoverflow.com/q/2721118
has title: com.mysql.jdbc.Driver ClassNotFoundException
has answer: http://stackoverflow.com/a/2721125
answer count: 3
tagged with: classnotfoundexception
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2721442
upvote count: 1
has body: I'm getting ClassNotFoundException on Class.forname("com.mysql.jdbc.Driver") I'm using Windows Vista 64-bit, Eclipse Galileo, GWT framework. I downloaded mysql-connector-java-5.1.6-bin, but what is the exact path I should put this file in? I'm getting this exception while I'm in gwt-projects, but in normal projects it works good. Any idea how that should be done?
tagged with: gwt
score: 1
tagged with: java
has comment: http://stackoverflow.com/comment/2747192
has answer: http://stackoverflow.com/a/2721469
type: Question
has comment: http://stackoverflow.com/comment/2747205
downvote count: 0

http://stackoverflow.com/a/2726922
downvote count: 1
answers question: http://stackoverflow.com/q/2725010
score: -1
upvote count: 0
has body: stream classdesc serialVersionUID = 5226096973188250357 What am I missing? What you are missing is private static final long serialVersionUID = 5226096973188250357L; However if the changed class is no longer serialization-compatible (see the Object Serialization Specification) you may now get more obscure errors.
type: Answer

http://stackoverflow.com/comment/2769860
type: AnswerComment
has text: I forgot the most important part: This needs to be free! Thanks for the tip, though :)
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2697361

http://stackoverflow.com/comment/2751608
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2724901
type: Comment
has text: Thanks, camickr was a bit faster but you deserve an upvote for extra elaboration! I did read the docs by the way, but I think I misunderstood it. :)

http://stackoverflow.com/q/2755945
has title: How can I use "." as the delimiter with String.split() in java
has answer: http://stackoverflow.com/a/2756050
has answer: http://stackoverflow.com/a/2755955
tagged with: java
has answer: http://stackoverflow.com/a/38753795
type: Question
answer count: 8
tagged with: split
has answer: http://stackoverflow.com/a/2756342
score: 125
downvote count: 0
tagged with: string
has answer: http://stackoverflow.com/a/2756045
favorite count: 0
linked to: http://stackoverflow.com/q/14833008
has answer: http://stackoverflow.com/a/2755957
type: UnansweredQuestion
upvote count: 125
duplicate of: http://stackoverflow.com/q/14833008
has answer: http://stackoverflow.com/a/16578721
has body: What I am trying to do is read a .java file, and pick out all of the identifiers and store them in a list. My problem is with the .split() method. If you run this code the way it is, you will get ArrayOutOfBounds, but if you change the delimiter from "." to anything else, the code works. But I need to lines parsed by "." so is there another way I could accomplish this? import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.*; public class MyHash { private static String[] reserved = new String[100]; private static List list = new LinkedList(); private static List list2 = new LinkedList(); public static void main (String args[]){ Hashtable hashtable = new Hashtable(997); makeReserved(); readFile(); String line; ListIterator itr = list.listIterator(); int listIndex = 0; while (listIndex &lt; list.size()) { if (itr.hasNext()){ line = itr.next().toString(); //PROBLEM IS HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! String[] words = line.split("."); //CHANGE THIS AND IT WILL WORK System.out.println(words[0]); //TESTING TO SEE IF IT WORKED } listIndex++; } } public static void readFile() { String text; String[] words; BufferedReader in = null; try { in = new BufferedReader(new FileReader("MyHash.java")); //NAME OF INPUT FILE } catch (FileNotFoundException ex) { Logger.getLogger(MyHash.class.getName()).log(Level.SEVERE, null, ex); } try { while ((text = in.readLine()) != null){ text = text.trim(); words = text.split("\\s+"); for (int i = 0; i &lt; words.length; i++){ list.add(words[i]); } for (int j = 0; j &lt; reserved.length; j++){ if (list.contains(reserved[j])){ list.remove(reserved[j]); } } } } catch (IOException ex) { Logger.getLogger(MyHash.class.getName()).log(Level.SEVERE, null, ex); } try { in.close(); } catch (IOException ex) { Logger.getLogger(MyHash.class.getName()).log(Level.SEVERE, null, ex); } } public static int keyIt (int x) { int key = x % 997; return key; } public sta…
has answer: http://stackoverflow.com/a/2755949

http://stackoverflow.com/a/2670521
has body: In your code, for each value of i, you are setting target array elements at i to value in "nums" at j. That is how you end up with same value for all the elements at the end of all iterations. First of all, very bad logic to have two loops for a simple swap algorithm such as : public static void reverse(int[] b) { int left = 0; // index of leftmost element int right = b.length-1; // index of rightmost element while (left &lt; right) { // exchange the left and right elements int temp = b[left]; b[left] = b[right]; b[right] = temp; // move the bounds toward the center left++; right--; } }//endmethod reverse or simplified: for (int left=0, int right=b.length-1; left&lt;right; left++, right--) { // exchange the first and last int temp = b[left]; b[left] = b[right]; b[right] = temp; } Why go through all this pain, why dont you trust Java's built-in APIs and do something like public static Object[] reverse(Object[] array) { List&lt;Object&gt; list = Arrays.asList(array); Collections.reverse(list); return list.toArray(); }
answers question: http://stackoverflow.com/q/2670460
has comment: http://stackoverflow.com/comment/2689102
type: Answer
has comment: http://stackoverflow.com/comment/2720808
has comment: http://stackoverflow.com/comment/2689145
score: -1
downvote count: 2
upvote count: 1
has comment: http://stackoverflow.com/comment/2690551

http://stackoverflow.com/comment/38879419
type: Comment
has text: Angular is already on my list of things to try. I would lump any of those into the HTML/javascript solution bucket. Sadly iteration time is long enough that changing technologies is a bit of an undertaking. Thanks for the suggestion.
comment on: http://stackoverflow.com/a/8977522
score: 0
type: AnswerComment

http://stackoverflow.com/a/2775788
upvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/69031871
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/2774326
has body: You can build a trigger job that triggers the other jobs. Make it configurable by using the JobMap properties, and you can reuse the class for triggering an arbitrary set of jobs (and maybe executing the first for yourself).

http://stackoverflow.com/a/2604211
answers question: http://stackoverflow.com/q/2604169
has comment: http://stackoverflow.com/comment/65396489
score: 5
type: Answer
upvote count: 6
downvote count: 1
has body: It provides another layer of abstraction. Reduces complexity of an object and makes it more modular. Sorta like using an interface(implementation being completely independent and no one cares how it is done just that it gets done.) Now I have never used it but it would be useful for: Implementing a particular function that needs to be done in different subclasses, since each of the sub classes needs to implement it in different ways another class would implement all the functions. Kinda like a module but only for a collection of classes. Wikipedia has a pretty good explanation: http://en.wikipedia.org/wiki/Visitor_pattern And their example helps explain what I am trying to say. Hope that helps clear it up a bit. EDIT**Sorry I linked to wikipedia for your answer but they really do have a decent example :) Not trying to be that guy that says go find it yourself.

http://stackoverflow.com/q/2674292
upvote count: 4
tagged with: jvm
answer count: 4
favorite count: 0
has title: Suspending the JVM for a limited amount of time
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/14044931
downvote count: 0
tagged with: java
linked to: http://stackoverflow.com/q/11010165
has comment: http://stackoverflow.com/comment/2694342
has answer: http://stackoverflow.com/a/2675622
type: Question
has body: How can I suspend the execution of a JVM for a configurable amount of time, similar to want happens on a full, serial, Garbage Collection? I want to test some edge cases but it's difficult to create the exact pauses I need with manually generating garbage + System.gc(). I'm trying to 'freeze' all the threads in the application, to simulate a situation where an application becomes unresponsive, and then resumes execution. The application is part of a cluster, and I'm trying to debug some leave / join / re-join problems.
has comment: http://stackoverflow.com/comment/5931409
score: 4
has comment: http://stackoverflow.com/comment/2694199
has answer: http://stackoverflow.com/a/2674961
accepted answer: http://stackoverflow.com/a/2674961
has answer: http://stackoverflow.com/a/2675683
has answer: http://stackoverflow.com/a/14044931

http://stackoverflow.com/comment/2689409
comment on: http://stackoverflow.com/a/2667973
type: Comment
type: AnswerComment
has text: Thanks. And I bet this would work with Eclipse 3.4+. I think the TPTP application is the same for Rad and Eclipse. I think the best bet it is to see if the XML output works. There is probably a -DTPTP_OUTPUT_FORMAT=xml something I am missing.
score: 0

http://stackoverflow.com/comment/2801056
type: Comment
score: 1
has text: its a random shuffle i want a specific permutation determined by perm array, maybe I named the method irritating, it should be more permute() instead of shuffle()
type: AnswerComment
comment on: http://stackoverflow.com/a/2768257

http://stackoverflow.com/a/2631260
answers question: http://stackoverflow.com/q/2618252
type: AcceptedAnswer
score: 0
type: Answer
has body: I think I have the best solution and as no one has answered it is what I will go with for the moment. I am creating a temporary file in Java and using this for saving the data. Then before exiting, I read that file and output it to stdout so that the python code can pick it up and store it in the database. Thankfully, it is always a similar size so I can limit the number of characters on the database field to 3500. If anyone gets a better solution, please comment to tell me, but for the moment, this is what I will use.
accepted answer of: http://stackoverflow.com/q/2618252
has comment: http://stackoverflow.com/comment/2654609

http://stackoverflow.com/a/2695673
answers question: http://stackoverflow.com/q/2695631
has comment: http://stackoverflow.com/comment/2717717
score: 0
has body: I don't know much about Java, but maybe if you removed the try/catch stuff you could see what the error actually is? According to the docs: "When an application running in the development server calls the Mail service to send an email message, the message is printed to the log. The Java development server does not send the email message." Does anything show up in the log?
type: Answer
has comment: http://stackoverflow.com/comment/2717869
has comment: http://stackoverflow.com/comment/2717784
has comment: http://stackoverflow.com/comment/2717799

http://stackoverflow.com/comment/2687514
comment on: http://stackoverflow.com/a/2661121
score: 5
type: AnswerComment
has text: @BalusC: I know; it's a pet peeve. Long method names -- like `isCurrentUserLoggedInAsRole` -- are sometimes a symptom of a larger problem: a misplaced method. (For example, the `User` class should know its assigned roles: `user.isAssigned( role )`.)
type: Comment

http://stackoverflow.com/a/2637941
upvote count: 1
downvote count: 0
type: Answer
score: 1
has body: If I understand your point correctly, you want to ensure that a given object is a String limited to a specific set of possible values. I'd go for Enums, in this case. Just use the standard Enums if you are using a recent Java version, or roll up the "old" DIY version that may perhaps be more appropriate to your specific problem. For an example of the latter one, see this
answers question: http://stackoverflow.com/q/2637912

http://stackoverflow.com/comment/2738473
has text: This might be the best option because I really like Scala. I'll probably just have to wait for Blackberry to suck less.
type: AnswerComment
comment on: http://stackoverflow.com/a/2713057
score: 0
type: Comment

http://stackoverflow.com/comment/2739575
comment on: http://stackoverflow.com/a/2713880
type: AnswerComment
has text: @ikurtz Yep, `setText(getText() + "...");`
score: 0
type: Comment

http://stackoverflow.com/comment/2796660
has text: In that case I guess you must store the data to a file... unless you want to create those 16 methods :) Of course, if you generate the class, it doesn't really matter that much how it is formatted.
type: AnswerComment
comment on: http://stackoverflow.com/a/2763665
score: 0
type: Comment

http://stackoverflow.com/comment/2716794
type: AnswerComment
type: Comment
has text: @jgubby: your last paragraph doesn't seem correct: you cannot read a 64-bit volatile that would have 32 bit from one write and the other 32 bit from another write.
comment on: http://stackoverflow.com/a/2694489
score: 2

http://stackoverflow.com/comment/2683545
score: 0
has text: You said you are comparing two array of integers. But, you took only one array a[i] and comparing the elements of same array. Are you using only one array and storing the elements 1,2,3,4,3,1,2,4 in this format ?
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2665593

http://stackoverflow.com/comment/2800985
type: Comment
comment on: http://stackoverflow.com/a/2768076
type: AnswerComment
has text: I still would pull it out into a private helper method rather than leave a "scary looking" conditional block in the code - "what does that do?" that way, if you ever do need to use it again, you can use the refactoring tools in your IDE to move the method to the utility class. having the named method helps to document the intent of the code, which is always a good thing, IMO. (and the overhead of the non var-args version is probably barely measurable.)
score: 8

http://stackoverflow.com/comment/2802720
score: 2
comment on: http://stackoverflow.com/a/2769474
type: AnswerComment
has text: @theband: You *can* have multiple `DispatcherServlets`, if your architecture makes more sense that way, but usually there's no reason to.
type: Comment

http://stackoverflow.com/comment/3222896
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2719918
has text: You can't really add generics to a class name, but you can add generics to the class header (definition). The advantages of using it are fewer casts and improved readability among others; http://www.angelikalanger.com/GenericsFAQ/FAQSections/ProgrammingIdioms.html#Topic1

http://stackoverflow.com/a/3051504
type: Answer
has body: The compiler wants you to write this: private static List&lt;String&gt; list = new ArrayList&lt;String&gt;(); because otherwise, you could add any type you like into list, making the instantiation as new ArrayList&lt;String&gt;() pointless. Java generics are a compile-time feature only, so an object created with new ArrayList&lt;String&gt;() will happily accept Integer or JFrame elements if assigned to a reference of the "raw type" List - the object itself knows nothing about what types it's supposed to contain, only the compiler does.
upvote count: 14
score: 14
downvote count: 0
answers question: http://stackoverflow.com/q/2770321

anonymous-class
tags question: http://stackoverflow.com/q/2681550
tag name: anonymous-class
tags question: http://stackoverflow.com/q/2699299
type: Tag
tags question: http://stackoverflow.com/q/2659517

http://stackoverflow.com/a/69199418
score: 1
answers question: http://stackoverflow.com/q/2745003
downvote count: 0
has body: As other people have mentioned you can't disable the GC. However, you can choose to use the experimental 'Epsilon' garbage collector which will never actually perform any garbage collections. Warning: it will crash if your JVM runs out of memory (because it's not doing any garbage collections). There's more info (including the command-line switch to use) at: http://openjdk.java.net/jeps/318 Good luck!
type: Answer
upvote count: 1

http://stackoverflow.com/a/2598413
answers question: http://stackoverflow.com/q/2598383
type: Answer
downvote count: 0
score: 1
has body: You need to decide which is the first thing to sort by, and which is the second. Once you decide that, you simply implement the compareTo method like so: @Override public int compareTo(Product o) { int result = this.model.compareTo(o.model); if (result == 0) return String.valueOf(this.power).compareTo(String.valueOf(o.power)); else return result; } Or, if you don't want to change the compareTo method, you can write your own Comparator like so: public class ProductComparator implements Comparator&lt;Product&gt; { public int compare(Product p1, Product p2) { int result = p1.model.compareTo(p2.model); if (result == 0) return String.valueOf(p1.power).compareTo(String.valueOf(p2.power)); else return result; } }
has comment: http://stackoverflow.com/comment/2607122
has comment: http://stackoverflow.com/comment/2607201
has comment: http://stackoverflow.com/comment/2607240
upvote count: 1

http://stackoverflow.com/comment/2613204
comment on: http://stackoverflow.com/a/2603571
score: 0
type: Comment
has text: Again thanks Peter! I had been pounding my head on this for days until you pointed this out.
type: AnswerComment

http://stackoverflow.com/comment/2642015
comment on: http://stackoverflow.com/a/2628855
score: 0
type: Comment
has text: I was stuck playing around with looking behind for `\G` (if previous character wasn't a match, then you also can't match if you're within the span of `word`, etc), which _perhaps_ can solve the non-overlap variant. Also previously I also tried something like yours but with the mistake of putting the positive lookahead AFTER the finite rep (which is also the problem I had before with `repeatBegin`). Anyway, good job again! I wish I can double-upvote this!
type: AnswerComment

http://stackoverflow.com/comment/2728969
type: AnswerComment
has text: It's important to note that "benchmarks are a crock" - not just the benchmarks published as the benchmarks game - http://shootout.alioth.debian.org/flawed-benchmarks.php
type: Comment
score: 3
comment on: http://stackoverflow.com/a/2705047

http://stackoverflow.com/a/2654728
has comment: http://stackoverflow.com/comment/2671400
type: Answer
has comment: http://stackoverflow.com/comment/2671153
downvote count: 0
score: 7
answers question: http://stackoverflow.com/q/2654709
upvote count: 7
has body: Sounds like you need something close to a lightweight db. Have you looked at/considered Java DB? A light db with a single, indexed table would basically be a disk-based, thread-safe hash map.

http://stackoverflow.com/a/2657137
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/2674015
type: Answer
upvote count: 1
has body: Not a real answer since it's already given (hence CW), but I couldn't resist (re)writing the isPalindrome() method ;) public static boolean isPalindrome(String s) { return new StringBuilder(s).reverse().toString().equals(s); }
answers question: http://stackoverflow.com/q/2656873

http://stackoverflow.com/a/2760449
type: Answer
has body: The embedded browser is the Internet Explorer on Windows, and Mozilla on Linux. We use it too, but it works perfectly and is not slow at all. If you want to let it appear faster, you should load the page and make the browser visible afterwards.
score: 0
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2657201
answers question: http://stackoverflow.com/q/2657201

http://stackoverflow.com/a/13305509
has comment: http://stackoverflow.com/comment/58527872
score: 9
answers question: http://stackoverflow.com/q/2711858
upvote count: 9
has comment: http://stackoverflow.com/comment/24954389
type: Answer
has body: I would also suggest extending TextView and other controls, but it would be better I consider to set up font in constructs. public FontTextView(Context context) { super(context); init(); } public FontTextView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public FontTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(); } protected void init() { setTypeface(Typeface.createFromAsset(getContext().getAssets(), AppConst.FONT)); }
downvote count: 0

http://stackoverflow.com/comment/2651587
type: Comment
comment on: http://stackoverflow.com/a/2637415
score: 0
type: AnswerComment
has text: I agree indeed that it "feels better" to write the interface for what it should be and do, without having implementation in mind.

http://stackoverflow.com/comment/2629169
has text: For the love of God, please don't use AWT! Developing as a web-app has numerous advantages - not the least of which is easier deployment.
score: 2
type: AnswerComment
comment on: http://stackoverflow.com/a/2617298
type: Comment

http://stackoverflow.com/comment/2772745
type: Comment
score: 1
has text: 3) e.g. unused imports can be removed in Eclipse using one single command invoked on whole code-base:)... I think that warning are not so important as you suggest, but when there are thousands, it often means that the project is rotten - conventions, design, code quality, this is just adding to technical debt. I would suggest adding some metric and convention checking tools and add break rule for the build server to avoid at least some quality issues.
comment on: http://stackoverflow.com/a/2743616
type: AnswerComment

http://stackoverflow.com/comment/127077899
score: 0
type: AnswerComment
has text: Excellent solution with invokeAll!
comment on: http://stackoverflow.com/a/38710673
type: Comment

http://stackoverflow.com/comment/33136431
type: Comment
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/2677260
has text: `@Transient` annotation on the getter is all that is needed

http://stackoverflow.com/a/2718649
upvote count: 1
downvote count: 1
has comment: http://stackoverflow.com/comment/4332481
answers question: http://stackoverflow.com/q/2718560
score: 0
type: Answer
has body: The synchronized keyword is used to acquire and release the lock on a Monitor. Like Mutexes, Monitors are used for concurrency control, but they are not the same. Using synchronized in itself is not a mistake, but it can be a low-level construct for using with multi-threading, and inappropriate use can quickly lead to multi-threading errors.

http://stackoverflow.com/a/2716929
has body: C++ std::exception_ptr allows you store exceptions. So it should be possible to embed exceptions in other exceptions and give you the impression that you have the stack on thrown exceptions. This could be useful if you want to know the root cause of the actual exception.
has comment: http://stackoverflow.com/comment/2742558
score: 0
has comment: http://stackoverflow.com/comment/2745032
type: Answer
answers question: http://stackoverflow.com/q/2716749

http://stackoverflow.com/comment/2821175
score: 1
has text: If you think a Map structure with a hash is not feasible, then this is probably the best answer. Your current call to `noDuplicates.indexOf(entity)` will have worst case performance of `O(N)` whereas a call to `TreeSet.contains()` can guarantee you `O(log(N))` performance. With a little effort on the `Comparator`, you can make it use your existing `Entity.equals` method too. (@rati: this is pretty much what you said...just adding more details)
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2785525

http://stackoverflow.com/comment/2674780
type: AnswerComment
comment on: http://stackoverflow.com/a/2652087
score: 0
has text: on pagevalidate(), how to get this window.submittrigger?
type: Comment

http://stackoverflow.com/comment/23213639
comment on: http://stackoverflow.com/a/2647000
type: Comment
score: 1
has text: Old question, but link seems to be broken.
type: AnswerComment

sql-server-express
tag name: sql-server-express
tags question: http://stackoverflow.com/q/2746488
type: Tag

http://stackoverflow.com/q/2724639
tagged with: windows
has answer: http://stackoverflow.com/a/2724655
accepted answer: http://stackoverflow.com/a/2724655
type: AnsweredQuestion
downvote count: 0
tagged with: java
type: Question
score: 3
upvote count: 3
has title: On Windows 7: Same path but Explorer & Java see different files than Powershell
answer count: 2
tagged with: filesystems
possible better answer: http://stackoverflow.com/a/2724694
has answer: http://stackoverflow.com/a/2724694
favorite count: 0
has body: Submitted for your approval, a story about a poor little java process trapped in the twilight zone... Before I throw up my hands and just say that the NTFS partition is borked is there any rational explanation of what I am seeing. I have a file with a path like this C:\Program Files\Company\product\config\file.xml I am reading this file after an upgrade and seeing something wonky. Eclipse and my Java app are still seeing the old version of this file while some other programs see the new version. The test that convinced my it was not my fat finger that caused the problem was this: In Explorer I entered the above path and Explorer displayed the old version of the file. Forcing Explorer to reload via Ctrl-F5 still yields the old version. This is the behavior I get in Java. Now in PowerShell I enter more "C:\Program Files\Company\product\config\file.xml" I cut and past the path from Explorer to make sure I am not screwing anything up and it shows me the new version of the file. So for the programming aspect of this, is there a cache or some system component that would be storing this stale reference. Am I responsible for checking or reseting that for some class of files. I can imagine somebody being "creative" in how xml files are processed to provide some bell or whistle. But it could be a case of just being borked. Any insights appreciated...Thanks!

http://stackoverflow.com/comment/2738406
score: 0
type: AnswerComment
has text: @Thomas: Not really... pushing binary data through a PrintWriter is like putting a square peg in a round hole. Why can you not change the filters? Is there really nothing you can do about them?
type: Comment
comment on: http://stackoverflow.com/a/2713124

http://stackoverflow.com/q/2723829
type: Question
tagged with: servlets
score: 0
has answer: http://stackoverflow.com/a/2723984
answer count: 1
tagged with: url
has body: My objects are stored online in two different places : &lt;1> On my nmjava.com site, where I can put them in a directory called "Dir_My_App/Dir_ABC/" &lt;2> On Google App Engine datastore When my Java app runs it checks both places for the objects, I designed the app so that it tries to get an object from a Url, it doesn't care whether it's an object in a directory or an object returned by a servlet. My_Object Get_Object(String Site_Url,String Object_Path) { ... get object by the name of Object_Path from the Site_Url ... } Now the request Url for my web site nmjava.com might look like this : http://nmjava.com/Dir_My_App/Dir_ABC/My_Obj_123 [ In a directory ] Or in the case of Google App Engine servlet : http://nm-java.appspot.com/Check_License/Dir_My_App/Dir_ABC/My_Obj_123 [ Non exist ] The "Object_Path" was generated by my app automatically. It can now get the object from my site by the above method like this : My_Object Get_Object("http://nmjava.com","/Dir_My_App/Dir_ABC/My_Obj_123"); In the Google App Engine, my servlet is running and ready to serve the object, if the request comes in correctly, but since I don't want to design my app to know whether the object is in one site's directory or in other site's datastore, I need to design the servlet to catch the non exist Url, such as the one above, and be able to make a call : My_Object Get_Object("http://nm-java.appspot.com/Check_License","/Dir_My_App/Dir_ABC/My_Obj_123"); So my question is : When a request comes into the servlet with a non exist Url, how should it catch it and analyze the url in order to respond properly, in my case it should know that : http://nm-java.appspot.com/Check_License/Dir_My_App/Dir_ABC/My_Obj_123 is asking for the object "My_Obj_123" [ ignore the dirs ] and return the object from the datastore. Now I'm getting this : Error: Not Found The requested URL /Check_License/Dir_My_App/Dir_ABC/My_Obj_123 was not found on this server. Where in my servlet and how do I detect the request for this no…
accepted answer: http://stackoverflow.com/a/2723984
type: AnsweredQuestion
has title: How to catch non exist requested URL in Java servlet?
tagged with: java

http://stackoverflow.com/a/65322942
downvote count: 0
score: 1
has body: Try this one updated intent google map address location find out Uri gmmIntentUri1 = Uri.parse("geo:0,0?q=" + Uri.encode(address)); Intent mapIntent1 = new Intent(Intent.ACTION_VIEW, gmmIntentUri1); mapIntent1.setPackage("com.google.android.apps.maps"); startActivity(mapIntent1);
upvote count: 1
answers question: http://stackoverflow.com/q/2662531
type: Answer

http://stackoverflow.com/comment/2720982
comment on: http://stackoverflow.com/a/2697983
type: Comment
score: 0
type: AnswerComment
has text: As an alternative though you could check that the device is roaming and check that using data services is on and warn the user and then allowing them to switch it off manually

http://stackoverflow.com/q/2623995
upvote count: 16
type: AnsweredQuestion
has title: Swing's KeyListener and multiple keys pressed at the same time
score: 16
tagged with: swing
type: Question
tagged with: java
tagged with: keylistener
has answer: http://stackoverflow.com/a/2624127
has answer: http://stackoverflow.com/a/56836707
has answer: http://stackoverflow.com/a/2624161
answer count: 3
downvote count: 0
has body: is there any conventional way in swing of tracking down the events, when two keyboard keys are pressed at the same time? I have a couple of ideas e.g. remembering the key and event generation time so that we could in a consecutive event handler invocation check the time difference between these two events and decide, whether it's a two-button event or not. But it looks like a kludge.
possible better answer: http://stackoverflow.com/a/2624127
accepted answer: http://stackoverflow.com/a/2624161
favorite count: 0

http://stackoverflow.com/a/43227684
type: Answer
score: 2
downvote count: 0
has body: Distributed ID generation can be archived with Redis and Lua. The implementation available in Github. It produces a distributed and k-sortable unique ids.
upvote count: 2
answers question: http://stackoverflow.com/q/2671858

http://stackoverflow.com/a/42881376
downvote count: 0
answers question: http://stackoverflow.com/q/2654709
upvote count: 6
type: Answer
score: 6
has body: Chronicle Map implements ConcurrentMap and persists data to disk via mapping it's memory to a file. Chronicle Map is conceptually very similar to MapDB (provides similar builder API and Map interface), but Chronicle Map is times faster than MapDB and has much better concurrency (Chronicle Map uses highly striped multi-level spin locks).

import
type: Tag
tags question: http://stackoverflow.com/q/2774747
tag name: import
tags question: http://stackoverflow.com/q/2611565
tags question: http://stackoverflow.com/q/2638016
tags question: http://stackoverflow.com/q/2627653
tags question: http://stackoverflow.com/q/2748232
tags question: http://stackoverflow.com/q/2754323
tags question: http://stackoverflow.com/q/2681161

http://stackoverflow.com/q/2678035
has comment: http://stackoverflow.com/comment/2697503
tagged with: servlets
has comment: http://stackoverflow.com/comment/2697332
answer count: 2
downvote count: 0
favorite count: 0
possible better answer: http://stackoverflow.com/a/2678054
has answer: http://stackoverflow.com/a/2678054
has answer: http://stackoverflow.com/a/2678076
has title: Is Java File object from a MultipartRequest written to disk as temp file or stored in memory?
type: AnsweredQuestion
has body: If I accept a file from a MultipartRequest and call File f = request.getFile("fileName"); Is the file written to disk (as a temp file) or is it only stored in memory at this point?
score: 1
tagged with: java
upvote count: 1
type: Question
accepted answer: http://stackoverflow.com/a/2678076

http://stackoverflow.com/a/2734447
has comment: http://stackoverflow.com/comment/2794055
accepted answer of: http://stackoverflow.com/q/2734106
upvote count: 3
answers question: http://stackoverflow.com/q/2734106
has comment: http://stackoverflow.com/comment/2762787
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2832486
score: 3
type: Answer
has body: Not great but you can always write the stream to a temporary file, and use the available method.

http://stackoverflow.com/comment/2793544
comment on: http://stackoverflow.com/q/2760896
score: 0
type: QuestionComment
has text: It's SPARQL, not SPARKQL. That might help you when googling...
type: Comment

http://stackoverflow.com/a/2699826
has comment: http://stackoverflow.com/comment/2722615
type: AcceptedAnswer
downvote count: 1
has body: Apparently you are trying to find in values. So here is something that would work: Map&lt;String, String&gt; m = new HashMap&lt;String, String&gt;(); .. List&lt;String&gt; result = new ArrayList&lt;String&gt;(); for(String s: m.values()){ if(s.equals("5")){ result.add(s); } } Also, watch for nulls in your if statement.
has comment: http://stackoverflow.com/comment/2722511
upvote count: 3
type: Answer
answers question: http://stackoverflow.com/q/2699754
score: 2
accepted answer of: http://stackoverflow.com/q/2699754
has comment: http://stackoverflow.com/comment/27369207
has comment: http://stackoverflow.com/comment/2722848

http://stackoverflow.com/comment/2807527
type: AnswerComment
has text: thanks :) I've been facing this problem for a while, and this only just hit me... Should've been an automatic reaction to the problem as it seems to have been with you
comment on: http://stackoverflow.com/a/2773814
type: Comment
score: 0

http://stackoverflow.com/q/2727849
tagged with: swing
type: Question
score: 20
accepted answer: http://stackoverflow.com/a/2728764
answer count: 3
has answer: http://stackoverflow.com/a/4914045
has body: Assume we have the following Swing application: final JFrame frame = new JFrame(); final JPanel outer = new JPanel(); frame.add(outer); JComponent inner = new SomeSpecialComponent(); outer.add(inner); So in this example we simply have an outer panel in the frame and a special component in the panel. This special component must do something when it is hidden and shown. But the problem is that setVisible() is called on the outer panel and not on the special component. So I can't override the setVisible method in the special component and I also can't use a component listener on it. I could register the listener on the parent component but what if the outer panel is also in another panel and this outer outer panel is hidden? Is there an easier solution than recursively adding component listeners to all parent components to detect a visibility change in SomeSpecialComponent?
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2728764
has answer: http://stackoverflow.com/a/2727875
has title: Detect if Java Swing component has been hidden
type: AnsweredQuestion
upvote count: 20
possible better answer: http://stackoverflow.com/a/4914045
tagged with: java

http://stackoverflow.com/a/2712892
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2738147
type: Answer
has body: Do the file loading in a loop and set the variable the condition depends on after the file has been successfully read. Use a try-catch block inside the loop and do the waiting in the catch-block.
downvote count: 0
accepted answer of: http://stackoverflow.com/q/2712880
answers question: http://stackoverflow.com/q/2712880
score: 1
upvote count: 1

http://stackoverflow.com/a/59004752
score: 0
type: Answer
has body: If you want to make sure that your $ operator does not suffer from XSS hack you can implement ServletContextListener and do some checks there. The complete solution at: http://pukkaone.github.io/2011/01/03/jsp-cross-site-scripting-elresolver.html @WebListener public class EscapeXmlELResolverListener implements ServletContextListener { private static final Logger LOG = LoggerFactory.getLogger(EscapeXmlELResolverListener.class); @Override public void contextInitialized(ServletContextEvent event) { LOG.info("EscapeXmlELResolverListener initialized ..."); JspFactory.getDefaultFactory() .getJspApplicationContext(event.getServletContext()) .addELResolver(new EscapeXmlELResolver()); } @Override public void contextDestroyed(ServletContextEvent event) { LOG.info("EscapeXmlELResolverListener destroyed"); } /** * {@link ELResolver} which escapes XML in String values. */ public class EscapeXmlELResolver extends ELResolver { private ThreadLocal&lt;Boolean&gt; excludeMe = new ThreadLocal&lt;Boolean&gt;() { @Override protected Boolean initialValue() { return Boolean.FALSE; } }; @Override public Object getValue(ELContext context, Object base, Object property) { try { if (excludeMe.get()) { return null; } // This resolver is in the original resolver chain. To prevent // infinite recursion, set a flag to prevent this resolver from // invoking the original resolver chain again when its turn in the // chain comes around. excludeMe.set(Boolean.TRUE); Object value = context.getELResolver().getValue( context, base, property); if (value instanceof String) { value = StringEscapeUtils.escapeHtml4((String) value); } return value; } finally { excludeMe.remove(); } } @Override public Class&lt;?&gt; getCommonPropertyType(ELContext context, Object base) { return null; } @Override public Iterator&lt;FeatureDescriptor&gt; getFeatureDescriptors(ELContext context, Object base){ return null; } @Override public Class&lt;?&gt; getType(ELContext context, Object base, Object property) { return null; } @Ov…
answers question: http://stackoverflow.com/q/2658922

http://stackoverflow.com/comment/2618536
has text: @Paul - then I would check in these methods, to find when you add a null attributes. (conditional breakpoint, maybe). Or simply protect adding the new attribute (but then you won't know the initial cause).
type: Comment
comment on: http://stackoverflow.com/a/2601211
type: AnswerComment
score: 0

http://stackoverflow.com/q/2687599
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2687756
has answer: http://stackoverflow.com/a/67447993
score: 6
has comment: http://stackoverflow.com/comment/2708419
has answer: http://stackoverflow.com/a/2687613
type: Question
tagged with: java
has answer: http://stackoverflow.com/a/2687763
has answer: http://stackoverflow.com/a/2687670
answer count: 8
has answer: http://stackoverflow.com/a/2687941
has answer: http://stackoverflow.com/a/2687604
downvote count: 0
favorite count: 0
has body: Say I have two lists: List&lt;String&gt;products = new ArrayList&lt;String&gt;(); products.add("computer"); products.add("phone"); products.add("mouse"); products.add("keyboard"); List&lt;String&gt;cart = new ArrayList&lt;String&gt;(); cart.add("phone"); cart.add("monitor"); I need to find how many items in the cart list exist in the products list. For the lists above, the answer would be 1 (as phone is in products and cart). If the cart list was: List&lt;String&gt;cart = new ArrayList&lt;String&gt;(); cart.add("desk"); cart.add("chair"); The result would be 0. If cart contained computer, mouse, desk, chair, the result would be 2 (for computer and mouse). Is there something in the Apache Commons Collections or the Google Collections API? I've looked through them and see ways to get a bag count, but not from another list, although it's possible I'm missing something. Right now, the only way I can think of is to iterate over the cart items and see if products contains the individual item and keep a count. I can't use containsAll as I need the count (not a boolean), and that would fail if all items in cart didn't exist in the product list (which can happen). I'm using Java 1.6 if that matters.
has comment: http://stackoverflow.com/comment/2708478
tagged with: java-6
tagged with: count
upvote count: 6
tagged with: list
has answer: http://stackoverflow.com/a/2687689
has title: Java - How to find count of items in a list in another list

http://stackoverflow.com/q/2757166
score: 1
tagged with: java
upvote count: 1
type: Question
tagged with: openid4java
has body: I have been looking at http://code.google.com/p/openid4java/wiki/SampleConsumer and it is hardcoded to work with type "fetch_request". Does it matter which type one wants, is there a way to tell or can one just use Fetch requests.
answer count: 2
downvote count: 0
has answer: http://stackoverflow.com/a/2768261
has title: How to find which attribute extensions an OpenId provider supports?
favorite count: 0
tagged with: openid
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2776901

http://stackoverflow.com/a/2824182
downvote count: 1
answers question: http://stackoverflow.com/q/2781086
upvote count: 30
has body: It's not necessary to know the internal layout of floating-point numbers. All you need is the pigeonhole principle and the knowledge that int and float are the same size. int is a 32-bit type, for which every bit pattern represents a distinct integer, so there are 2^32 int values. float is a 32-bit type, so it has at most 2^32 distinct values. Some floats represent non-integers, so there are fewer than 2^32 float values that represent integers. Therefore, different int values will be converted to the same float (=loss of precision). Similar reasoning can be used with long and double.
type: Answer
score: 29

http://stackoverflow.com/q/2723838
has answer: http://stackoverflow.com/a/55860428
has title: Determine file creation date in Java
has comment: http://stackoverflow.com/comment/2751268
downvote count: 0
upvote count: 140
favorite count: 0
type: Question
answer count: 8
has answer: http://stackoverflow.com/a/2723914
has answer: http://stackoverflow.com/a/26995786
has answer: http://stackoverflow.com/a/2724169
has answer: http://stackoverflow.com/a/75952448
tagged with: java
has body: There is another similar question to mine on StackOverflow (How to get creation date of a file in Java), but the answer isn't really there as the OP had a different need that could be solved via other mechanisms. I am trying to create a list of the files in a directory that can be sorted by age, hence the need for the file creation date. I haven't located any good way to do this after much trawling of the web. Is there a mechanism for getting file creation dates? BTW, currently on a Windows system, may need this to work on a Linux system as well. Also, I can't guarantee that a file naming convention would be followed where the creation date/time is embedded in the name.
tagged with: date
has answer: http://stackoverflow.com/a/32771882
score: 140
tagged with: filesystems
linked to: http://stackoverflow.com/q/741466
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/14455760
has answer: http://stackoverflow.com/a/2724009

http://stackoverflow.com/comment/90473958
type: AnswerComment
has text: ...and what happens when the server running that service goes down?
type: Comment
comment on: http://stackoverflow.com/a/2671961
score: 4

http://stackoverflow.com/a/2664360
upvote count: 24
answers question: http://stackoverflow.com/q/2664172
score: 24
has body: You can look at the numbers between a ConcurrentLinkedQueue and a BlockingQueue. What you will see is that CAS is noticeably faster under moderate (more realistic in real world applications) thread contention. The most attractive property of nonblocking algorithms is the fact that if one thread fails (cache miss, or worse, seg fault) then other threads will not notice this failure and can move on. However, when acquiring a lock, if the lock holding thread has some kind of OS failure, every other thread waiting for the lock to be freed will be hit with the failure also. To answer your questions, yes, nonblocking thread-safe algorithms or collections (ConcurrentLinkedQueue, ConcurrentSkipListMap/Set) can be significantly faster than their blocking counterparts. As Marcelo pointed out though, getting nonblocking algorithms correct is very difficult and requires a lot of consideration. You should read about the Michael and Scott Queue, this is the queue implementation for ConcurrentLinkedQueue and explains how to handle a two-way, thread-safe, atomic function with a single CAS.
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/2697976

http://stackoverflow.com/a/2752955
answers question: http://stackoverflow.com/q/2750545
has comment: http://stackoverflow.com/comment/2787566
type: AcceptedAnswer
downvote count: 0
type: Answer
score: 2
upvote count: 2
has body: This isn't an option in JBoss, unfortunately. The entire server operates off a single log4j configuration (specified by conf/jboss-log4j.xml), and your EJBs cannot change that. It's not ideal, but that's the way it is. Also, you don't need to add log4j.jar to server/default/lib, JBoss already has its own internal copy.
accepted answer of: http://stackoverflow.com/q/2750545
has comment: http://stackoverflow.com/comment/2788968

http://stackoverflow.com/q/2707583
linked to: http://stackoverflow.com/q/1379457
has title: Is javac enough to build an OSGi bundle?
upvote count: 2
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2707684
score: 2
has body: To produce a bundle from source using a tool such as javac, you need to provide it with a linear classpath. Unfortunately, it won't work in some situations still perfectly legal from an OSGi point of view: dependencies with embedded JAR in them; same packages contained by different dependencies. Since javac doesn't understand OSGi metadata, I won't be able to simply but the dependencies in a classpath. A finer package grained approach seems necessary. How this problem is addressed by people using OSGi in an automated process (continuous integration)? Strangely, there is a lot of resources on the web on how to create bundle JAR (creating the metadata, creating the JAR) provided you have the classes/inner JAR to put inside, but very few things on how actually get theses classes compiled. Let's take an example: my bundle need two other bundles to compile, both contains Xerces as an embedded JAR but in two different and incompatible versions. It is not a problem since only one of them export some packages of xerces my bundle is in turn importing. Not a very clean situation maybe but something that could "legaly" happen in an OSGi container without problem. Now, how can I compile it ? I can't put the two dependencies in my classpath (the embedded Xerces JAR won't be found by javac), I can't flatten then either (the two versions of Xerces will collide and maybe the one not exported would be first). If the ony solution is to create a "classpath" on a package level, not on a full bundle scale, javac is not usable at all.
tagged with: java
tagged with: classpath
type: Question
answer count: 2
downvote count: 0
favorite count: 0
tagged with: javac
tagged with: osgi
has answer: http://stackoverflow.com/a/2707705

cryptography
tag name: cryptography
tags question: http://stackoverflow.com/q/2681292
type: Tag
tags question: http://stackoverflow.com/q/2758869
tags question: http://stackoverflow.com/q/2665731
tags question: http://stackoverflow.com/q/2653180

http://stackoverflow.com/a/2882759
answers question: http://stackoverflow.com/q/2663949
has body: What I would try to do is isolate this behavior on the DAO Layer of the application. Using your example we would have: public class MyValidationBeanDAO { public void persist(MyValidationBean element) throws DAOException{ Set&lt;ConstraintViolation&gt; constraintViolations = validator.validate(element); if(!constraintViolations.isEmpty()){ throw new DAOException("1234", contraintViolations); } // it's ok, just persist it session.saveOrUpdate(element); } } And the following exception class: public class DAOException extends Exception { private final String errorCode; private final Set&lt;ConstraintViolation&gt; constraintViolations; public DAOException(String errorCode, Set&lt;ConstraintViolation&gt; constraintViolations){ super(String.format("Errorcode %s", errorCode)); this.errorCode = errorCode; this.constraintViolations = constraintViolations; } // getters for properties here } You could add some annotation information based on what property has not validated from here, but always doing this on the DAO method. I hope this helped.
type: Answer
score: 0

http://stackoverflow.com/a/2600481
downvote count: 0
has comment: http://stackoverflow.com/comment/16532029
answers question: http://stackoverflow.com/q/2598009
type: Answer
upvote count: 14
score: 14
has body: There's no real way to solve this in Java. You could use inner classes as a workaround: interface Alfa { void m(); } interface Beta { void m(); } class AlfaBeta implements Alfa { private int value; public void m() { ++value; } // Alfa.m() public Beta asBeta() { return new Beta(){ public void m() { --value; } // Beta.m() }; } } Although it doesn't allow for casts from AlfaBeta to Beta, downcasts are generally evil, and if it can be expected that an Alfa instance often has a Beta aspect, too, and for some reason (usually optimization is the only valid reason) you want to be able to convert it to Beta, you could make a sub-interface of Alfa with Beta asBeta() in it.
has comment: http://stackoverflow.com/comment/16532982

http://stackoverflow.com/comment/2683939
score: 4
type: Comment
type: QuestionComment
has text: hmm well we all knew what I meant so there was no difference as James say ..
comment on: http://stackoverflow.com/q/2665993

http://stackoverflow.com/a/2657357
score: 4
has body: An empty string "" is a string. It's not null. It doesn't have any character, not even \0 (which is just a character in Java, i.e. it's not a string terminator (JLS 10.9)). The following are all true: "" != null "" instanceof String "".contains("") The following are true exclusively for an empty string: "".matches("") "".matches("^$") "".length() == 0 "".isEmpty() This is also true for an empty string as well as all other strings containing only whitespaces: "".matches("\\s*"); This is because * is zero-or-more repetition of a pattern. Zero repetition of a whitespace is an empty string. The following is also true for all strings containing only whitespaces: s.trim().isEmpty() Further discussions I notiched that \s* detects one or more whitespaces. How do I make it so that it detects only whitespace? For example "test test" would be invalid? \s* matches zero or more whitespaces, and "test test".matches("\\s*") is false. However, you can find \s* in "test test", just as you can find it in any string, because \s* can match the empty string, and all strings contains(""). Figured it out... ^\s*[^a-zA-Z0-9\W]|^$ [^a-zA-Z0-9\W] doesn't really make any sense, and in fact "_".matches("^\\s*[^a-zA-Z0-9\\W]|^$"). Perhaps the confusion is because matches in Java needs to match the whole string (i.e. as if you've surrounded the entire pattern with ^ and $), so you can drop the anchors for matches but you'd need it for, say find. The proper regex for such methods would then be "^\\s*$", with the anchors explicitly included. The following is an excerpt from cletus's original answer (which is now deleted): Pattern p = Pattern.compile("^\\s*$", Pattern.MULTILINE); Matcher m = p.matcher(fileString); while (m.find()) { ... } The Pattern.MULTILINE allows ^ and $ to also match line terminators within fileString.
type: Answer
has comment: http://stackoverflow.com/comment/2677441
has comment: http://stackoverflow.com/comment/2676790
answers question: http://stackoverflow.com/q/2657325
accepted answer of: http://stackoverflow.com/q/2657325
upvote count: 4
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/a/67447993
has body: You can use Stream API to filter and count the elements of products in cart. import java.util.ArrayList; import java.util.List; public class Main { public static void main(String[] args) { List<String> products = new ArrayList<String>(); products.add("computer"); products.add("phone"); products.add("mouse"); products.add("keyboard"); List<String> cart = new ArrayList<String>(); cart.add("phone"); cart.add("monitor"); cart.forEach(item -> System.out.println(item + ": " + products.stream().filter(e -> e.equals(item)).count())); } } Output: phone: 1 monitor: 0 Alternatively, you can use Collections#frequency to print the frequency of each item of cart in products: for (String item : cart) { System.out.println(item + ": " + Collections.frequency(products, item)); } Alternatively, for each item in cart, you can iterate products and count the occurances: for (String item : cart) { int count = 0; for (String product : products) { if (item.equals(product)) count++; } System.out.println(item + ": " + count); }
score: 0
type: Answer
answers question: http://stackoverflow.com/q/2687599

http://stackoverflow.com/comment/2803519
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2749889
has text: Gamedev.net has a lot of good resources, including a good forum.
score: 0

http://stackoverflow.com/q/2647349
type: Question
tagged with: serializable
has answer: http://stackoverflow.com/a/2647361
score: 0
possible better answer: http://stackoverflow.com/a/2647361
has title: Variable reference problem when loading an object from a file in Java
tagged with: load
tagged with: variables
has body: I have a problem with the reference of a variable when loading a saved serialized object from a data file. All the variables referencing to the same object doesn't seem to update on the change. I've made a code snipped below that illustrates the problem. Tournament test1 = new Tournament(); Tournament test2 = test1; try { FileInputStream fis = new FileInputStream("test.out"); ObjectInputStream in = new ObjectInputStream(fis); test1 = (Tournament) in.readObject(); in.close(); } catch (IOException ex){ Logger.getLogger(Frame.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex){ Logger.getLogger(Frame.class.getName()).log(Level.SEVERE, null, ex); } System.out.println("test1: " + test1); System.out.println("test2: " + test2); After this code is ran test1 and test2 doesn't reference to the same object anymore. To my knowledge they should do that since in the declaration of test2 makes it a reference to test1. When test1 is updated test2 should reflect the change and return the new object when called in the code. Am I missing something essential here or have I been misstaught about how the variable references in Java works?
has answer: http://stackoverflow.com/a/2647386
accepted answer: http://stackoverflow.com/a/2647386
has answer: http://stackoverflow.com/a/2647452
has answer: http://stackoverflow.com/a/2647482
answer count: 4
tagged with: reference
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/comment/95510887
score: 8
comment on: http://stackoverflow.com/a/13858201
has text: Sometimes it is exactly what you want to achieve. Eg. I have seen Java-based microservices running always with UTC to avoid time zone problems. In these systems the database backend runs with UTC as well, so it is natural to "force" the JVM to UTC as well. What is important: you have to know what you are doing and what are the consequences...
type: AnswerComment
type: Comment

http://stackoverflow.com/a/2784894
downvote count: 0
type: Answer
has body: From SecretKeySpec doc: This constructor does not check if the given bytes indeed specify a secret key of the specified algorithm. For example, if the algorithm is DES, this constructor does not check if key is 8 bytes long, and also does not check for weak or semi-weak keys. In order for those checks to be performed, an algorithm-specific key specification class (in this case: DESKeySpec) should be used. I guess your bytes do not correspond to a valid key for AES. Here you can find an example on how to generate it. Suerte. UPDATE: See also here. UPDATE 2: As the other answer points out, you particular raw surely is invalid because your system does not support AES 256. Shorten it to 16 bytes (128 bits) and try again.
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/2784772

http://stackoverflow.com/a/5912307
type: Answer
score: 2
upvote count: 2
has body: You need to declare the ArrayList inside the class, not outside, like this: public class HelloItemizedOverlay extends ItemizedOverlay { private ArrayList&lt;OverlayItem&gt; mOverlays = new ArrayList&lt;OverlayItem&gt;(); }
answers question: http://stackoverflow.com/q/2769020
downvote count: 0

http://stackoverflow.com/comment/2657888
has text: Still doesn't make sense to me. Whats the point of having one column in a scroll pane and another another scroll pane with the other columns? You can either create two TableModels or as I suggested above share the TableModel and then remove TableColumns as you require.
comment on: http://stackoverflow.com/a/2642910
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/2618074
answers question: http://stackoverflow.com/q/2618059
score: 3
upvote count: 3
has comment: http://stackoverflow.com/comment/88490800
has comment: http://stackoverflow.com/comment/88451879
has body: Not a valid floating-point value (e.g. the result of division by zero) http://en.wikipedia.org/wiki/NaN
downvote count: 0
type: Answer

http://stackoverflow.com/q/2744851
has answer: http://stackoverflow.com/a/2745563
tagged with: java
has answer: http://stackoverflow.com/a/2744945
type: Question
answer count: 2
tagged with: api
downvote count: 0
tagged with: inheritance
has body: What if I have few factory methods returning non-public type and pairing set of methods which gives variables of this non-public type? This results with titled warning message in NetBeans. In result public API will contain only two pairing sets of methods. The reason is to make my type hierarchy sealed (like seald classes in Scala) and allow users only instantiate these types through factory methods. So we get DSL in some sense. For example, Schedule class represented by calendar fields' contraints. There are some types of contraints - Range, Singleton, List, FullSet - with NumberSet interface as a root. We don't want to expose these types and how Schedule interact with them. We just want the specification from the user. So we make NumberSet package-private. In class Schedule we create few factory-methods for constraints: NumberSet singleton(int value); NumberSet range(int form, int to); NumberSet list(NumberSet ... components); and some methods for creating Schedule object: Schedule everyHour(NumberSet minutes); Schedule everyDay(NumberSet minutes, NumberSet hours); User can only use them in the manner: Schedule s = Schedule.everyDay( singleton(0), list(range(10-15), singleton(8)) ); Is it bad idea?
accepted answer: http://stackoverflow.com/a/2744945
has title: Exporting non-public type through public API
score: 7
favorite count: 0
upvote count: 7
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2745563

http://stackoverflow.com/a/2716131
downvote count: 0
answers question: http://stackoverflow.com/q/2714795
type: Answer
upvote count: 2
has body: Chapter 7 of Beautiful Testing describes testing an XMPP chat client. I recommend reading the chapter. The conclusion is illustrative and may provide some pointers for your chat application: In our quest to create beautiful tests for checking XMPP protocol implementations, we started out by testing simple request-response protocols at the lowest level: the data sent of the network stream. After discovering that this form of testing does not really scale well, we abstracted out the protocol to a higher level, up to the point where the tests used only high-level data structures. By testing protocol behavior on a high level, we were able to write tests for more complex protocols without compromising the clarity of the tests. For the most complex protocols, writing scenarios helped to cover all of the possible situations that can arise in a protocol session. Finally, since XMPP is an open protocol with many different implementations, it's very important to test an XMPP application on the real network, to ensure interoperability with other implementations. By running small test programs regularly, we were able to test the system in its entirety, and check whether our implementation of the protocol plays together nicely with other entities on the network.
score: 2

http://stackoverflow.com/a/2617712
upvote count: 3
answers question: http://stackoverflow.com/q/2617606
downvote count: 0
has comment: http://stackoverflow.com/comment/2631987
score: 3
type: Answer
has body: I would recommend to include them (the icons) with your class files in a jar, say a folder called resources and only the icon loader needs to know the resources folders name within your jar.

http://stackoverflow.com/a/14904876
answers question: http://stackoverflow.com/q/2624145
has comment: http://stackoverflow.com/comment/128744969
upvote count: 4
downvote count: 0
score: 4
type: Answer
has body: In a well-designed exception framework, a distinction should be made between exceptions which are to some extent "expected" and those which are not. Java attempts to use checked versus unchecked exceptions for this. By that standard, IOException should be a checked exception. A fundamental problem, though, is that oftentimes code will be written with a (perhaps reasonable) expectation that a certain exception will not occur, and nothing can usefully be done to handle it if it does. If a method is declared as throwing a particular checked exception, Java allows its caller to ignore the exception if it declares itself as throwing that exception, but there's no means by which a method or code block can specify that certain exceptions from called methods are not expected to occur. A common anti-pattern is: try { methodThatsDeclaredAsThrowingFooExceptionButWont() } catch FooException Ex { // Never going to happen } The apparent assumption is that since the method won't throw FooException and the only reason the catch is there is to make the compiler happy, there's no reason for the catch to do anything. Insidious, because if a FooException does get thrown, for whatever reason, it will go undetected. An alternative is for a method which calls methodThatsDeclaredAsThrowingFooExceptionButWont to declare itself as throws FooException or throws Exception, but that isn't really appropriate either. If a method which is not expected to throw a FooException does, the system state is apt to be different from what it would be expected when a FooException is thrown. For example, suppose one attempts to load a document, but the document-load routine needs to read some non-document-specific translation tables which are supposed to be stored at a fixed location; if that attempt fails, having the IOException percolate up to the caller would imply that there was a problem loading the document being loaded. If the load-document routine isn't prepared to sensibly handle the possibility tha…

http://stackoverflow.com/comment/31885007
comment on: http://stackoverflow.com/a/3977963
score: 0
type: Comment
has text: -1 You cant stream a xlxs. Just like the OP mentioned
type: AnswerComment

http://stackoverflow.com/comment/2769241
type: AnswerComment
comment on: http://stackoverflow.com/a/2738860
has text: When I face a checked exception, what I usually do is chain it in my own checked exception, which is also fully documented. If needed I chain it in an unchecked exception, again of my own and document this. There is absolutely no need to throw further the IOException, SQLException or whatever other checked exception. Encapsulating them in a new one is perfect (checked or unchecked). The case I mentioned in the initial issue is special because there is no place for *any* exception: nor checked or unchecked.
score: 0
type: Comment

http://stackoverflow.com/q/2735736
has answer: http://stackoverflow.com/a/15990047
tagged with: constants
answer count: 9
score: 161
accepted answer: http://stackoverflow.com/a/2735906
tagged with: final
has title: Why is there no Constant feature in Java?
has answer: http://stackoverflow.com/a/35835148
possible better answer: http://stackoverflow.com/a/2736231
has answer: http://stackoverflow.com/a/2735830
has answer: http://stackoverflow.com/a/2736231
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2735794
has answer: http://stackoverflow.com/a/77296696
tagged with: java
has comment: http://stackoverflow.com/comment/59337733
has body: I was trying to identify the reason behind constants in Java I have learned that Java allows us to declare constants by using final keyword. My question is why didn't Java introduce a Constant (const) feature. Since many people say it has come from C++, in C++ we have const keyword. Please share your thoughts.
type: Question
has answer: http://stackoverflow.com/a/37687858
has answer: http://stackoverflow.com/a/2735906
downvote count: 0
favorite count: 0
linked to: http://stackoverflow.com/q/105014
has answer: http://stackoverflow.com/a/2735845
upvote count: 161

http://stackoverflow.com/comment/2794826
type: Comment
has text: @Steve: You're *MutableReference<T>* seems to try to reinvent the *AtomicReference<...>* Java API wheel :)
score: 0
type: QuestionComment
comment on: http://stackoverflow.com/q/2762489

http://stackoverflow.com/q/2659593
has answer: http://stackoverflow.com/a/2659740
type: AnsweredQuestion
tagged with: constants
upvote count: 167
has answer: http://stackoverflow.com/a/74264484
has answer: http://stackoverflow.com/a/14419212
tagged with: java
has body: I am learning Java and just found that the Interface can have fields, which are public static and final. I haven't seen any examples of these so far. What are some of the use cases of these Interface Constants and can I see some in the Java Standard Library?
type: Question
score: 167
has answer: http://stackoverflow.com/a/55877115
downvote count: 0
has answer: http://stackoverflow.com/a/50060182
answer count: 13
accepted answer: http://stackoverflow.com/a/2659740
has answer: http://stackoverflow.com/a/68993185
has answer: http://stackoverflow.com/a/51782756
has answer: http://stackoverflow.com/a/2659763
linked to: http://stackoverflow.com/q/66066
favorite count: 0
has answer: http://stackoverflow.com/a/2659610
possible better answer: http://stackoverflow.com/a/48376371
has answer: http://stackoverflow.com/a/2659626
has answer: http://stackoverflow.com/a/41447549
tagged with: interface
has answer: http://stackoverflow.com/a/48376371
has title: What is the use of interface constants?
has answer: http://stackoverflow.com/a/20539351

http://stackoverflow.com/q/2747416
has answer: http://stackoverflow.com/a/22041159
score: 1
accepted answer: http://stackoverflow.com/a/2749351
tagged with: java
upvote count: 1
tagged with: dom
has answer: http://stackoverflow.com/a/2747933
type: Question
tagged with: w3c
possible better answer: http://stackoverflow.com/a/2747933
tagged with: kml
answer count: 3
downvote count: 0
has answer: http://stackoverflow.com/a/2749351
favorite count: 0
has title: How to get the line number an xml element is on via the Java w3c dom api
has body: Is there a way to lookup the line number that a given element is at in an xml file via the w3c dom api? My use case for this is that we have 30,000+ maps in kml/xml format. I wrote a unit test that iterates over each file found on the hard drive (about 17GB worth) and tests that it is parseable by our application. When it fails I throw an exception that contains the element instance that was considered "invalid". In order for our mapping department (nobody here knows how to program) to easily track down the typo we would like to log the line number of the element that caused the exception. Can anybody suggest a way to do this? Please note we are using the W3C dom api included in the Android 1.6 SDK.
tagged with: android
type: AnsweredQuestion

http://stackoverflow.com/a/2648956
downvote count: 0
score: 1
has body: IFile interface seems to have some methods which would allow you to write some content: /** * Appends the entire contents of the given stream to this file. * ... */ public void appendContents(InputStream source, boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException;
upvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/2687741
answers question: http://stackoverflow.com/q/2642502

http://stackoverflow.com/comment/2616797
type: QuestionComment
comment on: http://stackoverflow.com/q/2606766
score: 1
has text: Are either the Strings or Integers unique by definition for your problem? If so, a Dictionary might be more appropriate.
type: Comment

http://stackoverflow.com/q/2772352
upvote count: 2
has body: My java application is generating an image(basically an org chart) for a jasper report. As org charts go, there's no way one can determine the final size of the image output. Also the image output can grow too large, that cropping the image is useless. Is it even possible to have the jasper report to dynamically resize it's image element without splitting the images?
answer count: 2
has answer: http://stackoverflow.com/a/2772412
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2772533
score: 2
tagged with: report
downvote count: 0
tagged with: java
has title: displaying really huge images in jasper reports
type: Question
tagged with: jasper-reports

http://stackoverflow.com/a/2728171
type: Answer
has body: Checkstyle and FindBugs and PMD. The latter two are much more than just style tools. But there is usually some effort to be put in, in order to get an agreement among the members of the team and, as well as for configuration of the tool.
score: 5
upvote count: 5
downvote count: 0
answers question: http://stackoverflow.com/q/2728139

http://stackoverflow.com/comment/2626697
comment on: http://stackoverflow.com/a/2615266
score: 0
type: AnswerComment
type: Comment
has text: Thanks, but this isn't really what I'm looking for. That is going to make it harder to separate my apps than easier, because now there is one monolithic Main class!

many-to-one
tags question: http://stackoverflow.com/q/2729168
tag name: many-to-one
type: Tag

http://stackoverflow.com/comment/2825470
type: Comment
comment on: http://stackoverflow.com/a/2759452
has text: I understand the need for a CREATE permission. My question was how to use it in spring security specifically. Thank you though.
type: AnswerComment
score: 0

http://stackoverflow.com/a/2720821
has comment: http://stackoverflow.com/comment/2747238
downvote count: 0
score: 19
type: AcceptedAnswer
upvote count: 19
answers question: http://stackoverflow.com/q/2720738
accepted answer of: http://stackoverflow.com/q/2720738
type: Answer
has body: These are the relevant JLS sections: JLS 5.1.1 Identity Conversion A conversion from a type to that same type is permitted for any type. JLS 5.2 Assignment Conversion Assignment conversion occurs when the value of an expression is assigned to a variable: the type of the expression must be converted to the type of the variable. Assignment contexts allow the use of one of the following: Identity conversion [...] In addition, if the expression is a constant expression of type byte, short, char or int : A narrowing primitive conversion may be used if the type of the variable is byte, short, or char, and the value of the constant expression is representable in the type of the variable. The above rules explain all of the following: short a = 4; // representable constant short b = 5; // representable constant short c = 5 + 4; // representable constant short d = a; // identity conversion short e = a + b; // DOES NOT COMPILE! Result of addition is int short z = 32767; // representable constant short z_ = 32768; // DOES NOT COMPILE! Unrepresentable constant As to why this doesn't compile: test(7); // DOES NOT COMPILE! There's no test(int) method! It's because the narrowing conversion with constant is only defined for assignments; not for method invocation, which has entirely different rules. JLS 5.3. Method Invocation Conversion Method invocation conversions specifically do not include the implicit narrowing of integer constants which is part of assignment conversion. The designers of the Java programming language felt that including these implicit narrowing conversions would add additional complexity to the overloaded method matching resolution process. Instead of explaining how method resolution works precisely, I will just quote Effective Java 2nd Edition, Item 41: Use overloading judiciously: The rules that determine which overloading is selected are extremely complex. They take up thirty-three pages in the language specification, and few programmers understand all of the…

http://stackoverflow.com/a/46910651
score: 11
upvote count: 11
answers question: http://stackoverflow.com/q/2777076
has body: Since 4.1, Apache HttpClients handles request and response compression. You don't need to compress request, no need to set any "Accept-Encoding" in request headers. It automatically handles response decompression as well, no need to handle Decompression of response. Till 4.3 it handles gzip and deflate. You can check ResponseContentEncoding api doc here. Just use: HttpClients.custom() which uses: HttpClientBuilder.create() If you want to check in library goto HttpClientBuilder it uses RequestAcceptEncoding &amp; ResponseContentEncoding You can disable it through "disableContentCompression()" HttpClient httpClient = HttpClients.custom() .setConnectionManager(cm) .disableContentCompression() //this disables compression .build(); Please make sure if you add any interceptor it can override that, use it carefully. HttpClient httpClient = HttpClients.custom() .setConnectionManager(cm) .setHttpProcessor(httpprocessor) //this interceptor can override your compression. .build();
downvote count: 0
type: Answer

http://stackoverflow.com/a/2765192
type: Answer
score: 2
upvote count: 2
answers question: http://stackoverflow.com/q/2765127
downvote count: 0
has body: The problem you are having is that you declare a global JPanel named l, but then when you instantiate JPanels in your constructor, you declare and assign a local scope JPanel named l. When you try to add a component in your actionPerformed, you are attempting to add it to the null global var.

http://stackoverflow.com/q/2728097
has body: I'm working on Java Swing application with Google Guice as an IOC container. Things are working pretty well. There are some UI problems. When a standard L&amp;F is replaced with Pushing pixels Substance L&amp;F application is not running due to Guice's Swing components creation outside of UI thread. Is there a way to tell Guice to create Swing components in the UI thread? Maybe I should create custom providers which will return Swing components after SwingUtilities.invokeAndWait(Runnable) creates them. I don't like the idea of running the whole application in UI thread, but maybe it's just a perfect solution.
upvote count: 5
has answer: http://stackoverflow.com/a/2728126
possible better answer: http://stackoverflow.com/a/2756337
accepted answer: http://stackoverflow.com/a/2729607
answer count: 3
score: 5
has answer: http://stackoverflow.com/a/2756337
tagged with: guice
downvote count: 0
has title: Guice creates Swing components outside of UI thread problem?
favorite count: 0
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2729607
tagged with: java
tagged with: swing
tagged with: ui-thread
type: Question
tagged with: instantiation

http://stackoverflow.com/q/2602038
has title: Java: substitute for ArrayList cos primitive types not allowed in ArrayList?
has answer: http://stackoverflow.com/a/2602072
has comment: http://stackoverflow.com/comment/2612085
has answer: http://stackoverflow.com/a/2602058
type: AnsweredQuestion
downvote count: 0
score: 1
tagged with: java
has body: Primitive types are not allowed in ArrayList, source. Partial solution: you can wrap prim.types such as int to Integer to form an extra class but a side effect. I want to index data, is there some substitute for ArrayList that allows primitive types?
linked to: http://stackoverflow.com/q/1301588
type: Question
has answer: http://stackoverflow.com/a/8240401
linked to: http://stackoverflow.com/q/2602636
tagged with: arraylist
has answer: http://stackoverflow.com/a/2602228
possible better answer: http://stackoverflow.com/a/2602399
has answer: http://stackoverflow.com/a/2602112
has answer: http://stackoverflow.com/a/2602399
accepted answer: http://stackoverflow.com/a/2602112
has answer: http://stackoverflow.com/a/2602113
upvote count: 1
has answer: http://stackoverflow.com/a/2602137
answer count: 10
has answer: http://stackoverflow.com/a/2602756
favorite count: 0
tagged with: primitive-types
has answer: http://stackoverflow.com/a/2602081

http://stackoverflow.com/a/11988335
has comment: http://stackoverflow.com/comment/18894543
score: 6
has body: This is how I did it - Create my own MockSSLSocketFactory (Class attached below) Use it to initialise DefaultHttpClient. Proxy settings need to be provided if a proxy is used. Initialising DefaultHTTPClient - SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); schemeRegistry.register(new Scheme("https", 443, new MockSSLSocketFactory())); ClientConnectionManager cm = new SingleClientConnManager(schemeRegistry); DefaultHttpClient httpclient = new DefaultHttpClient(cm); Mock SSL Factory - public class MockSSLSocketFactory extends SSLSocketFactory { public MockSSLSocketFactory() throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(trustStrategy, hostnameVerifier); } private static final X509HostnameVerifier hostnameVerifier = new X509HostnameVerifier() { @Override public void verify(String host, SSLSocket ssl) throws IOException { // Do nothing } @Override public void verify(String host, X509Certificate cert) throws SSLException { //Do nothing } @Override public void verify(String host, String[] cns, String[] subjectAlts) throws SSLException { //Do nothing } @Override public boolean verify(String s, SSLSession sslSession) { return true; } }; private static final TrustStrategy trustStrategy = new TrustStrategy() { @Override public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException { return true; } }; } If behind a proxy, need to do this - HttpParams params = new BasicHttpParams(); params.setParameter(AuthPNames.PROXY_AUTH_PREF, getClientAuthPrefs()); DefaultHttpClient httpclient = new DefaultHttpClient(cm, params); httpclient.getCredentialsProvider().setCredentials( new AuthScope(proxyHost, proxyPort), new UsernamePasswordCredentials(proxyUser, proxyPass));
downvote count: 0
answers question: http://stackoverflow.com/q/2703161
type: Answer
upvote count: 6

http://stackoverflow.com/q/2772966
type: Question
upvote count: 2
has answer: http://stackoverflow.com/a/2773025
has body: Somehow I don't like IDE very much, but I don't find a particular good tool to build java applications from source yet. I welcome all kinds of feedbacks!
has comment: http://stackoverflow.com/comment/2806735
has title: What's the best building tool for java besides ant?
has answer: http://stackoverflow.com/a/5013593
tagged with: build-automation
favorite count: 0
score: 2
downvote count: 0
answer count: 5
type: UnansweredQuestion
has comment: http://stackoverflow.com/comment/2806546
has answer: http://stackoverflow.com/a/2773001
tagged with: java
has answer: http://stackoverflow.com/a/2773016
has answer: http://stackoverflow.com/a/2773113

http://stackoverflow.com/q/2654949
tagged with: private-key
tagged with: jce
downvote count: 0
has answer: http://stackoverflow.com/a/2661495
has title: How to read a password encrypted key with java?
favorite count: 0
score: 16
tagged with: bouncycastle
type: UnansweredQuestion
has body: I have private key stored in file in PKCS8 DER format and protected by password. What is the easiest way to read it? Here is the code I use to load unencrypted one: InputStream in = new FileInputStream(privateKeyFilename); byte[] privateKeydata = new byte[in.available()]; in.read(privateKeydata); in.close(); KeyFactory privateKeyFactory = KeyFactory.getInstance("RSA"); PKCS8EncodedKeySpec encodedKeySpec = new PKCS8EncodedKeySpec(privateKeydata); PrivateKey privateKey = privateKeyFactory.generatePrivate(encodedKeySpec); It works fine for unencrypted keys with the same specification. By the way, I am using BouncyCastle. I can view this private key using following openssl command openssl pkcs8 -in ./privatekey.key -inform DER -passin pass:thisismypass Please, Help!!! I,ve posted some solutions in my own answer to this topic. But I keep question unanswered in case anybody can help with making it work without extra library, just BouncyCastle.
upvote count: 16
tagged with: pkcs#8
type: Question
tagged with: java
has answer: http://stackoverflow.com/a/3985508
answer count: 2

annotations
tags question: http://stackoverflow.com/q/2704099
tags question: http://stackoverflow.com/q/2786292
tags question: http://stackoverflow.com/q/2611986
type: Tag
tags question: http://stackoverflow.com/q/2603742
tags question: http://stackoverflow.com/q/2742809
tags question: http://stackoverflow.com/q/2766844
tags question: http://stackoverflow.com/q/2686733
tags question: http://stackoverflow.com/q/2611619
tags question: http://stackoverflow.com/q/2773594
tags question: http://stackoverflow.com/q/2785809
tags question: http://stackoverflow.com/q/2598712
tags question: http://stackoverflow.com/q/2603274
tags question: http://stackoverflow.com/q/2650169
tags question: http://stackoverflow.com/q/2601201
tags question: http://stackoverflow.com/q/2680321
tags question: http://stackoverflow.com/q/2745471
tags question: http://stackoverflow.com/q/2727710
tags question: http://stackoverflow.com/q/2691957
tag name: annotations
tags question: http://stackoverflow.com/q/2742463
tags question: http://stackoverflow.com/q/2745972
tags question: http://stackoverflow.com/q/2721194
tags question: http://stackoverflow.com/q/2615182

http://stackoverflow.com/comment/2681083
has text: Yes, that's basically what I suggested.
comment on: http://stackoverflow.com/a/2663385
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/a/2785650
downvote count: 0
has comment: http://stackoverflow.com/comment/2821151
answers question: http://stackoverflow.com/q/2785486
has body: It all depends on what that merge operation is doing. Does merge change any of the attributes that are compared when you do equals? If not, then you'll be amazed at how much faster it will be if you do this: First, define a hashCode for your Entity class that is compatible with your definition of equals. One common way to do this is: public int hashCode() { // assuming the four attributes that determine equality are called // attrFoo, attrBar, attrBaz, and attrQux int hash = 1; hash += attrFoo == null ? 0 : attrFoo.hashCode(); hash *= 37; hash += attrBar == null ? 0 : attrBar.hashCode(); hash *= 37; hash += attrBaz == null ? 0 : attrBaz.hashCode(); hash *= 37; hash += attrQux == null ? 0 : attrQux.hashCode(); return hash; } Then, use a HashMap so that you can find these things: Map&lt;Entity, Entity&gt; map = new HashMap&lt;Entity, Entity&gt;(); for(Entity entity: lstEntities) { if (map.containsKey(entity)) { map.get(entity).merge(entity); } else { map.put(entity, entity); } } return map.values(); // or keys(). Whichever. I should note that I feel a bit dirty writing the above code, because you really shouldn't make Map keys that aren't immutable, but this will work and be much, much faster than what you're doing now.
has comment: http://stackoverflow.com/comment/2821146
score: 1
has comment: http://stackoverflow.com/comment/2821157
upvote count: 1
has comment: http://stackoverflow.com/comment/2821156
has comment: http://stackoverflow.com/comment/2821225
type: Answer

http://stackoverflow.com/a/2776274
has body: In traditional way, I would have to sort the map according to the values, and take the first/last one. thanks No, you wouldn't. You would have to iterate through all values and at each step compare the current element with the smallest one seen so far. That's O(n), compared with O(n*log(n)) for sorting - a potentially huge difference. BTW, this is exactly how Collections.min() works.
answers question: http://stackoverflow.com/q/2776176
has comment: http://stackoverflow.com/comment/2811427
upvote count: 5
has comment: http://stackoverflow.com/comment/2810778
score: 5
downvote count: 0
type: Answer

http://stackoverflow.com/a/2635792
has body: I wouldn't recommend sorting the underlying list in getItem(), in my opinion a get..() method should be 'idempotent' and not have any externally-visible effect on its parent's state. In the case of your problem I would tackle it at the point at which the tweets are added to the container. You haven't included this part of your app source but it seems likely you are using an ArrayList. Perhaps you are querying the Twitter API for a list of tweets ordered most recently down, and calling add() on your ArrayList for each result, which is adding the tweets to the bottom of the list. Did you know you can insert at any point into an ArrayList? I would recommend reverse iterating through the results from the Twitter API and inserting each result at the top of your ArrayList with add(0, ....) rather than adding to the back of the list.
answers question: http://stackoverflow.com/q/2635708
type: AcceptedAnswer
downvote count: 0
type: Answer
has comment: http://stackoverflow.com/comment/2649819
has comment: http://stackoverflow.com/comment/2649845
upvote count: 14
has comment: http://stackoverflow.com/comment/2650401
accepted answer of: http://stackoverflow.com/q/2635708
score: 14

http://stackoverflow.com/q/2754339
upvote count: 5
tagged with: java
has body: how can I create an array of tuples in jsp (java) like (a:1, b:2) (c:3, d:4) ... ...
type: Question
has title: java: how do I create an array of tuples
score: 5
has answer: http://stackoverflow.com/a/2754487
downvote count: 0
tagged with: jsp
answer count: 6
has answer: http://stackoverflow.com/a/2754377
tagged with: data-structures
favorite count: 0
tagged with: tuples
has answer: http://stackoverflow.com/a/40316612
type: UnansweredQuestion
tagged with: set
has answer: http://stackoverflow.com/a/2754365
has answer: http://stackoverflow.com/a/2754407
has answer: http://stackoverflow.com/a/2754792

http://stackoverflow.com/comment/2795400
comment on: http://stackoverflow.com/a/2763140
type: AnswerComment
has text: If I want to do using my own data structure what is the procedure >
score: 0
type: Comment

http://stackoverflow.com/comment/2802961
comment on: http://stackoverflow.com/a/2769655
score: 0
type: AnswerComment
has text: Thanks. So something like ArrayBlockingQueue would probably be a good idea? I didn't think about my list being thread-safe.
type: Comment

http://stackoverflow.com/q/2697341
has answer: http://stackoverflow.com/a/2697904
downvote count: 0
has answer: http://stackoverflow.com/a/55266156
possible better answer: http://stackoverflow.com/a/3076005
tagged with: hsqldb
has answer: http://stackoverflow.com/a/3076005
favorite count: 0
linked to: http://stackoverflow.com/q/11435654
has answer: http://stackoverflow.com/a/11555106
has answer: http://stackoverflow.com/a/47174985
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2697904
has title: Inspect in memory hsqldb while debugging
tagged with: java
has answer: http://stackoverflow.com/a/64469850
tagged with: unit-testing
linked to: http://stackoverflow.com/q/7309359
type: Question
answer count: 8
has answer: http://stackoverflow.com/a/64469900
score: 42
upvote count: 42
has answer: http://stackoverflow.com/a/56969163
linked to: http://stackoverflow.com/q/24943894
has body: We're using hdsqldb in memory to run junit tests which operate against a database. The db is setup before running each test via a spring configuration. All works fine. Now when a tests fails it can be convinient to be able to inspect the values in the in memory database. Is this possible? If so how? Our url is: jdbc.url=jdbc:hsqldb:mem:testdb;sql.enforce_strict_size=true The database is destroyed after each tests. But when the debugger is running the database should also still be alive. I've tried connecting with the sqldb databaseManager. That works, but I don't see any tables or data. Any help is highly appreciated!

http://stackoverflow.com/comment/3583855
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2995898
type: Comment
has text: hi, I have the same issue, do you know where could be the stale files on Glassfishv3?

http://stackoverflow.com/a/2771917
downvote count: 0
upvote count: 2
has comment: http://stackoverflow.com/comment/113043957
has comment: http://stackoverflow.com/comment/62665455
has body: The closest thing that meets your needs is probably a distributed object cache such as Coherence or Terracotta. With these technologies different JVM instances can share objects.
answers question: http://stackoverflow.com/q/2771868
type: Answer
has comment: http://stackoverflow.com/comment/2805587
score: 2

http://stackoverflow.com/comment/2798981
has text: The first for-loop will only be run once because of the break statement.
score: 0
comment on: http://stackoverflow.com/q/2766465
type: Comment
type: QuestionComment

http://stackoverflow.com/comment/71514223
has text: A similar problem and the solution is discussed here - http://stackoverflow.com/questions/38942514/simple-java-program-100-times-slower-after-plugging-in-usb-hotspot/
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2608848

http://stackoverflow.com/comment/16922712
type: AnswerComment
has text: is it still for reading xml only? do you have a version that can operate the xml document like adding an attribute to an element?
type: Comment
comment on: http://stackoverflow.com/a/6860904
score: 0

http://stackoverflow.com/comment/2789001
comment on: http://stackoverflow.com/a/2729857
type: Comment
has text: Hey, if we merge the module-idea and the answerfrom @Chung Hu then we can do this: 1) the library declares a "css-factory"interface, it has a method createBundle() 2) the library uses cssresources from this bundle 3) we use deferred binding to give an implementation for this interface (look for "deffered binding" and "replace-with" in GWT docs) 4) put the factory implementation and the deferred binding in a separate module. This will be the style-module we want. [then we don't have to use the "super-source" tag I mentioned before... it's kinda ugly]
type: AnswerComment
score: 0

http://stackoverflow.com/a/2703841
upvote count: 2
type: Answer
score: 2
has body: Simply add some reference to the first frame in the second or pass the value you're interested in to the second frame before you display it. As for the code example you requested: public class SecondFrame extends JFrame { private JFrame firstFrame; public SecondFrame(JFrame firstFrame) { this.firstFrame = firstFrame; } } Now you can obtain everything there is to obtained from the firstFrame through the internal reference to it.
answers question: http://stackoverflow.com/q/2703834
downvote count: 0

http://stackoverflow.com/q/2682276
score: 0
answer count: 3
has answer: http://stackoverflow.com/a/2682978
has answer: http://stackoverflow.com/a/2682574
type: UnansweredQuestion
has body: private synchronized Map&lt;Team, StandingRow&gt; calculateStanding() { System.out.println("Calculate standing for group " + getName()); Map&lt;Team, StandingRow&gt; standing = new LinkedHashMap&lt;Team, StandingRow&gt;(); for (Team team : teams) { standing.put(team, new StandingRow(team)); } StandingRow homeTeamRow, awayTeamRow; for (Match match : matches.values()) { homeTeamRow = standing.get(match.getHomeTeam()); awayTeamRow = standing.get(match.getAwayTeam()); System.out.println("Contains key for " + match.getHomeTeam() + ": " + standing.containsKey(match.getHomeTeam())); System.out.println("Contains key for " + match.getAwayTeam() + ": " + standing.containsKey(match.getAwayTeam())); } } This is my code. matches contains 6 elements, but the problem is that after two matches no keys are anymore found in the standing map. The output is for example Contains key for Zuid-Afrika: true Contains key for Mexico: true Contains key for Uruguay: true Contains key for Frankrijk: true Contains key for Zuid-Afrika: false Contains key for Uruguay: false Contains key for Frankrijk: false Contains key for Mexico: false Contains key for Mexico: false Contains key for Uruguay: false Contains key for Frankrijk: false Contains key for Zuid-Afrika: false This is in a threaded environment, but the method is synchronized so I thought that this would not give a problem? I have also a simple unit test for this method and that works well.
has title: java and threads: very strange behaviour
tagged with: java
tagged with: thread-safety
has answer: http://stackoverflow.com/a/2682399
has comment: http://stackoverflow.com/comment/2701934
type: Question
has comment: http://stackoverflow.com/comment/2701863

http://stackoverflow.com/comment/2680364
type: AnswerComment
has text: This would work, but it will somehow break encapsulation, an event shouldn't try to handle itself :)
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2662802

http://stackoverflow.com/q/2747819
has comment: http://stackoverflow.com/comment/44178588
favorite count: 0
tagged with: serialization
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2747901
upvote count: 19
tagged with: java
has answer: http://stackoverflow.com/a/2747907
type: Question
has body: I am intending to serialize and deserialize a hashmap whose key is a string. From Josh Bloch's Effective Java, I understand the following. P.222 For example, consider the case of a hash table. The physical representation is a sequence of hash buckets containing key-value entries. Which bucket an entry is placed in is a function of the hash code of the key, which is not, in general guaranteed to be the same from JVM implementation to JVM implementation. In fact, it isn't even guaranteed to be the same from run to run on the same JVM implementation. Therefore accepting the default serialized form for a hash table would constitute a serious bug. Serializing and deserializing the hash table could yield an object whose invariants were seriously corrupt. My questions are: 1) In general, would overriding equals and hashcode of the key class of the map resolve this issue and the map can be correctly restored? 2) If my key is a String and the String class is already overriding the hashCode() method, would I still have problem described above. (I am seeing a bug which makes me think this is probably still a problem even though the key is String with overriding hashCode.) 3)Previously, I got around this issue by serializing an array of entries (key, value) and when deserializing I would reconstruct the map. I am wondering if there is a better approach. 4) If the answers to question 1 and 2 are that it still can't be guaranteed, could someone explain why? If the hashCodes are the same would they go to the same buckets across JVMs? Thanks, Grace
has answer: http://stackoverflow.com/a/13028970
has answer: http://stackoverflow.com/a/2747911
downvote count: 0
has answer: http://stackoverflow.com/a/11675975
has answer: http://stackoverflow.com/a/43091718
score: 19
has title: Serializing and deserializing a map with key as string
has answer: http://stackoverflow.com/a/2747959
answer count: 7
has comment: http://stackoverflow.com/comment/2777624

http://stackoverflow.com/a/2754279
has body: Window.Location.assign(newUrl) But in general, you want to avoid doing so, because you would loose all client state. You are better off changing the view via code, and then updating History (which updates the fragment url - the portion of the url after #).
upvote count: 10
downvote count: 0
answers question: http://stackoverflow.com/q/2754230
type: Answer
score: 10

http://stackoverflow.com/a/2747852
answers question: http://stackoverflow.com/q/2747553
has body: You can use the Highlighter that is available through JTextComponent's setHighlighter().
downvote count: 0
type: Answer
upvote count: 3
score: 3

http://stackoverflow.com/comment/103500889
type: Comment
has text: @maaartinus What conditions are too expensive to check in production? Can you give examples what you use assertions for?
comment on: http://stackoverflow.com/a/37605954
type: AnswerComment
score: 0

http://stackoverflow.com/comment/2741041
has text: I'll try a timer loop, =] I'm not much into effiency, but i'm guessing a timer loop is inefficient? :P :)
type: AnswerComment
comment on: http://stackoverflow.com/a/2710287
score: 0
type: Comment

http://stackoverflow.com/comment/2642547
has text: First of all, you should be aware that finalize method is called not just after the object is released, in other words, it is not like c++ destructor. GC decides when to collect it, after it is released. However, sometimes a java program may exit before garbage collecting the objects. That is the case the finalize method is not called.
type: AnswerComment
comment on: http://stackoverflow.com/a/2629249
score: 0
type: Comment

http://stackoverflow.com/comment/2693718
score: 0
type: AnswerComment
type: Comment
has text: -1 Much better to read the file line by line (blockwise) and copy only the lines which don't match the line to delete.
comment on: http://stackoverflow.com/a/2674899

http://stackoverflow.com/comment/2812578
comment on: http://stackoverflow.com/a/2777482
type: AnswerComment
score: 0
type: Comment
has text: Oh, you may find [this article](http://balusc.blogspot.com/2009/05/unicode-how-to-get-characters-right.html) useful as well to get more insight in the world of characters and bytes.

http://stackoverflow.com/a/2615761
downvote count: 0
has comment: http://stackoverflow.com/comment/125999184
score: 42
answers question: http://stackoverflow.com/q/2615712
type: Answer
has comment: http://stackoverflow.com/comment/40337000
upvote count: 42
has body: I'm not convinced that doing what you did fixes the problem; I think it masks yet another problem in your logic. To find the second highest is actually quite simple: static int secondHighest(int... nums) { int high1 = Integer.MIN_VALUE; int high2 = Integer.MIN_VALUE; for (int num : nums) { if (num &gt; high1) { high2 = high1; high1 = num; } else if (num &gt; high2) { high2 = num; } } return high2; } This is O(N) in one pass. If you want to accept ties, then change to if (num &gt;= high1), but as it is, it will return Integer.MIN_VALUE if there aren't at least 2 elements in the array. It will also return Integer.MIN_VALUE if the array contains only the same number.

http://stackoverflow.com/a/2751423
answers question: http://stackoverflow.com/q/2751378
score: 2
downvote count: 0
type: Answer
upvote count: 2
has body: You should take a look at server push technologies, like Comet for GWT

http://stackoverflow.com/comment/2662035
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2646638
has text: That's even more extreme than adding @SuppressWarnings("unchecked") to the relevant methods; my issue is that I'd like to see as many warnings as possible while suppressing this one.
score: 3

filewriter
tag name: filewriter
tags question: http://stackoverflow.com/q/2738448
type: Tag
tags question: http://stackoverflow.com/q/2669015

http://stackoverflow.com/q/2621017
score: 6
has answer: http://stackoverflow.com/a/2621122
has comment: http://stackoverflow.com/comment/2636915
has title: How to convert a long to a fixed-length 16-bit binary string?
has comment: http://stackoverflow.com/comment/2633326
downvote count: 0
has answer: http://stackoverflow.com/a/21839548
has answer: http://stackoverflow.com/a/2621146
favorite count: 0
has comment: http://stackoverflow.com/comment/2633320
has answer: http://stackoverflow.com/a/2621105
has answer: http://stackoverflow.com/a/2621075
type: UnansweredQuestion
upvote count: 6
has comment: http://stackoverflow.com/comment/2633316
tagged with: java
has answer: http://stackoverflow.com/a/2621117
has body: Hi i want to convert a long integer to binary but the problem is i want a fixed 16 bit binary result after conversion like if i convert 2 to 16 bit binary it should give me 0000000000000010 as ans can anyone help me ?
type: Question
has answer: http://stackoverflow.com/a/2621164
answer count: 8
has comment: http://stackoverflow.com/comment/2633413
has comment: http://stackoverflow.com/comment/2633402
has answer: http://stackoverflow.com/a/2621093

http://stackoverflow.com/a/2680091
type: Answer
answers question: http://stackoverflow.com/q/2680026
has body: @smessing did you properly implement equals and hashcode methods on your class that objects Foo and Face belong to? When you want to store an object in a List, Map or a Set then it is a requirement that equals and hashCode are implemented so they obey the standard contract as specified in the documentation. If these are not properly done, a get operation can result in unexpected results as you mentioned.
score: 0
has comment: http://stackoverflow.com/comment/2699733
upvote count: 2
downvote count: 2

http://stackoverflow.com/a/2703749
has comment: http://stackoverflow.com/comment/2727337
answers question: http://stackoverflow.com/q/2703689
upvote count: 1
has comment: http://stackoverflow.com/comment/2727274
score: 1
has body: When you state the requirements are you intending for them to be enforced by your method? The number may contain an optional minus sign, and an optional decimal part. There will not be any superfluous leading zeroes. If your intent is to have the method detect when those constraints are violated you will need additional to write additional unit-tests to ensure that contract is being enforced. What about testing for 1234.5678.91011? Do you expect your method to return 1,234.5678.91011 or just ignore the whole thing? Best to write a test to verify your expectations
downvote count: 0
type: Answer

http://stackoverflow.com/comment/15132419
has text: This explicitly refers to log4j and not slf4j generically
score: 5
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/10353716

http://stackoverflow.com/a/2745182
has comment: http://stackoverflow.com/comment/12228491
has comment: http://stackoverflow.com/comment/12230328
upvote count: 10
type: Answer
has comment: http://stackoverflow.com/comment/38194664
downvote count: 0
score: 10
has body: You can easily scale your image by using Image's getScaledInstance method: BufferedImage img = ImageIO.read(new File("image.jpg")); int scaleX = (int) (img.getWidth() * 0.5); int scaleY = (int) (img.getHeight() * 0.5); Image newImg = img.getScaledInstance(scaleX, scaleY, Image.SCALE_SMOOTH); Once you've obtained your scaled Image you can "convert" it back into a BufferedImage as described here. Finally, use the ImageIO class to write your BufferedImage to a file.
accepted answer of: http://stackoverflow.com/q/2744909
answers question: http://stackoverflow.com/q/2744909
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2775645
has comment: http://stackoverflow.com/comment/29200618

http://stackoverflow.com/q/2625229
has answer: http://stackoverflow.com/a/2626268
has answer: http://stackoverflow.com/a/2625254
has title: Extracting a given number of the highest values in a List
tagged with: sorting
has answer: http://stackoverflow.com/a/2626456
has comment: http://stackoverflow.com/comment/2646726
tagged with: highest
has answer: http://stackoverflow.com/a/2625263
has answer: http://stackoverflow.com/a/2625575
has answer: http://stackoverflow.com/a/2625245
favorite count: 0
upvote count: 5
has comment: http://stackoverflow.com/comment/2638207
answer count: 10
has answer: http://stackoverflow.com/a/2625803
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/2625295
possible better answer: http://stackoverflow.com/a/2625606
tagged with: java
has answer: http://stackoverflow.com/a/2625606
type: Question
has answer: http://stackoverflow.com/a/2625249
score: 5
accepted answer: http://stackoverflow.com/a/2625249
has body: I'm seeking to display a fixed number of items on a web page according to their respective weight (represented by an Integer). The List where these items are found can be of virtually any size. The first solution that comes to mind is to do a Collections.sort() and to get the items one by one by going through the List. Is there a more elegant solution though that could be used to prepare, say, the top eight items?
tagged with: algorithm

http://stackoverflow.com/a/2612582
type: AcceptedAnswer
type: Answer
accepted answer of: http://stackoverflow.com/q/2612478
downvote count: 0
answers question: http://stackoverflow.com/q/2612478
score: 1
has body: Here is the pseudocode for a simple RGB to HSV converter. It will give a H of UNDEFINED if the color is a shade of gray, otherwise H is between 0 and 6. x = min(R, G, B); V = max(R, G, B); if (V == x) { H = UNDEFINED S = 0 } else { if( R == x ) { f = G - B; i = 3; } else if( G == x ) { f = B - R; i = 5; } else { f = R - G; i = 1; } H = i - f /(V - x); S = (V - x)/V; } Now you can either convert all your pixels and bin them to construct your HSV histogram, or you can convert each bin of your RGB histogram to an HSV bin.
upvote count: 1

http://stackoverflow.com/q/2624145
has answer: http://stackoverflow.com/a/26923598
upvote count: 29
has comment: http://stackoverflow.com/comment/2638155
answer count: 6
has comment: http://stackoverflow.com/comment/2636918
has comment: http://stackoverflow.com/comment/2637490
has answer: http://stackoverflow.com/a/2624268
has answer: http://stackoverflow.com/a/14904876
favorite count: 0
tagged with: exception
has answer: http://stackoverflow.com/a/2624229
has comment: http://stackoverflow.com/comment/2640479
possible better answer: http://stackoverflow.com/a/26923598
has comment: http://stackoverflow.com/comment/2637543
has comment: http://stackoverflow.com/comment/2740543
has answer: http://stackoverflow.com/a/2624237
accepted answer: http://stackoverflow.com/a/2624237
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2637185
downvote count: 0
tagged with: java
has comment: http://stackoverflow.com/comment/2637450
has comment: http://stackoverflow.com/comment/2640579
score: 29
has answer: http://stackoverflow.com/a/2624367
type: Question
has body: Do you agree that the designers of Java class java.io.IOException should have made it an unchecked run-time exception derived from java.lang.RuntimeException instead of a checked exception derived only from java.lang.Exception? I think that class IOException should have been an unchecked exception because there is little that an application can do to resolve problems like file system errors. However, in When You Can't Throw An Exception, Elliotte Rusty Harold claims that most I/O errors are transient and so you can retry an I/O operation several times before giving up: For instance, an IOComparator might not take an I/O error lying down, but — because many I/O problems are transient — you can retry a few times, as shown in Listing 7: Is this generally the case? Can a Java application correct I/O errors or wait for the system to recover? If so, then it is reasonable for IOException to be checked, but if it is not the case, then IOException should be unchecked so that business logic can delegate handling of this exception to a separate system error handler.
has title: Should class IOException in Java have been an unchecked RuntimeException?

http://stackoverflow.com/q/2708408
has answer: http://stackoverflow.com/a/9196380
has title: Dispatch MouseEvent
favorite count: 0
accepted answer: http://stackoverflow.com/a/2872931
answer count: 3
has body: Is there a way to dispatch MouseEvent, same as dispatchKeyEvent using the KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(listener); that happens before the event transferred to the component ? I know I have 2 options 1) add mouse event to all compoenents recursive 2) use a transparent glasspane Does Java support this , or do I have to use the one of the options above? thank you
upvote count: 6
score: 6
tagged with: swing
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2842446
has answer: http://stackoverflow.com/a/2872931
has answer: http://stackoverflow.com/a/2842446
tagged with: java
tagged with: dispatchevent
has comment: http://stackoverflow.com/comment/2810746
tagged with: mouseevent
has comment: http://stackoverflow.com/comment/2810236
type: Question
has comment: http://stackoverflow.com/comment/2785995
downvote count: 0

http://stackoverflow.com/q/2704700
has answer: http://stackoverflow.com/a/2777203
has answer: http://stackoverflow.com/a/2712581
tagged with: rest
answer count: 5
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2734620
tagged with: web-services
linked to: http://stackoverflow.com/q/80799
has comment: http://stackoverflow.com/comment/41954630
tagged with: cxf
tagged with: java
type: Question
tagged with: jersey
has answer: http://stackoverflow.com/a/9704809
upvote count: 75
has answer: http://stackoverflow.com/a/2734549
has title: Java REST implementation: Jersey vs CXF
downvote count: 0
score: 75
has body: What do you think is the advantages/disadvantages between this two libraries? Which of these two are best suited for production environment? By the way I will be using JSON instead of XML. I also would like to know what library is most supported by the community e.g. tutorials, documentation.
has comment: http://stackoverflow.com/comment/4658730
favorite count: 0

http://stackoverflow.com/q/2730388
downvote count: 0
has comment: http://stackoverflow.com/comment/56640845
has answer: http://stackoverflow.com/a/2732459
has title: Hibernate: Safely reattach an object to the session
favorite count: 0
upvote count: 11
has comment: http://stackoverflow.com/comment/3189249
linked to: http://stackoverflow.com/q/912659
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2732340
score: 11
has body: I'm maintaining a cache of objects across hibernate sessions by storing (possibly-detached) objects in a map. When the cache gets a hit, I test if the object is already part of the session with Session.contains(object). If not, I re-attach it with Session.lock(object, LockMode.NONE). The problem is, if the same object was loaded previously in the session, it throws a org.hibernate.NonUniqueObjectException. Given a detached instance, I see no way to find out in advance if this exception will get thrown, without possibly hitting the database. There are a couple workarounds: Reattach all cached objects at the start of every transaction. Catch the NonUniqueObjectException and then call session.load(object.class, object.getId()); Neither of these are as clean as checking the session in advance for an object class + id. Is there any way to do that?
tagged with: java
tagged with: hibernate
type: Question
answer count: 2

http://stackoverflow.com/q/2730796
type: AnsweredQuestion
downvote count: 0
score: 1
favorite count: 0
possible better answer: http://stackoverflow.com/a/2730903
type: Question
has answer: http://stackoverflow.com/a/2730903
accepted answer: http://stackoverflow.com/a/2730932
has body: Supposing new audio and image types will be created, I want my filter to separate the images and audio files. Is there a way to recognize then?
upvote count: 1
has answer: http://stackoverflow.com/a/2730868
has title: Is there a way to identify audio or image files in java, without use the file extension?
tagged with: java
answer count: 3
tagged with: file
has answer: http://stackoverflow.com/a/2730932

http://stackoverflow.com/q/2646960
has answer: http://stackoverflow.com/a/2648952
type: Question
type: AnsweredQuestion
score: 3
tagged with: java
tagged with: hibernate
has body: In a simple inheritance tree, an abstract superclass has two subclasses. The subclasses both store a key-value pair, but but one will be holding a type Encrypted String, and the other one a plain old String. Now, my question is can I do this: @Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) public abstract Attribute { @Id private Integer id; @Column(name="attribute_key") private String key; } @Entity public EncryptedAttribute extends Attribute { @Column(name="attribute_value") private EncryptedString encryptedValue; } @Entity public UnEncryptedAttribute extends Attribute { @Column(name="attribute_value") private String plainValue; } The Encrypted String and plain String should both end up as varchars in the db, but can I store persistent attributes associated with different sub-classes in the same column? This would avoid the "swiss-cheese" side-effect of storing null values in columns which aren't used in a particular row.
answer count: 1
downvote count: 0
accepted answer: http://stackoverflow.com/a/2648952
tagged with: inheritance
favorite count: 0
has title: Can I reuse a column across subclasses in a Hibernate table-per-hierarchy inheritance strategy?
upvote count: 3

http://stackoverflow.com/a/2616743
downvote count: 0
has body: * The outbound port on the client side might change among packets. Is that third assumption correct Not if the client keeps using the same outbound socket. Sending the first datagram will cause a local bind, so the socket will be on a fixed local port from then on.
answers question: http://stackoverflow.com/q/2616057
has comment: http://stackoverflow.com/comment/2628533
upvote count: 3
type: Answer
score: 3

http://stackoverflow.com/a/2613945
answers question: http://stackoverflow.com/q/2613432
has comment: http://stackoverflow.com/comment/55222954
type: Answer
score: 110
has comment: http://stackoverflow.com/comment/99424913
has comment: http://stackoverflow.com/comment/25213751
upvote count: 110
has comment: http://stackoverflow.com/comment/2630243
downvote count: 0
has comment: http://stackoverflow.com/comment/2629521
has comment: http://stackoverflow.com/comment/99425581
has comment: http://stackoverflow.com/comment/40273359
has comment: http://stackoverflow.com/comment/113578981
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2613432
has comment: http://stackoverflow.com/comment/2629289
has body: You can use the "Replace" (or "Replace in Path" if you want to remove comments in multiple files) in the regular expression mode and then use this regular expression in the "Text to find" field: (/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/|[ \t]*//.*) and replace it with an empty string. Then press "All" to apply this replacement to the entire file or all the selected files. This will remove all block comments and line comments from your file. If you want only block comments to be removed, use this regex instead: (/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/) And if you want to just remove line comments, you can use this regex: ([ \t]*//.*) However, I should warn that this works only %99.99 of times. You might have a string variable defined in your file like: String myStr = "/** I am not a comment */"; This regex will turn this to: String myStr = "";

http://stackoverflow.com/comment/2777837
has text: Yes, his hash table is broken, not his key. Or perhaps he simply misdiagnosed the problem altogether.
comment on: http://stackoverflow.com/a/2747907
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2678720
type: AnswerComment
comment on: http://stackoverflow.com/a/2661386
type: Comment
has text: I think cletus is right - such a behavior is not strange at all, it's the common expected behavior. I'd be very pissed if I had to set a separate set of configuration values, when I wanted to use the one's provided by the os all the time. And if I don't want to use the OS's defaults there is an easy way to change them. After all - convention over configuration, right ;-)
score: 1

http://stackoverflow.com/a/2622764
has body: I would suggest that you don't bother. Most Unix-style MTAs invented and perfected deferred sending decades ago, and you shouldn't be reinventing the wheel. You'll do it poorly (in comparison to sendmail or postfix), and you'll miss something. My best advice is to use the Java Mail APIS javax.mail and let the MTA deal with the asynchronous part.
type: Answer
has comment: http://stackoverflow.com/comment/2643221
has comment: http://stackoverflow.com/comment/2643586
score: 4
accepted answer of: http://stackoverflow.com/q/2622721
upvote count: 4
answers question: http://stackoverflow.com/q/2622721
type: AcceptedAnswer
downvote count: 0

http://stackoverflow.com/comment/2780078
type: Comment
comment on: http://stackoverflow.com/a/2750012
has text: Does `double` satisfy the finance sector contract? Can you not control the rounding mode etc for `double` as well?
type: AnswerComment
score: 0

http://stackoverflow.com/q/2770476
has title: Wicket app in embedded Jetty causes UnsupportedClassVersionError
score: 0
has body: I've tried to run a Wicket app in an embedded Jetty, using this code: public static void main( String[] args ){ Server server = new Server(8080); Context root = new Context( server, "/", Context.SESSIONS ); FilterHolder filterHolder = new FilterHolder( new WicketFilter() ); filterHolder.setInitParameter("applicationClassName", cz.dw.test.WicketApplication.class.getName() ); root.addFilter( filterHolder, "/*" , Handler.ALL ); try { server.start(); } catch (Exception ex) { ex.printStackTrace(); } } But I got java.lang.UnsupportedClassVersionError: Bad version number in .class file. Switching the target class version for my app (1.6 -> 1.5) did not help. I use Sun JDK 1.6.0_17, Wicket 1.4.8, Jetty 6.1.24. When I run the app normally (deploy to Jetty or mvn jetty:run), it works fine. I tried to debug, but the JRE classes have no debug data. The stacktrace is of no use as it happens when loading the classes into JVM. Any ideas what could be wrong? How can I find which class is causing this? Thanks, Ondra
answer count: 1
accepted answer: http://stackoverflow.com/a/2770582
tagged with: wicket
tagged with: jetty
type: AnsweredQuestion
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/2770582

http://stackoverflow.com/q/2638590
favorite count: 0
has answer: http://stackoverflow.com/a/31715984
type: Question
upvote count: 155
has answer: http://stackoverflow.com/a/2638662
tagged with: reflection
tagged with: java
possible better answer: http://stackoverflow.com/a/20330416
has answer: http://stackoverflow.com/a/20330416
has title: Best way of invoking getter by reflection
accepted answer: http://stackoverflow.com/a/2638662
tagged with: getter
score: 155
has body: I need to get the value of a field with a specific annotation, So with reflection I am able to get this Field Object. The problem is that this field will be always private though I know in advance it will always have a getter method. I know that I can use setAccesible(true) and get its value (when there is no PermissionManager), though I prefer to invoke its getter method. I know that I could look for the method by looking for "get+fieldName" (though I know for example for boolean fields are sometimes named as "is+fieldName"). I wonder if there is a better way to invoke this getter (many frameworks use getters/setters to access the attributes so maybe they do in another way). Thanks
answer count: 4
type: AnsweredQuestion
downvote count: 0
has answer: http://stackoverflow.com/a/2638660

http://stackoverflow.com/comment/113875063
has text: This is not working on my Laptop. It shows int cannot be dereferenced error. How to correct it ?
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/10471029

http://stackoverflow.com/comment/133096265
has text: @Jack: a good practice for this example is to block IPs not user accounts
type: Comment
score: 0
comment on: http://stackoverflow.com/a/4713116
type: AnswerComment

http://stackoverflow.com/a/2647709
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2663285
has comment: http://stackoverflow.com/comment/2667454
has body: Yes. You could simply call rate = Rate.Good; for this specific case. But what I think you are really looking for is a successor function. Here you are: public class EnumTest extends TestCase { private enum X { A, B, C; public X successor() { return values()[(ordinal() + 1) % values().length]; } }; public void testSuccessor() throws Exception { assertEquals(X.B, X.A.successor()); assertEquals(X.C, X.B.successor()); assertEquals(X.A, X.C.successor()); } }
has comment: http://stackoverflow.com/comment/2663198
type: Answer
score: 11
has comment: http://stackoverflow.com/comment/2669892
downvote count: 0
has comment: http://stackoverflow.com/comment/2663251
accepted answer of: http://stackoverflow.com/q/2647677
has comment: http://stackoverflow.com/comment/2663610
has comment: http://stackoverflow.com/comment/2663565
answers question: http://stackoverflow.com/q/2647677
has comment: http://stackoverflow.com/comment/2663453
upvote count: 11
has comment: http://stackoverflow.com/comment/2663300
has comment: http://stackoverflow.com/comment/2682035

http://stackoverflow.com/a/2682399
has body: This is almost surely not a threading issue. I'm all but certain that the problem is in your Team class. It's probably not implementing hashCode()/equals() the right way. Review the javadoc for these two methods and implement them accordingly.
score: 9
type: Answer
has comment: http://stackoverflow.com/comment/2702277
has comment: http://stackoverflow.com/comment/2702309
answers question: http://stackoverflow.com/q/2682276
upvote count: 9
downvote count: 0
has comment: http://stackoverflow.com/comment/2702268

http://stackoverflow.com/comment/37362855
type: Comment
has text: my resource is on the test-classes directory and i can load the file with `Myclass.class.getClassLoader.getResource("/my/path")`. but doesn't work with `@ContextConfiguration(location = "classpath:/my/path")`
comment on: http://stackoverflow.com/a/2607409
score: 0
type: AnswerComment

http://stackoverflow.com/comment/2740786
has text: If you're going to put money on it, I'd suggest `SecureRandom` with a good seed. (And perhaps consider paid support.)
type: QuestionComment
comment on: http://stackoverflow.com/q/2715423
score: 2
type: Comment

http://stackoverflow.com/a/2676857
downvote count: 0
score: 27
type: Answer
answers question: http://stackoverflow.com/q/2676704
has body: I like the convention of just adding "s" to the type name when the type is an interface or a class you don't control. Examples of that in the JDK include Collections and Executors. It's also the convention used in Google Collections. When you're dealing with a class you have control over, I'd say utility methods belong on the class itself generally.
has comment: http://stackoverflow.com/comment/2696772
upvote count: 27

http://stackoverflow.com/comment/2757972
type: Comment
comment on: http://stackoverflow.com/a/2730543
score: 0
type: AnswerComment
has text: @GK I formatted it with correct indentation, there was no need to replace my edit :)

mozilla
tags question: http://stackoverflow.com/q/2755343
type: Tag
tag name: mozilla

http://stackoverflow.com/comment/2787449
has text: @Stephen Denne - in 10+ years of Java coding, I've yet to come across a situation where extending Throwable would have been a good idea. Granted, it is not impossible that such a situation might exist ...
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2756001
score: 5

http://stackoverflow.com/comment/2640745
comment on: http://stackoverflow.com/q/2627381
score: 0
has text: How do you know there is something wrong? In which way does the actual result differ from the expected?
type: Comment
type: QuestionComment

http://stackoverflow.com/a/2777032
upvote count: 1
has body: This depends on how your column is defined in mySQL. mySQL is the oddman out of databases in that VARCHAR and similar columns default to case insensitive matches. If you want XYZ and XyZ to be distinct legal options, you'll need to change your CREATE TABLE statement to create a case sensitive column (see docs for your version of mySQL.) It's likely something like this: CREATE TABLE code ( key VARCHAR(32) BINARY, value VARCHAR(32) BINARY )
downvote count: 0
has comment: http://stackoverflow.com/comment/2811594
score: 1
answers question: http://stackoverflow.com/q/2776942
type: Answer

http://stackoverflow.com/a/2699804
upvote count: 4
has body: The core of BigDecimal is the same in each language. If the limiting factors for performance are the mathematical operations in BigDecimal, then there will be no difference between the three languages, because they all use java.math.BigDecimal. Therefore, use the language which is easiest to read and understand (which is probably not java).
downvote count: 0
score: 4
has comment: http://stackoverflow.com/comment/2722927
type: Answer
answers question: http://stackoverflow.com/q/2699657

http://stackoverflow.com/comment/2815438
score: 0
has text: @jpanewbie Indeed. Last idea then: use a `default SYSDATE` for the update date too and set the update date to `null` in a `@PreUpdate` method.
type: AnswerComment
comment on: http://stackoverflow.com/a/2780348
type: Comment

http://stackoverflow.com/a/4749262
type: AcceptedAnswer
has body: This answer solved my problems: Sandbox against malicious code in a Java application
score: 0
type: Answer
answers question: http://stackoverflow.com/q/2626981
accepted answer of: http://stackoverflow.com/q/2626981

http://stackoverflow.com/a/2603839
has comment: http://stackoverflow.com/comment/2618214
type: Answer
score: 1
upvote count: 1
answers question: http://stackoverflow.com/q/2603745
downvote count: 0
has body: This blog post may be helpful: http://blog.notdot.net/2009/9/Distributed-Transactions-on-App-Engine (Even though the examples are in Python, the concept is exactly the same)

http://stackoverflow.com/comment/58464839
type: AnswerComment
score: 0
type: Comment
has text: Link is here: http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Freference%2Fpreferences%2Fjava%2Fcompiler%2Fref-preferences-building.htm. Not working for me anyway :(
comment on: http://stackoverflow.com/a/4224288

http://stackoverflow.com/comment/2668087
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2649145
has text: I had more or less the same problem... Have faith! http://stackoverflow.com/questions/179259

http://stackoverflow.com/comment/57362010
has text: The value added is that you're explicitly declaring the type is not known. There is no way to convey this information in pre-1.5 notation.
type: Comment
comment on: http://stackoverflow.com/a/2651648
score: 0
type: AnswerComment

http://stackoverflow.com/a/2722913
type: Answer
answers question: http://stackoverflow.com/q/2722742
score: 0
has body: This (untested): int test[] = {10212,10202,11000,11000,11010}; ArrayList&lt;Integer&gt; test2 = new ArrayList&lt;Integer&gt;(); for (int i : test) { int p = test2.size(); while (i &gt; 0) { test2.add(p, i % 10); i /= 10; } }

http://stackoverflow.com/comment/2793141
has text: never heard of it before, but googling for "terracotta distributed cache" gave me this: http://www.terracotta.org/confluence/display/labs/Distributed-Cache+Webcast
type: Comment
type: QuestionComment
score: 1
comment on: http://stackoverflow.com/q/2761177

http://stackoverflow.com/comment/2676782
type: Comment
type: QuestionComment
has text: sorry its a html weppage using gwt
score: 0
comment on: http://stackoverflow.com/q/2649631

http://stackoverflow.com/comment/27662914
comment on: http://stackoverflow.com/a/2620371
score: 0
has text: You have to login to see the content. :-(
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/4075094
comment on: http://stackoverflow.com/a/3307145
type: Comment
has text: Oh I was so excited for the JNLP, but apparently it doesnt like my macbook. So much for cross platform.
score: 0
type: AnswerComment

http://stackoverflow.com/comment/87718598
type: Comment
has text: @Anna: It's my pleasure - Thank you.
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/12832195

http://stackoverflow.com/a/2772321
type: Answer
score: 2
downvote count: 0
has body: Some of the largest existing ones are from the software development space (thats also the primary domain for desktop applications) like Eclipse or Netbeans or Rational Software architect. Another big one is the IBM DB2 Tools (not the database itself). (But if you want to see something as a reference better not take these because they are slow as hell).
accepted answer of: http://stackoverflow.com/q/2772259
answers question: http://stackoverflow.com/q/2772259
upvote count: 2
type: AcceptedAnswer

http://stackoverflow.com/a/2670452
type: Answer
accepted answer of: http://stackoverflow.com/q/2670414
has body: Use javaw -splash:resources\images\splash\splash.gif com.myproj.MyProjApp instead of what you have there.
upvote count: 12
type: AcceptedAnswer
score: 12
answers question: http://stackoverflow.com/q/2670414
downvote count: 0
has comment: http://stackoverflow.com/comment/2688954

plugin.xml
type: Tag
tag name: plugin.xml
tags question: http://stackoverflow.com/q/2779499

http://stackoverflow.com/a/3092926
score: 4
answers question: http://stackoverflow.com/q/2683361
upvote count: 4
has body: I'm not familiar with ORACLE, so I'm not up with the OLAP features that may or may not be built into the product. But in essence to get Cube type functionality from a relational engine, you need to build a Star or Snowflake schema represenation of your data. This involves categorising your data between FACTs and DIMENSIONs. Put simply, FACTS are the things you want to analyse, count, averag, aggregate etc. Examples of which are "OrderValue", "Quantity", "Count" etc. As you can see all of these are numeric types, so arguably FACTs are always numeric fields. DIMENSIONs on the other have are the things you want to analyse by, or the things that describe the FACTs. Examples of dimensions would be "Customers", "Products", "OrderDate" etc. So, if I have an "OrderValue" of £100, I can say that this £100 was spent by "Customer" ABC, on "Product" Widget on "OrderDate" 24/03/2010. Hence the dimensions describe each fact You place all of your FACTs into a FACT table, and your DIMENSIONs into separate DIMENSION tables, one for each. Then link the individual DIMENSION rows to the fact using keys. eg. FACT table = FAC_ORDERS (one row for each Fact to be aggregated) Structure FactID, OrderDateID, CustomerID, ProductID, OrderValue, OrderQty DIMENSION table = DIM_Product Structure ProductID, ProductName DIMENSION table = DIM_Customer Structure CustomerID, CustomerName DIMENSION table = DIM_TimeDay Structure OrderDateID, ActualDate, Year, Month, Week, Day Alternatively, if you have access to a SQL Server with Analysis Services running on it, you can avoid this by building an OLAP Cube in SQL Server using a tool like CUBE-it Zero. It's a FREE SQL Server OLAP Cube building tool that builds OLAP Cubes in SQL Server Analysis Server as it's data source, but there is an optional add-on you can buy for taking data from ORACLE as well. check it out at http://www.bi-lite.com
downvote count: 0
type: Answer

http://stackoverflow.com/comment/64880738
comment on: http://stackoverflow.com/a/2650423
score: 0
type: AnswerComment
has text: @Pascal, Re *"run the build continuously"*.. "the *build*" refers to?
type: Comment

http://stackoverflow.com/a/2746122
has body: If you are comfortable with not wrapping the code after the FileReader constructor, you can declare the FileReader outside of the try/catch block, like this: FileReader fr = null; try { fr = new FileReader(args[1]); } catch (IOException e) { // handle } // code that uses fr This is a reasonable design, and I use it often. Make sure you properly handle, in the following code, the possibility that fr is null (i.e. the constructor threw an exception).
answers question: http://stackoverflow.com/q/2746098
type: Answer
score: 9
upvote count: 9
has comment: http://stackoverflow.com/comment/2775512
has comment: http://stackoverflow.com/comment/2775717
has comment: http://stackoverflow.com/comment/2775748
downvote count: 0

http://stackoverflow.com/comment/101208306
comment on: http://stackoverflow.com/a/2624237
type: AnswerComment
type: Comment
has text: I disagree, checked exceptions should be well defined business code paths. All exceptions related to the IO devices are unexpected
score: 0

http://stackoverflow.com/comment/2819766
comment on: http://stackoverflow.com/a/2784289
type: AnswerComment
has text: @Hank: With a non-trivial update, you wrap your own `synchronized(thebuffer){...}` round it, but you don't need that sort of thing too often. Indeed, that's why `StringBuilder` was introduced; to get rid of the cost of holding locks at all when it's not needed (i.e., almost all the time).
score: 0
type: Comment

http://stackoverflow.com/comment/2791503
type: Comment
has text: Let's say I have following in ValidationMessages.properties: "answerform.questionId.invalid = Invalid question id: {0}." fieldError.getCode() will return "answerform.questionId.invalid", I am looking for the error itself, not the code, ex: "Invalid question id: 123"
score: 1
comment on: http://stackoverflow.com/a/2752421
type: AnswerComment

http://stackoverflow.com/comment/2653781
has text: Thanks for citing the Eclipse plans for supporting Java 7. They mention that they will support Java 7 in a different branch. Do you know where that branch of development is?
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2639371

http://stackoverflow.com/comment/140279290
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2653613
has text: All of a JVMs (remaining) native threads are destroyed when the JVM shuts down.
type: AnswerComment

http://stackoverflow.com/comment/2764429
has text: No, that should be `!input.matches("[^A-Za-z0-9.]")`.
comment on: http://stackoverflow.com/a/2712685
type: AnswerComment
score: 0
type: Comment

http://stackoverflow.com/a/49064767
has body: We should also take in consideration how the compiler threats the generic classes: in "instantiates" a different type whenever we fill the generic arguments. Thus we have ListOfAnimal, ListOfDog, ListOfCat, etc, which are distinct classes that end up being "created" by the compiler when we specify the generic arguments. And this is a flat hierarchy (actually regarding to List is not a hierarchy at all). Another argument why covariance doesn't make sense in case of generic classes is the fact that at base all classes are the same - are List instances. Specialising a List by filling the generic argument doesn't extend the class, it just makes it work for that particular generic argument.
score: 0
type: Answer
answers question: http://stackoverflow.com/q/2745265

http://stackoverflow.com/comment/2795754
type: AnswerComment
has text: @aioobe, thanks a lot! Unless you want to store those numbers as Strings (then the private constructor needs to change accordingly), no " are needed.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2763428

http://stackoverflow.com/comment/2808022
comment on: http://stackoverflow.com/q/2774173
type: Comment
type: QuestionComment
score: 0
has text: i didnt think of good algorithm .

http://stackoverflow.com/q/2751603
has answer: http://stackoverflow.com/a/46895694
has title: How to get error text in controller from BindingResult?
has answer: http://stackoverflow.com/a/7384449
has answer: http://stackoverflow.com/a/66113363
has answer: http://stackoverflow.com/a/2752421
accepted answer: http://stackoverflow.com/a/2752421
favorite count: 0
upvote count: 37
has body: I have an controller that returns JSON. It takes a form, which validates itself via spring annotations. I can get FieldError list from BindingResult, but they don't contain the text that a JSP would display in the &lt;form:errors&gt; tag. How can I get the error text to send back in JSON? @RequestMapping(method = RequestMethod.POST) public @ResponseBody JSONResponse submit(@Valid AnswerForm answerForm, BindingResult result, Model model, HttpServletRequest request, HttpServletResponse response) { if (result.hasErrors()) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); JSONResponse r = new JSONResponse(); r.setStatus(JSONResponseStatus.ERROR); //HOW DO I GET ERROR MESSAGES OUT OF BindingResult??? } else { JSONResponse r = new JSONResponse(); r.setStatus(JSONResponseStatus.OK); return r; } } JSONREsponse class is just a POJO public class JSONResponse implements Serializable { private JSONResponseStatus status; private String error; private Map&lt;String,String&gt; errors; private Map&lt;String,Object&gt; data; // ...getters and setters... } Calling BindingResult.getAllErrors() returns an array of FieldError objects, but it does not have the actual errors.
has answer: http://stackoverflow.com/a/20550627
tagged with: spring-annotations
tagged with: spring
has answer: http://stackoverflow.com/a/47465362
tagged with: spring-mvc
type: AnsweredQuestion
downvote count: 0
tagged with: java
possible better answer: http://stackoverflow.com/a/7384449
type: Question
score: 37
tagged with: http://stackoverflow.com/tag/json
answer count: 6

http://stackoverflow.com/q/2758639
tagged with: http://stackoverflow.com/tag/xml
has body: Does anyone know good XML library for Java which I can use to write data extracted from database into XML format?
has title: XML library for Java
upvote count: 1
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2758656
linked to: http://stackoverflow.com/q/831865
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/2758664
has comment: http://stackoverflow.com/comment/2790254
type: Question
downvote count: 0
favorite count: 0
answer count: 3
possible better answer: http://stackoverflow.com/a/2758659
has answer: http://stackoverflow.com/a/2758656
has answer: http://stackoverflow.com/a/2758659

http://stackoverflow.com/q/2739134
has body: I have converted a WSDL file to generate Java code (with Axis2)that will be deployed as web service. Do I only need to implement and extend the skeleton file generated? Or, can I edit and extend other classes too? I fear modifying other files will result in some mismatch between the WSDL and Java code.
score: 1
tagged with: java
tagged with: apache-axis
upvote count: 1
tagged with: web-services
type: Question
has answer: http://stackoverflow.com/a/2739783
downvote count: 0
answer count: 1
has title: Web services - WSDL to Java - Extending only skeleton file?
favorite count: 0
type: UnansweredQuestion

http://stackoverflow.com/comment/9570413
has text: @stivlo - true, I'm always using it without it, but if debug information is not included by the compiler, spring can't know the name of the param.
type: Comment
comment on: http://stackoverflow.com/a/2605318
score: 0
type: AnswerComment

http://stackoverflow.com/comment/2616104
comment on: http://stackoverflow.com/a/2605990
type: AnswerComment
score: 4
type: Comment
has text: well, did you import it? `import javax.servlet.http.HttpServeltResponse`

resin
type: Tag
tag name: resin
tags question: http://stackoverflow.com/q/2749528

http://stackoverflow.com/q/2616168
tagged with: mysql
has title: How do I get the median/mode/range of a column in SQL using Java?
has comment: http://stackoverflow.com/comment/2627911
type: Question
has body: I have to get the median, mode and range of test scores from one column in a table but I am unsure how to go about doing that. When you connect to the database using java, you are normally returned a ResultSet that you can make a table or something out of but how do you get particular numbers or digits? Is there an SQL command to get the median/mode/range or will I have to calculate this myself, and how do you pull out numbers from the table in order to be able to calculate the mode/median/range? Thanks.
upvote count: 5
tagged with: java
score: 5
answer count: 3
has answer: http://stackoverflow.com/a/2616195
downvote count: 0
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/19046340
has comment: http://stackoverflow.com/comment/2627831
tagged with: jdbc
has answer: http://stackoverflow.com/a/19046522

http://stackoverflow.com/q/2761473
tagged with: sdk
answer count: 3
downvote count: 0
has answer: http://stackoverflow.com/a/2769419
tagged with: eclipse-3.5
tagged with: eclipse-plugin
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2761625
score: 2
tagged with: java
has title: Blackberry SDK 4.2.1 not available in Eclipse Plug-in 1.1
tagged with: blackberry
has answer: http://stackoverflow.com/a/2791511
type: Question
has body: I need to develop an application for Blackberry Java SDK 4.2.1 and above. I'm currently under Eclipse Classic 3.5, and I have installed the BlackBerry Java Plug-in for Eclipse v1.1, with all the Blackberry Java SDK available, versions 4.5 to 5.0. Unfortunately, there isn't any SDK available under 4.5. Is anyone know how to solve this problem? I mean, developing for Blackberry Java SDK 4.2.1 with Eclipse IDE. Thank you.
upvote count: 2

http://stackoverflow.com/comment/2643356
type: Comment
type: QuestionComment
score: 1
has text: SF, sun.misc.Unsafe class (http://www.docjar.com/docs/api/sun/misc/Unsafe.html), you're looking for putByte method.
comment on: http://stackoverflow.com/q/2629357

http://stackoverflow.com/a/2673864
has comment: http://stackoverflow.com/comment/74851943
type: Answer
has comment: http://stackoverflow.com/comment/135612572
has body: No. Escaping / externalizing the string is your only choice.
score: 81
has comment: http://stackoverflow.com/comment/100894586
has comment: http://stackoverflow.com/comment/137559030
accepted answer of: http://stackoverflow.com/q/2673855
answers question: http://stackoverflow.com/q/2673855
type: AcceptedAnswer
downvote count: 0
upvote count: 81

http://stackoverflow.com/q/2654948
has answer: http://stackoverflow.com/a/2655064
has answer: http://stackoverflow.com/a/2670407
tagged with: user-interface
answer count: 6
favorite count: 0
possible better answer: http://stackoverflow.com/a/24024689
has answer: http://stackoverflow.com/a/24024689
has body: I am using miglayout to create a form in which there are JTextFields (short input answers) as well as JTextAreas (Longer answers). The problem is twofold. The border placed around a Scrollpane wrapped text area does not match that of a Text Field. The width and placement of the textarea/textfield differ, causing them not to line up correctly. alt text http://grab.by/3O0V After changing from right/left to right/fill: alt text http://grab.by/3RMk You can see that the bounds line up, but that there are still gaps. I tried setting novisualpadding but this did not fix it. Source code: package test2; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; import net.miginfocom.swing.MigLayout; public class Test extends JPanel { private static final int NUM_CHARACTERS_WIDTH = 20; private static final int NUM_ROWS = 5; public Test() { setLayout(new MigLayout( "wrap 2", // Align text labels on the so their right edge meets left edge of the text fields "[right][left]" )); add(new JLabel("Text field:")); add(new JTextField(NUM_CHARACTERS_WIDTH)); add(new JLabel("No scrollpane text area:")); add(new JTextArea(NUM_ROWS, NUM_CHARACTERS_WIDTH)); add(new JLabel("Scrollpane text area:")); add(new JScrollPane(new JTextArea(NUM_ROWS, NUM_CHARACTERS_WIDTH))); add(new JLabel("Text field:")); add(new JTextField(NUM_CHARACTERS_WIDTH)); } public static void main(String[] args) { JFrame frame = new JFrame(""); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new Test(); frame.add(panel); frame.pack(); frame.setVisible(true); } } What's the preferred way to mix and match jtextfield and jtextareas, while still maintaining visual harmony? I notice now that the text field has a blue highlight around it when focus is in it, as opposed to the text area... another source of visual discontinuity.
has answer: http://stackoverflow.com/a/2655348
accepted answer: http://stackoverflow.com/a/2691179
score: 8
type: AnsweredQuestion
downvote count: 0
has title: Swing - how to mix JTextField and JTextAreas and have same visual appearance?
tagged with: swing
has answer: http://stackoverflow.com/a/2691179
upvote count: 8
type: Question
tagged with: miglayout
has answer: http://stackoverflow.com/a/2657370
tagged with: java

http://stackoverflow.com/a/2726706
type: Answer
has body: While I can't offer a java solution, here are some for C# ... If you can alter the signature of Process to accept IEnumerable ... public void Process(IEnumerable&lt;A&gt; myList) { ... } then, in C# 4.0, everything will just work, thanks to the improved support for co- and contra-variance. If you're working in C# 3.0, you can introduce a generic type parameter to the method: public void Process&lt;T&gt;(List&lt;T&gt; myList) where T : A { ... } Then, you can call passing either List or List and the generic type parameter will bind accordingly. Note that you don't often have to specify it directly, as type inferrence will usually give you what you need. If this doesn't suit, you could convert the List using the Cast extension method from Enumerable: public void Process(List&lt;A&gt; myList) { ... } var someList = getListA1(); Process( someList.Cast&lt;A&gt;());
type: AcceptedAnswer
downvote count: 0
upvote count: 8
accepted answer of: http://stackoverflow.com/q/2726681
score: 8
answers question: http://stackoverflow.com/q/2726681

http://stackoverflow.com/comment/23338091
type: AnswerComment
comment on: http://stackoverflow.com/a/2687084
type: Comment
score: 2
has text: I'm using the Swing Layout Editor in NetBeans 7.3. To make this work, I had to set the PreferredSize property for the JTextArea to null. When I did, the vertical scrollbar magically appeared.

http://stackoverflow.com/q/2651632
has title: How to check if an Object is a Collection Type in Java?
answer count: 6
has answer: http://stackoverflow.com/a/2651727
has answer: http://stackoverflow.com/a/2651648
downvote count: 0
has answer: http://stackoverflow.com/a/2651644
upvote count: 90
favorite count: 0
has answer: http://stackoverflow.com/a/34529830
linked to: http://stackoverflow.com/q/2950319
has answer: http://stackoverflow.com/a/2651649
possible better answer: http://stackoverflow.com/a/2651654
score: 90
has body: By using java reflection, we can easily know if an object is an array. What's the easiest way to tell if an object is a collection(Set,List,Map,Vector...)?
has answer: http://stackoverflow.com/a/2651654
type: AnsweredQuestion
accepted answer: http://stackoverflow.com/a/2651644
tagged with: java
type: Question

http://stackoverflow.com/comment/2704763
type: AnswerComment
has text: It will kill the JVM. So if the external software started your program by spawning a Java process, it will be fine. If the external software is Java code that simply creates an instance of your class(es) and runs them, then that external code will be killed too.
type: Comment
comment on: http://stackoverflow.com/a/2684636
score: 1

http://stackoverflow.com/comment/2670209
score: 8
comment on: http://stackoverflow.com/q/2653875
has text: Pick one of http://stackoverflow.com/search?q=java+html+parser
type: Comment
type: QuestionComment

http://stackoverflow.com/a/2637518
score: 1
upvote count: 1
type: Answer
has body: Interfaces are incredibly overused in Java partly because of the language design and partly because people think making lots of interfaces is good design. Abstract classes would be superior to interfaces if Java allowed multiple inheritance. Scala a new programming language for the JVM has a concept of Traits which are essentially abstract classes with MI capability. The advantage to an abstract class is that you can add behavior to the abstract class with out breaking existing classes that extend it. Thus an abstract class is also better as an extension mechanism (plugin) then interfaces. Unfortunately JMock and its brethren encourage lots of interfaces for BDD testing but this is not necessarily true because there are at least a couple of libraries to mock concrete objects.
answers question: http://stackoverflow.com/q/2637377
downvote count: 0

http://stackoverflow.com/comment/2695752
comment on: http://stackoverflow.com/q/2676719
type: QuestionComment
score: 2
has text: I'm sorry, let me rephrase my title, how do I get the angle between the line defined by these two points and the horizontal access that cuts through my object at the center of the screen??
type: Comment

http://stackoverflow.com/comment/2713074
type: AnswerComment
has text: Does the solution change if doclets are used?
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2680340

http://stackoverflow.com/comment/2694198
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2675400
has text: Yes, I think it's the most elegant solution but because of some reasons it does not work in my case. But I still need to find out what exactly is wrong.

http://stackoverflow.com/comment/4083536
has text: This is same as what Woodstox does as well. Question is wrong in implying otherwise.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2654098
type: AnswerComment

http://stackoverflow.com/comment/2655884
type: AnswerComment
type: Comment
score: 1
comment on: http://stackoverflow.com/a/2640841
has text: You have a space beween the `.dtd` and the `"`

http://stackoverflow.com/comment/2689437
score: 0
comment on: http://stackoverflow.com/a/2670817
type: AnswerComment
type: Comment
has text: You can use anonymous code blocks in Groovy. See my answer for details and example.

http://stackoverflow.com/q/2769710
downvote count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2772317
score: 1
tagged with: java
type: Question
has body: I am newbie to Java. I have some design questions. Say I have a crawler application, that does the following: 1. Crawls a url and gets its content 2. Parses the contents 3. Displays the contents How do you decide between implementing a function or a class? -- Should the parser be a function of the crawler class, or should it be a class in itself, so it can be used by other applications as well? -- If it should be a class, should it be protected or public class? How do you decide between implementing a public or protected class? -- If I had to create a class to generate stats from the parsed contents for eg, should that class be protected (so only the crawler class can access it) or should it be public? Thanks Ron
tagged with: access-modifiers
tagged with: class
has answer: http://stackoverflow.com/a/2769776
has title: Java Design Questions - Class, Function, Access Modifiers
answer count: 3
has answer: http://stackoverflow.com/a/2769744
upvote count: 1
has comment: http://stackoverflow.com/comment/2803030
favorite count: 0

http://stackoverflow.com/q/2663980
answer count: 3
possible better answer: http://stackoverflow.com/a/2667671
has comment: http://stackoverflow.com/comment/10796959
downvote count: 0
has answer: http://stackoverflow.com/a/2667671
favorite count: 0
has answer: http://stackoverflow.com/a/2664040
has comment: http://stackoverflow.com/comment/14651584
type: AnsweredQuestion
has title: Why do I get an Enum constant reference cannot be qualified in a case label?
tagged with: java
has answer: http://stackoverflow.com/a/2664036
score: 46
type: Question
upvote count: 46
tagged with: enums
accepted answer: http://stackoverflow.com/a/2664036
has body: Why does the following code fail to compile, while changing the case statement to case ENUM1: doSomeStuff(); works? public enum EnumType { ENUM1, ENUM2, ENUM3; void doSomeStuff() { switch(this) { case EnumType.ENUM1: doSomeStuff(); } } }

http://stackoverflow.com/a/2656006
downvote count: 0
type: Answer
has body: The recommended way of doing things is to configure the build path. This is a nice article describing the process.
upvote count: 1
answers question: http://stackoverflow.com/q/2655964
score: 1

http://stackoverflow.com/comment/120288568
comment on: http://stackoverflow.com/a/51543908
type: Comment
has text: Yes. This is tested.
type: AnswerComment
score: 0

http://stackoverflow.com/a/2759860
score: 1
upvote count: 1
downvote count: 0
has body: You could use a layout manager like Mig Layout for that kind of positionning. (source: miglayout.com)
type: Answer
answers question: http://stackoverflow.com/q/2759840

http://stackoverflow.com/a/3846171
has body: **How to accept array by user Input Answer:- import java.io.*; import java.lang.*; class Reverse1 { public static void main(String args[]) throws IOException { int a[]=new int[25]; int num=0,i=0; BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter the Number of element"); num=Integer.parseInt(br.readLine()); System.out.println("Enter the array"); for(i=1;i&lt;=num;i++) { a[i]=Integer.parseInt(br.readLine()); } for(i=num;i&gt;=1;i--) { System.out.println(a[i]); } } }
type: Answer
answers question: http://stackoverflow.com/q/2622725
score: 0

http://stackoverflow.com/a/11374720
answers question: http://stackoverflow.com/q/2605555
has body: Place old database (old.db) in your asset folder. Type this inside onCreate() of your activity: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); .... //=======Code For copying Existing Database file to system folder for use====// // Copying Existing Database into system folder try { String destPath = "/data/data/" + getPackageName() + "/databases/data.db"; File f = new File(destPath); if(!f.exists()){ Log.v(TAG,"File Not Exist"); InputStream in = getAssets().open("old.db"); OutputStream out = new FileOutputStream(destPath); byte[] buffer = new byte[1024]; int length; while ((length = in.read(buffer)) &gt; 0) { out.write(buffer, 0, length); } in.close(); out.close(); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { Log.v("TAG","ioexeption"); e.printStackTrace(); } DBManager dbManager = new DBManager(this); Log.v(TAG,"Database is there with version: "+dbManager.getReadableDatabase().getVersion()); String sql = "select * from prizes"; SQLiteDatabase db = dbManager.getReadableDatabase(); Cursor cursor = db.rawQuery(sql, null); Log.v(TAG,"Query Result:"+cursor); cursor.close(); db.close(); dbManager.close(); .... } Now you have to make a DBManager Class which subclasses SQLiteOpenHelper . Insert the abstract method and constructor. Don't forget to type correct database name inside super() of dbHelper. public class DBManager extends SQLiteOpenHelper { private static final int DATABASE_VERSION = 1; private static final String TAG = "DATABASES"; public DBManager(Context context) { super(context, "data.db", null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { Log.v(TAG,"On create Called:"+db.getPath()); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { } } Now you can access database by instantiating DBManager. SQLiteDatabase db = dbManager.getReadableDatabase(); Cursor cursor = db.rawQuery(sql, null); ... Don't forget to close database or u…
score: 7
upvote count: 7
downvote count: 0
type: Answer

http://stackoverflow.com/q/2667131
has title: Is there something like Restrictions.eq(true, false) in Criteria API?
has body: I need a generic Criterion which forces the result to zero matches. Something like Restrictions.eq(true, false) ?
has answer: http://stackoverflow.com/a/2669060
has answer: http://stackoverflow.com/a/2667310
favorite count: 0
accepted answer: http://stackoverflow.com/a/2667310
score: 16
tagged with: criteria-api
has answer: http://stackoverflow.com/a/42090306
type: AnsweredQuestion
downvote count: 0
tagged with: java
tagged with: hibernate
has comment: http://stackoverflow.com/comment/2685173
type: Question
tagged with: criteria
upvote count: 16
possible better answer: http://stackoverflow.com/a/2669060
has comment: http://stackoverflow.com/comment/2691694
answer count: 3

http://stackoverflow.com/comment/4216927
type: AnswerComment
score: 0
comment on: http://stackoverflow.com/a/2762238
type: Comment
has text: @rohanbk - Not too much. But, it would be a reasonably good choice, since it would allow you to easily benchmark other classifiers on your data.

conflict
tag name: conflict
type: Tag
tags question: http://stackoverflow.com/q/2734864

http://stackoverflow.com/q/2650169
has title: Mapping Hashmap of Coordinates in Hibernate with Annotation
upvote count: 3
tagged with: java
tagged with: hibernate
type: Question
has comment: http://stackoverflow.com/comment/2666486
answer count: 1
downvote count: 0
has answer: http://stackoverflow.com/a/7836227
tagged with: hibernate-mapping
favorite count: 0
has body: I've just started using hibernate and I'm trying to map walking distance between two coordinates into a hashmap, There can be many connections from one "FromCoordinate" to another "ToCoordinate". I'm not sure if i've implemented this correctly, What annotations do i need to map this MashMap? Thanks HashMap> coordWalkingConnections = new HashMap>(); @Entity @Table(name = "COORDCONNECTIONS") public class CoordinateConnection implements Serializable{ private static final long serialVersionUID = -1624745319005591573L; /** auto increasing id number */ @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "ID") @id private int id; @Embedded public FromCoordinate fromCoord; @Embedded public ToCoordinate toCoord; HashMap&lt;FromCoordinate, ArrayList&lt;ToCoordinate &gt;&gt; coordWalkingConnections = new HashMap&lt;FromCoordinate, ArrayList&lt;ToCoordinate &gt;&gt;(); } public class FromCoordinate implements ICoordinate { @Column(name = "FROM_LAT") private double latitude; @Column(name = "FROM_LNG") private double longitude; } public class ToCoordinate implements ICoordinate { @Column(name = "TO_LAT") private double latitude; @Column(name = "TO_LNG") private double longitude; @Column(name = "DISTANCE") private double distance; } DATABASE STRUCTURE id FROM_LAT FROM_LNG TO_LAT TO_LNG Dist 1 43.352669 -6.264341 43.350012 -6.260653 0.38 2 43.352669 -6.264341 43.352669 -6.264341 0.00 3 46.352669 -6.264341 43.353373 -6.262013 0.17 4 47.352465 -6.265865 43.351290 -6.261200 0.25 5 45.452578 -6.265768 43.352788 -6.264396 0.01 6 45.452578 -6.265768 45.782788 -6.234523 0.01 ..... ... . Example HashMap for HashMap&lt;Coordinate, ArrayList&lt;Coordinate&gt;&gt; &lt;KEY{43.352669 -6.264341}, Arraylist VALUES{(43.350012,-6.260653,0.383657), (43.352669, -6.264341, 0.000095), (43.353373, -6.262013, 0.173201)}&gt; &lt;KEY{47.352465 -6.265865}, Arraylist VALUES{(43.351290,-6.261200,0.258781)}&gt; &lt;KEY{45.452578 -6.265768}, Arraylist VALUES{(43.352788,-6.264396,0.013726),(45.782…
type: UnansweredQuestion
tagged with: annotations
score: 3

http://stackoverflow.com/comment/2807537
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2773814
type: Comment
has text: Heh, yeah. I think you beat me to it by just a few seconds ;)

http://stackoverflow.com/comment/2788343
has text: With this one I get an IllegalStateException
comment on: http://stackoverflow.com/a/2756809
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/53697714
type: AnswerComment
has text: Works with PostgreSQL. Hibernate prints the query with debug logging enabled, however it prints the message almost at the end of query processing, so I am not sure if you get anything useful when an error is raised.
comment on: http://stackoverflow.com/a/2683299
type: Comment
score: 0

http://stackoverflow.com/a/2758324
downvote count: 0
has comment: http://stackoverflow.com/comment/2789913
has body: First and foremost: java methods should start lowercase. It's not enforced by the compiler or language spec, but it's a convention that everyone follows, and you'll get into trouble with tools, IDE's, and most importantly other programmers, if you don't follow it.
upvote count: 2
answers question: http://stackoverflow.com/q/2758310
type: Answer
has comment: http://stackoverflow.com/comment/2807035
has comment: http://stackoverflow.com/comment/2789866
score: 2

http://stackoverflow.com/comment/2638406
has text: Interesting question. I can see how no additional memory is required here, but will the reference to a class object prevent the classToInstanceMap from being garbage collected though?
comment on: http://stackoverflow.com/a/2625576
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/111028479
score: 0
comment on: http://stackoverflow.com/q/2661659
type: Comment
type: QuestionComment
has text: You should read the FTP protocol documentation.

http://stackoverflow.com/a/2672196
has body: Perhaps this would be a nice opportunity to use the Strategy Design Pattern. This way you can change the fighting strategy which will be used when party members are added or removed, rather than every fight.
answers question: http://stackoverflow.com/q/2672172
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/2690875

http://stackoverflow.com/comment/2768248
type: AnswerComment
has text: He is, but he's also given the javamail property that should promote the connection to TLS after connecting.
comment on: http://stackoverflow.com/a/2739619
score: 0
type: Comment

crystal-reports
tags question: http://stackoverflow.com/q/2710200
tag name: crystal-reports
type: Tag
tags question: http://stackoverflow.com/q/2702537

http://stackoverflow.com/comment/2705518
has text: You really have to understand what's going on under the hood. Take the 'best' ORM and use it terribly and you will get terrible performance!
comment on: http://stackoverflow.com/a/2685341
type: Comment
score: 3
type: AnswerComment

http://stackoverflow.com/a/2713763
downvote count: 0
score: 1
has body: The is a special component for that - JToggleButton. It is exactly what you want. It can be used with ButtonGroup as radio buttons and check boxes (they are descendants of toggle button)
has comment: http://stackoverflow.com/comment/2739331
upvote count: 1
answers question: http://stackoverflow.com/q/2712921
type: Answer

http://stackoverflow.com/q/2703511
upvote count: 1
type: AnsweredQuestion
tagged with: interpreter
has body: I am looking for a library or set of libraries that will help me write a forgiving command interpreter. A forgiving command interpreter would be a command interpreter which can deal with simple and even not so simple spelling and word order mistakes in the input. My goal is to have an interpreter which would take the input (a command) from a user and then: execute the command, if it is correct. apply corrections to the command, until a correct command is generated and then present that command to the user to confirm whether it is 'what the user meant'. For example: The GlassFish Server has a command-line administrative interface, named asadmin. It allows users to script interaction with the server and work with it interactively. An asadmin command has a fairly rigid structure: asadmin &lt;asadmin options&gt; &lt;subcommand&gt; &lt;subcommand-options&gt; &lt;operand&gt; The asadmin command currently attempts to help users that misspell a command, like this: vkraemer$ ../../GlassFish3.0.1.b12/glassfish/bin/asadmin creat-domain --user foobar --portbase 2600 fubar Deprecated syntax, instead use: asadmin --user foobar creat-domain [options] ... Remote server does not listen for requests on [localhost:4848]. Is the server up? Unable to get remote commands. Closest matching local command(s): create-domain Command creat-domain failed. This is a pretty good catch. It is not as smart when it comes to misspelled options. I would like to remove almost all the constraints on the input, to allow users to make multiple mistakes in a command, but still get to the point where they have a chance to execute a command. Consider this example HCI: vkraemer$ ../../GlassFish3.0.1.b12/glassfish/bin/asadmin create-domain foobar Enter admin user name [Enter to accept default "admin" / no password]&gt; Domain foobar already exists in /Users/vkraemer/GlassFish3.0.1.b12/glassfish/domains. Use a different domain name or the --domaindir option. CLI130 Could not create domain, foobar Command create…
tagged with: java
type: Question
answer count: 2
has answer: http://stackoverflow.com/a/2703636
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2703641
has title: Best Java library(ies) for forgiving command interpreter
score: 1
tagged with: parsing
accepted answer: http://stackoverflow.com/a/2703636
has comment: http://stackoverflow.com/comment/2726959
possible better answer: http://stackoverflow.com/a/2703641

http://stackoverflow.com/comment/2810093
comment on: http://stackoverflow.com/a/2775626
score: 0
type: AnswerComment
type: Comment
has text: If i use a JFrame i got this error: "java.lang.IllegalArgumentException: adding a window to a container". That's my code in actionPerformed method: PopupFactory factory = PopupFactory.getSharedInstance(); JFrame frame = new JFrame(); frame.setLayout(null); frame.setBounds(428, 99, 185, 155); final JButton button = new JButton(); button.setText("Button"); button.setBounds(10, 93, 111, 25); frame.getContentPane().add(button); final Popup popup = factory.getPopup(null, frame, 200, 200); popup.show();

http://stackoverflow.com/q/2756714
has comment: http://stackoverflow.com/comment/2788318
answer count: 1
has comment: http://stackoverflow.com/comment/2788161
accepted answer: http://stackoverflow.com/a/2756795
favorite count: 0
has comment: http://stackoverflow.com/comment/2788193
has comment: http://stackoverflow.com/comment/2788197
has answer: http://stackoverflow.com/a/2756795
type: AnsweredQuestion
tagged with: word-frequency
score: 1
tagged with: java
downvote count: 2
type: Question
has title: Word frequency in Programming Pearls
tagged with: algorithm
has body: In "Programming Pearls" I have met the following problem. The question is this: "print words in order of decreasing frequency". As I understand problem is this. Suppose there is a given string array, let's call it s (words I have chosen randomly, it does not matter), String s[]={"cat","cat","dog","fox","cat","fox","dog","cat","fox"}; We see that string "cat" occurs 4 times, "fox" 3 times and "dog" 2 times. So the desired result will be this: cat fox dog I have written the following code in Java: import java.util.*; public class string { public static void main(String[] args){ String s[]={"fox","cat","cat","fox","dog","cat","fox","dog","cat"}; Arrays.sort(s); int counts; int count[]=new int[s.length]; for (int i=0;i&lt;s.length-1;i++){ counts=1; while (s[i].equals(s[i+1])){ counts++; } count[i]=counts; } } } I have sorted the array and created a count array where I write the number of occurrences of each word in array. My problem is that somehow the index of the integer array element and the string array element is not the same. How can I print words according to the maximum elements of the integer array?
has comment: http://stackoverflow.com/comment/2788281
has comment: http://stackoverflow.com/comment/2788215
upvote count: 3

registry
tags question: http://stackoverflow.com/q/2627446
tags question: http://stackoverflow.com/q/2607604
tag name: registry
type: Tag
tags question: http://stackoverflow.com/q/2691433

http://stackoverflow.com/comment/76259688
comment on: http://stackoverflow.com/a/2728547
type: AnswerComment
has text: A little difference of opinion on the way semantics are used don't make an answer wrong (or misleading). Anyone who reads this can easily understand that "C based" basically means "procedure oriented" - Anyone who has learnt Java knows the POP vs OOP difference.
type: Comment
score: 7

http://stackoverflow.com/comment/2619059
type: Comment
score: 1
type: AnswerComment
comment on: http://stackoverflow.com/a/2608682
has text: @ufk: This isn't a complex regex. You may otherwise want to hassle with a bunch of `String#indexOf()`, `String#substring()`, methods and so on. It's only a little tad faster, but it's much more code. @GK: Uh, did you read/understand the regex or even test it?

http://stackoverflow.com/comment/102136625
comment on: http://stackoverflow.com/a/20522548
has text: @AdamGawne-Cain Fair enough, Java is not a functional language, and has no real support for pure functions. I guess my thought process when I wrote this was, since with static methods you give up many features - such as polymorphism, dynamic binding, inheritance and instance scopes - it would be easier to keep methods pure, since you only have to worry about not using any class state, and only calling other pure methods. But yes, you're right, it still shares many concerns about side effects with instance methods.
type: Comment
score: 0
type: AnswerComment

http://stackoverflow.com/a/2647153
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2646431
type: Answer
has comment: http://stackoverflow.com/comment/35759925
has body: Okay, I found the answer. Wikipedia says: GlassFish is free software, dual-licensed under two free software licences: the Common Development and Distribution License (CDDL) and the GNU General Public License (GPL) with the classpath exception. The Classpath Exception is the main thing here. See the yellow section at the bottom of the license agreement on the Glassfish website: "CLASSPATH" EXCEPTION TO THE GPL VERSION 2 Certain source files distributed by Sun Microsystems, Inc. are subject to the following clarification and special exception to the GPL Version 2, but only where Sun has expressly included in the particular source file's header the words "Sun designates this particular file as subject to the "Classpath" exception as provided by Sun in the License file that accompanied this code." Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License Version 2 cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module.? An independent module is a module which is not derived from or based on this library.? If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so.? If you do not wish to do so, delete this exception statement from your version. Essentially that means that as long as I distribute the licenses with the Glassfish libraries, I am free to put them on the classpath of my proprietary software. Searching through the downloaded source of Metro (the part I want to use) I found only a handful of Ja…
upvote count: 5
accepted answer of: http://stackoverflow.com/q/2646431
score: 5

named-query
type: Tag
tags question: http://stackoverflow.com/q/2666048
tag name: named-query
tags question: http://stackoverflow.com/q/2662013

http://stackoverflow.com/a/4042705
score: 3
upvote count: 3
answers question: http://stackoverflow.com/q/2728283
has body: When you go to Export =&gt; Java =&gt; Runnable JAR file, You said "Next" button is not activated yet, You don't have to press the next button because you can just press finish, If you don't want the Lauch Configuration, You can manually edit the manifest file later. If you have external libraries you can chose one of the options they give you, extract/package/copy required libraries into jar file
type: Answer
downvote count: 0

http://stackoverflow.com/q/2712709
tagged with: string
has title: Parsing a text file with a fixed format in Java
has body: Suppose I know a text file format, say, each line contains 4 fields like this: firstword secondword thirdword fourthword firstword2 secondword2 thirdword2 fourthword2 ... and I need to read it fully into memory I can use this approach: open a text file while not EOF read line by line split each line by a space create a new object with four fields extracted from each line add this object to a Set Ok, but is there anything better, a special 3-rd party Java library? So that we could define the structure of each text line beforehand and parse the file with some function thirdpartylib.setInputTextFileFormat("format.xml"); thirdpartylib.parse(Set, "pathToFile") ?
type: UnansweredQuestion
type: Question
tagged with: text
tagged with: java
has answer: http://stackoverflow.com/a/2712747
has comment: http://stackoverflow.com/comment/2737926
has answer: http://stackoverflow.com/a/2712846
score: 0
answer count: 2
tagged with: text-parsing

http://stackoverflow.com/a/2745237
score: 0
type: Answer
has comment: http://stackoverflow.com/comment/20384228
has body: Check out the class java.util.Formatter.
upvote count: 1
downvote count: 1
answers question: http://stackoverflow.com/q/2745206

http://stackoverflow.com/comment/2783544
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2750598
has text: Oh. I was thinking how am I supposed to retrieve the text from Element, hence the question. I think I got the endOffset correct, however using what you'd suggested breaks my current implementation. I'll stick to my old code till I figure out what is wrong. Anyway, thanks.

http://stackoverflow.com/comment/2816395
type: AnswerComment
comment on: http://stackoverflow.com/a/2769343
score: 0
type: Comment
has text: @Harper: Well, I don't want to get into a protracted debate, but how is my example here different from the generic collections? If I say "class MyList extends ArrayList<Integer>", then MyList.get returns an Integer, not an Object. That's the whole point of generics. That's exactly what I'm trying to do here. Yes, I could dispense with the generics and have B.getFoo return an A. But in the context of my program, I know that it will always be a B and I need to use it as a B, so I would have to cast it. How would that be better? Okay, I could write a different function, a getBFoo or whatever. ...

http://stackoverflow.com/q/2780192
type: Question
answer count: 2
has title: Integration JS and Java
has body: I have two systems to integrate: 1)desktop application (Java6) and 2)web-application (HTML,JS). I want first application to share some services to the second one. How could simply I do that ? I want some simple solution. Thanks!
tagged with: javascript
has comment: http://stackoverflow.com/comment/2815047
possible better answer: http://stackoverflow.com/a/2780267
has answer: http://stackoverflow.com/a/2780267
score: 0
has answer: http://stackoverflow.com/a/2780224
tagged with: integration
accepted answer: http://stackoverflow.com/a/2780224
type: AnsweredQuestion
tagged with: java

http://stackoverflow.com/a/52238570
answers question: http://stackoverflow.com/q/2710300
upvote count: 11
has body: The break after switch cases is used to avoid the fallthrough in the switch statements. Though interestingly this now can be achieved through the newly formed switch labels as implemented via JEP-325. With these changes, the break with every switch case can be avoided as demonstrated further :- public class SwitchExpressionsNoFallThrough { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int value = scanner.nextInt(); /* * Before JEP-325 */ switch (value) { case 1: System.out.println("one"); case 2: System.out.println("two"); default: System.out.println("many"); } /* * After JEP-325 */ switch (value) { case 1 ->System.out.println("one"); case 2 ->System.out.println("two"); default ->System.out.println("many"); } } } On executing the above code with JDK-12, the comparative output could be seen as //input 1 // output from the implementation before JEP-325 one two many // output from the implementation after JEP-325 one and //input 2 // output from the implementation before JEP-325 two many // output from the implementation after JEP-325 two and of course the thing unchanged // input 3 many // default case match many // branches to 'default' as well
type: Answer
score: 11
downvote count: 0

http://stackoverflow.com/q/2694566
answer count: 4
favorite count: 0
tagged with: static
has comment: http://stackoverflow.com/comment/2716325
has answer: http://stackoverflow.com/a/2694579
has answer: http://stackoverflow.com/a/2694611
has comment: http://stackoverflow.com/comment/2716356
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2694600
score: 21
tagged with: java
has body: First some code: import java.util.*; //... class TicTacToe { //... public static void main (String[]arg) { Random Random = new Random() ; toerunner () ; // this leads to a path of // methods that eventualy gets us to the rest of the code } //... public void CompTurn (int type, boolean debug) { //... boolean done = true ; int a = 0 ; while (!done) { a = Random.nextInt(10) ; if (debug) { int i = 0 ; while (i&lt;20) { System.out.print (a+", ") ; i++; }} if (possibles[a]==1) done = true ; } this.board[a] = 2 ; } //... } //to close the class Here is the error message: TicTacToe.java:85: non-static method nextInt(int) cannot be referenced from a static context a = Random.nextInt(10) ; ^ What exactly went wrong? What does that error message "non static method cannot be referenced from a static context" mean?
upvote count: 21
duplicate of: http://stackoverflow.com/q/290884
possible better answer: http://stackoverflow.com/a/2694604
type: Question
has answer: http://stackoverflow.com/a/2694604
accepted answer: http://stackoverflow.com/a/2694579
has title: non static method cannot be referenced from a static context
downvote count: 0

http://stackoverflow.com/a/2652695
type: Answer
answers question: http://stackoverflow.com/q/2652632
score: 1
upvote count: 1
has body: If you're talking about singletons in particular: that's one reason why the best way to implement them is via an enum: public enum YourSingleton { INSTANCE; // methods go here } If you're talking about using setAccessible() in general: If the code is written by someone you don't trust not to do underhanded tricks like that, you shouldn't run it anyway (or run it in a sandbox). Among developers, public/private should be considered metainformation about how the code is intended to be used - not as a security feature.
downvote count: 0

http://stackoverflow.com/comment/2766928
score: 0
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2738466
has text: @T.J. thanks, I saw that it was broke and was trying to fix it at the same time.

http://stackoverflow.com/a/2623225
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2648271
has body: You can use indexOf() to find the first line break, and substring() to take the substring from 0 to that line break Edit: Example (assuming the line break is \n): String str = "Line 1\nLine 2\nLine 3"; String firstLine = str.substring(0, str.indexOf("\n")); //firstLine == "Line 1"
type: Answer
accepted answer of: http://stackoverflow.com/q/2623213
upvote count: 6
answers question: http://stackoverflow.com/q/2623213
score: 6
has comment: http://stackoverflow.com/comment/2635688

http://stackoverflow.com/comment/2765562
type: Comment
has text: @Narayan That is because Eclipse provides its own batch files. The important thing to note is that the batch files aren't included in the exe installer and if you needed them for whatever reason, you need to download the zip version. Actually you can download both and extract the zip file over the folder the exe installer has created. The contents of both are the same.
comment on: http://stackoverflow.com/a/2735559
score: 0
type: AnswerComment

http://stackoverflow.com/q/2732650
downvote count: 0
has answer: http://stackoverflow.com/a/2746762
favorite count: 0
accepted answer: http://stackoverflow.com/a/2733481
tagged with: active-objects
has answer: http://stackoverflow.com/a/2733481
type: AnsweredQuestion
score: 3
upvote count: 3
tagged with: java
tagged with: http://stackoverflow.com/tag/json
has title: Is there a JSON library that can serialize Proxy objects?
tagged with: gson
possible better answer: http://stackoverflow.com/a/2746762
type: Question
has body: Using ActiveObjects as my ORM and Gson as my JSON processor. Ran into a problem going toJson from persisted objects. The problem is that my persisted class is actually an Interface and AO is proxying that object under the hood. Here's some sample code: Venue venue = manager.get(Venue.class, id); gson.toJson(venue); Comes up with this exception: java.lang.UnsupportedOperationException: Expecting parameterized type, got interface java.lang.reflect.InvocationHandler. Are you missing the use of TypeToken idiom? See http://sites.google.com/site/gson/gson-user-guide#TOC-Serializing-and... Because venue.getClass().getName() gives: $Proxy228 I've tried a few solutions in various combinations: gsonBuilder.registerTypeAdapter(Venue.class, newVenueSerializer()); Type listType = new TypeToken&lt;Venue&gt;() {}.getType(); Nothing has worked so far and I'm using a wonky field-by-field workaround. Any suggestions? I'm not married to Gson, so if there's an alternative library that can do this I'd be happy to use it.
tagged with: proxy
answer count: 2

http://stackoverflow.com/comment/2785782
type: Comment
has text: That was news to me, thanks! I'd seen SwingWorker before but never gave it much attention.
comment on: http://stackoverflow.com/a/2754554
score: 0
type: AnswerComment

http://stackoverflow.com/a/2761355
accepted answer of: http://stackoverflow.com/q/2758248
has comment: http://stackoverflow.com/comment/131440750
score: 6
downvote count: 0
has body: I found a nice explanation in the JBoss documentation (chapter 8.4.1): The login() call only binds the name and password to the JBoss EJB layer of the client. All subsequent EJB calls will use these credentials and pass them to the called EJB method.
type: AcceptedAnswer
upvote count: 6
answers question: http://stackoverflow.com/q/2758248
type: Answer

http://stackoverflow.com/a/2713012
score: 4
answers question: http://stackoverflow.com/q/2712971
has body: I don't, but the argument given to me for doing this while at university was that it makes things more explicit, so you don't 'forget' that a superclass constructor is being called. I just don't see the need tho.
type: Answer
upvote count: 4
downvote count: 0

http://stackoverflow.com/q/2707793
has answer: http://stackoverflow.com/a/2707827
has comment: http://stackoverflow.com/comment/2732700
tagged with: macos
tagged with: unix
favorite count: 0
tagged with: linux
answer count: 5
has answer: http://stackoverflow.com/a/2707951
has body: I usually store the Java applications and JAR files that I download from the Web in the ~/Java folder on my computer (an OS X machine). I have been doing this since the days when I was a Windows user. However I think in UNIX based systems user local apps are conventionally stored in another directory. I have a feeling that this directory should either be /usr/local/, /usr/local/USERNAME, /opt/local, or /opt/local/USERNAME but I am not sure. Any ideas which directory can I use for this purpose? Please note that, I am talking about archive files that I download from the Web, unpack and use locally and not programs that have installation scripts or MacPorts, etc.
has comment: http://stackoverflow.com/comment/2731765
accepted answer: http://stackoverflow.com/a/2707827
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/2707815
upvote count: 10
possible better answer: http://stackoverflow.com/a/9770205
type: Question
has answer: http://stackoverflow.com/a/38109559
has answer: http://stackoverflow.com/a/9770205
downvote count: 0
score: 10
has title: The conventional location for storing my Java libraries and applications in UNIX based systems
has comment: http://stackoverflow.com/comment/2731771

http://stackoverflow.com/a/57519080
answers question: http://stackoverflow.com/q/2614774
score: 5
upvote count: 5
downvote count: 0
has body: Check if there is a deadlock. For example, Runtime.getRuntime().addShutdownHook(new Thread(this::close)); System.exit(1); and in the close() public void close() { // some code System.exit(1); } The System.exit() actually calls the shutdown hook and finalizers. So, if your shutdown hook calls the exit() again internally, for some reason (for example, when the close() raises an exception for which you want to exit the program, then you will call exit() there also). Like this.. public void close() { try { // some code that raises exception which requires to exit the program } catch(Exception exceptionWhichWhenOccurredShouldExitProgram) { log.error(exceptionWhichWhenOccurredShouldExitProgram); System.exit(1); } } Though, it is a good practice to throw the exception, some may choose to log and exit. Note, also, that Ctrl+C will also not work if there is a deadlock. Since it also calls the shutdown hook. Anyways, if it is the case, the problem can be solved by this workaround: private static AtomicBoolean exitCalled=new AtomicBoolean(); private static void exit(int status) { if(!exitCalled.get()) { exitCalled.set(true); System.exit(status); } } Runtime.getRuntime().addShutdownHook(new Thread(MyClass::close)); exit(1); } private static void close() { exit(1); } P.S: I feel that the above exit() version must actually be written in the System.exit() method only (may be some PR for JDK?) Because, there is practically no point (at least from what I see) in entertaining a deadlock in System.exit()
type: Answer

http://stackoverflow.com/q/2711882
upvote count: 1
type: Question
has comment: http://stackoverflow.com/comment/2736816
score: 1
tagged with: java
tagged with: code-completion
answer count: 2
downvote count: 0
tagged with: ide
favorite count: 0
has answer: http://stackoverflow.com/a/2711899
has answer: http://stackoverflow.com/a/2711907
has title: open source java IDEs which support code complete
type: UnansweredQuestion
has body: What I have known of are eclipse , netbeans and JavaSideKick for jedit. Are there other alternatives? Please let me know cause it really helps me! Thanks a lot!

http://stackoverflow.com/q/2780119
has answer: http://stackoverflow.com/a/2781695
accepted answer: http://stackoverflow.com/a/2781643
score: -2
tagged with: java
answer count: 2
upvote count: 0
favorite count: 0
tagged with: serialization
tagged with: android
has body: I have a model (MVC) class whose internal state (which basically contains of private int fields) I want to store. The program is running on Android (for now) so I need to store the in a Bundle, but I'll be using the same class later in a desktop application where I'll have to store the state some other way, so I can't reference Bundle directly in my class. So my question is: What is the best way to store (and retrieve) the state of a class without exposing it's implementation? The best I could think of removing the private access modifier so that the fields become package accessible and create read/write helper classes in the same package, but that somehow seems wrong.
has answer: http://stackoverflow.com/a/2781643
tagged with: model-view-controller
type: AnsweredQuestion
downvote count: 2
has title: Transparently storing class state without exposing implementation
possible better answer: http://stackoverflow.com/a/2781695
type: Question

http://stackoverflow.com/a/2682106
answers question: http://stackoverflow.com/q/2681977
has body: As a first cut, run FindBugs or PMD over your code. Both of the have rules for detecting source code in which database resources are not or may not be properly closed. And they will probably highlight lots of other issues that are worth fixing.
score: 1
upvote count: 1
accepted answer of: http://stackoverflow.com/q/2681977
type: AcceptedAnswer
downvote count: 0
type: Answer

http://stackoverflow.com/a/2652087
upvote count: 1
has body: onchange="window.submitTrigger=this; this.form.submit();" Then you can read the window.submitTrigger variable in your validation routines to work out which element triggered the submission, for example /* somewhere in pagevalidate() routine */ /* note here that I am assuming the html id of the selectbox is "staffselect" -&gt; I'm not familiar with Tapestry so simply had to make the assumption that this is the correct id - if not, change the string you're searching for accordingly */ if (window.submitTrigger.id = "staffselect") { //do something here } Of note, is that I think it's bad style to use onchange in this way, however not understanding Tapestry, I'm just giving you the most simple change to what's already there which I assume will work...
score: 1
has comment: http://stackoverflow.com/comment/2684406
accepted answer of: http://stackoverflow.com/q/2652022
answers question: http://stackoverflow.com/q/2652022
type: AcceptedAnswer
downvote count: 0
has comment: http://stackoverflow.com/comment/2674780
type: Answer

http://stackoverflow.com/comment/2656613
has text: @Matti, sometimes i don't know what the other questions are. Usualy other people do though. Again this is all evedenced by the answers below.
type: QuestionComment
type: Comment
score: 1
comment on: http://stackoverflow.com/q/2641685

http://stackoverflow.com/a/19602592
type: Answer
answers question: http://stackoverflow.com/q/2613404
score: 0
has body: Chunk, my no-nonsense template engine for Java, would be a good choice. Lightweight. Great docs with examples and recipes: http://www.x5software.com/chunk Standalone - no servlets required. Templates from filesystem, classpath, strings, a webserver, or write your own template provider. Based on simple templates with {$tags}. Templates can include other templates or even execute them as macros with a json-formatted dictionary of tag values. Looping, conditionals, filters, all the typical goodies.

timezone
tags question: http://stackoverflow.com/q/2627992
type: Tag
tag name: timezone
tags question: http://stackoverflow.com/q/2644477
tags question: http://stackoverflow.com/q/2646037
tags question: http://stackoverflow.com/q/2600604
tags question: http://stackoverflow.com/q/2673968
tags question: http://stackoverflow.com/q/2609360

http://stackoverflow.com/a/2696566
downvote count: 0
score: 4
type: AcceptedAnswer
accepted answer of: http://stackoverflow.com/q/2653718
answers question: http://stackoverflow.com/q/2653718
type: Answer
upvote count: 4
has body: The "java:" scheme was introduced in J2EE for accessing process-local data. The "comp" context is short for "component"; it contains data that is local to the J2EE component (web module or EJB type) that is active on the current thread. The "env" subcontext is short for "environment"; it is the context under which EJB references, resource references, and environment entries are bound. The "wm/default" is an arbitrary name. The "wm" subcontext name is the convention for work managers, but the full name could have also been "java:comp/env/myDefaultWM", where web.xml/ejb-jar.xml defined a resource-ref with &lt;res-ref-name&gt;myDefaultWM&lt;res-ref-name&gt;.

http://stackoverflow.com/a/2721359
accepted answer of: http://stackoverflow.com/q/2721322
has comment: http://stackoverflow.com/comment/2747550
has body: Swing has the concept of pluggable look and feels. Some of those look and feels mimic the look of native components from Windows, GTK+, etc. Even on Windows there are two separate look and feels - Classic and Vista I think. Maybe you're using different OSes on your two systems and an GUI designer that sets the look and feels automatically. Most don't however - the default look and feel Metal(before Java 1.6.10) and Nimbus look the same on every OS. // build the look and feel section final LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels(); List&lt;String&gt; lookAndFeelNames = new ArrayList&lt;String&gt;(); lookAndFeelNames.add("System"); for (LookAndFeelInfo lookAndFeelInfo : lookAndFeelInfos) { if (!lookAndFeelInfo.getName().equals("CDE/Motif")) { lookAndFeelNames.add(lookAndFeelInfo.getName()); } } if (selectedLookAndFeel.equals("System")) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(SpellbookFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(SpellbookFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(SpellbookFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(SpellbookFrame.class.getName()).log(Level.SEVERE, null, ex); } } else { for (LookAndFeelInfo lookAndFeelInfo : lookAndFeelInfos) { if (lookAndFeelInfo.getName().equals(selectedLookAndFeel)) { try { UIManager.setLookAndFeel(lookAndFeelInfo.getClassName()); } catch (ClassNotFoundException e1) { e1.printStackTrace(); } catch (InstantiationException e1) { e1.printStackTrace(); } catch (IllegalAccessException e1) { e1.printStackTrace(); } catch (UnsupportedLookAndFeelException e1) { e1.printStackTrace(); } } } } SwingUtilities.updateComponentTreeUI(tabbedPane)…
answers question: http://stackoverflow.com/q/2721322
upvote count: 2
has comment: http://stackoverflow.com/comment/2747462
type: AcceptedAnswer
downvote count: 0
type: Answer
score: 2

http://stackoverflow.com/q/2759484
score: 3
has body: I am trying to compile with javac on Snow Leopard through the command line. I have Xcode installed. I am just using a simple Hello World file, it works in Eclipse but I can't get it to work using javac. javac -version returns javac 1.6.0_17 HelloWorld.java public class HelloWorld { public static void main(String[] args) { String message = "Welcome to Java!"; System.out.println(message); } } I type: javac HelloWorld.java and get the following error. HelloWorld.java:1: class, interface, or enum expected public class HelloWorld ^ 1 error and... javac -cp . HelloWorld.java returns the same. echo $CLASSPATH just returns blank. Thanks for the help.
tagged with: java
answer count: 2
has answer: http://stackoverflow.com/a/2759498
downvote count: 0
has title: Can't get Javac to work on Mac OS X
favorite count: 0
accepted answer: http://stackoverflow.com/a/2759498
tagged with: macos
type: AnsweredQuestion
tagged with: compiler-errors
possible better answer: http://stackoverflow.com/a/2760053
upvote count: 3
has answer: http://stackoverflow.com/a/2760053
type: Question

http://stackoverflow.com/a/55673220
has comment: http://stackoverflow.com/comment/113881906
type: Answer
upvote count: 12
answers question: http://stackoverflow.com/q/2618059
has body: Minimal runnable example The first thing that you have to know, is that the concept of NaN is implemented directly on the CPU hardware. All major modern CPUs seem to follow IEEE 754 which specifies floating point formats, and NaNs, which are just special float values, are part of that standard. Therefore, the concept will be the very similar across any language, including Java which just emits floating point code directly to the CPU. Before proceeding, you might want to first read up the following answers I've written: a quick refresher of the IEEE 754 floating point format: What is a subnormal floating point number? some lower level NaN basics covered using C / C++: What is difference between quiet NaN and signaling NaN? Now for some Java action. Most of the functions of interest that are not in the core language live inside java.lang.Float. Nan.java import java.lang.Float; import java.lang.Math; public class Nan { public static void main(String[] args) { // Generate some NaNs. float nan = Float.NaN; float zero_div_zero = 0.0f / 0.0f; float sqrt_negative = (float)Math.sqrt(-1.0); float log_negative = (float)Math.log(-1.0); float inf_minus_inf = Float.POSITIVE_INFINITY - Float.POSITIVE_INFINITY; float inf_times_zero = Float.POSITIVE_INFINITY * 0.0f; float quiet_nan1 = Float.intBitsToFloat(0x7fc00001); float quiet_nan2 = Float.intBitsToFloat(0x7fc00002); float signaling_nan1 = Float.intBitsToFloat(0x7fa00001); float signaling_nan2 = Float.intBitsToFloat(0x7fa00002); float nan_minus = -nan; // Generate some infinities. float positive_inf = Float.POSITIVE_INFINITY; float negative_inf = Float.NEGATIVE_INFINITY; float one_div_zero = 1.0f / 0.0f; float log_zero = (float)Math.log(0.0); // Double check that they are actually NaNs. assert Float.isNaN(nan); assert Float.isNaN(zero_div_zero); assert Float.isNaN(sqrt_negative); assert Float.isNaN(inf_minus_inf); assert Float.isNaN(inf_times_zero); assert Float.isNaN(quiet_nan1); assert Float.isNaN(quiet_nan2); assert Float.isNa…
score: 12
downvote count: 0

http://stackoverflow.com/a/47413441
has body: This will add all dates between two dates and It will add current dates and then new dates will be added based on loop condition. private void onDateSet(){ Calendar endDate = Calendar.getInstance(),startDate = Calendar.getInstance(); startDate.set(currentYear,currentMonthOfYear,currentDayOfMonth); endDate.set(inputYear,inputMonthOfYear,inputDayOfMonth); datesToAdd(startDate,endDate); } //call for get dates list private List&lt;Date&gt; datesToAdd(Calendar startDate,Calendar endDate){ List&lt;Dates&gt; datesLists = new List&lt;&gt;(); while (startDate.get(Calendar.YEAR) != endDate.get(Calendar.YEAR) || startDate.get(Calendar.MONTH) != endDate.get(Calendar.MONTH) || startDate.get(Calendar.DAY_OF_MONTH) != endDate.get(Calendar.DAY_OF_MONTH)) { datesList.add(new Date(startDate.get(Calendar.YEAR), startDate.get(Calendar.MONTH), startDate.get(Calendar.DATE)); startDate.add(Calendar.DATE, 1);//increas dates } return datesList; }
type: Answer
answers question: http://stackoverflow.com/q/2689379
has comment: http://stackoverflow.com/comment/81816964
has comment: http://stackoverflow.com/comment/81809090
score: 0
has comment: http://stackoverflow.com/comment/81832435

http://stackoverflow.com/a/2785322
has comment: http://stackoverflow.com/comment/137245770
score: 15
has comment: http://stackoverflow.com/comment/138498679
downvote count: 1
upvote count: 16
has body: It doesn't have to be. The important thing is that it should be a singleton.
type: Answer
answers question: http://stackoverflow.com/q/2784009
has comment: http://stackoverflow.com/comment/138379623

jtextfield
tags question: http://stackoverflow.com/q/2739617
tags question: http://stackoverflow.com/q/2725716
tag name: jtextfield
type: Tag
tags question: http://stackoverflow.com/q/2706535

http://stackoverflow.com/a/17814674
upvote count: 1
answers question: http://stackoverflow.com/q/2746598
downvote count: 0
has body: What about phpj? It can be used as view templates or you can make your web server system from scratch I made phpj because i dont like to having to update my application and load it with tomcat all the time, so with this i can use static locations for my web application using apache-like configurations
type: Answer
score: 1

http://stackoverflow.com/a/4197279
has comment: http://stackoverflow.com/comment/4979077
upvote count: 7
has comment: http://stackoverflow.com/comment/38378633
has comment: http://stackoverflow.com/comment/12281399
has comment: http://stackoverflow.com/comment/12211267
type: Answer
downvote count: 0
has body: On Mac OS X 10.7 (Lion), you have to first download and install the developer package: go to https://developer.apple.com/downloads/index.action log in (or sign up for a developer account) search for "java" in the search box above Categories choose the newest Java for Mac OS X 10.7 Update XXX Developer Package download and install src.jar can then be found in: /Library/Java/JavaVirtualMachines/1.6.0_***.jdk/Contents/Home/src.jar On the older Mac OS X 10.6 (Snow Leopard), you do the same as above, except look for the newest Java for Mac OS X 10.6 Update XXX Developer Package): src.jar can then be found in: /Library/Java/JavaVirtualMachines/1.6.0_***.jdk/Contents/Home/src.jar
answers question: http://stackoverflow.com/q/2767220
has comment: http://stackoverflow.com/comment/12308922
score: 7

http://stackoverflow.com/q/2619288
favorite count: 0
tagged with: xpath
has body: A html page has paging links, 1 set at the top of the page and another on the bottom of the page. Using HtmlUnit, I am currently getting the HtmlAnchor on the page using getByAnchorText("1"); There is a problem in some of the links on the top, so I want to reference the bottom links using XPath. nextPageAnchor = (HtmlAnchor) page.getByXPath(""); How can I reference the 2nd link on the page, with using xpath? I need to reference the link using the AnchorText, so a link like: 33 The href has random text, and is a javascript function so I have no idea what it will be. Is this possible with xpath?
has title: Xpath to get the 2nd url with the matching text in the href tag
type: AnsweredQuestion
score: 4
tagged with: java
type: Question
has answer: http://stackoverflow.com/a/2620109
has answer: http://stackoverflow.com/a/2619308
tagged with: htmlunit
accepted answer: http://stackoverflow.com/a/2620109
upvote count: 4
possible better answer: http://stackoverflow.com/a/2619308
answer count: 2
downvote count: 0

http://stackoverflow.com/q/2731233
has answer: http://stackoverflow.com/a/2733674
answer count: 2
accepted answer: http://stackoverflow.com/a/2731448
favorite count: 0
tagged with: apache-commons-config
has answer: http://stackoverflow.com/a/2731448
score: 2
type: AnsweredQuestion
downvote count: 0
tagged with: java
has title: Apache Commons Configuration trigger event on property file change
type: Question
upvote count: 2
possible better answer: http://stackoverflow.com/a/2733674
has body: I'm using Apache Commons Configuration library to store my app properties. I can monitor changes of property file using FileChangedReloadingStrategy and it works perfectly. What I would like to do is to trigger configurationChanged event of ConfigurationListener when property file is changed. This case works if I will try to get a property from my code directory = MyConfiguration.getInstance().getString("directory"); this line will trigger configurationChanged. But I need this event to be triggered when FileChangedReloadingStrategy catches changes in file without doing redundant calls. Thanks.

http://stackoverflow.com/comment/2849134
type: AnswerComment
type: Comment
score: 0
has text: the client side is connect to a shared object with red5. when the user press a betting command it runs a function in my main application class. only then i need to take the next betting schedule that should start in X seconds and to start it immediately.
comment on: http://stackoverflow.com/a/2774301

http://stackoverflow.com/comment/2741529
score: 0
has text: See: http://stackoverflow.com/questions/1295170/whats-the-difference-between-boolean-and-boolean-in-java and see also: http://stackoverflow.com/questions/2306257/boolean-instanceof-object-is-true
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2716002

http://stackoverflow.com/a/2644816
answers question: http://stackoverflow.com/q/2644771
has body: ExampleThread 1 and ExampleThread 2 are different objects. In one of them you assigned 10 to both int fields and that's why you see that output for first thread. In second you didn't assign anything to int fields so you get 0s.
has comment: http://stackoverflow.com/comment/2659896
upvote count: 2
score: 2
downvote count: 0
type: Answer

http://stackoverflow.com/a/35354148
has body: Problem: The problem is to get the second largest array element. Observation: Second largest number is defined as the number that has the minimum difference when subtracted from the maximum element in the array. Solution: This is a two pass solution. First pass is to find the maximum number. Second pass is to find the element that has minimum difference with the maximum element as compared to other array elements. Example: In the array [2, 3, 6, 6, 5] maximum = 6 and second maximum = 5 , since it has the minimum difference to the maximum element 6 - 5 = 1 the solution for second largest = 5 function printSecondMax(myArray) { var x, max = myArray[0]; // Find maximum element for(x in myArray){ if(max &lt; myArray[x]){ max = myArray[x]; } } var secondMax = myArray[0], diff = max - secondMax; // Find second max, an element that has min diff with the max for(x in myArray){ if(diff != 0 &amp;&amp; (max - myArray[x]) != 0 &amp;&amp; diff &gt; (max - myArray[x])){ secondMax = myArray[x]; diff = max - secondMax; } } console.log(secondMax); } Complexity : O(n), This is the simplest way to do this. For finding maximum element even more efficiently one can look into max heap, a call to max-heapify will take O(log n) time to find the max and then pop-ing the top element gives maximum. To get the second maximum, max-heapify after pop-ing the top and keep pop-ing till you get a number that is less than maximum. That will be the second maximum. This solution has O(n log n) complexity.
score: 0
answers question: http://stackoverflow.com/q/2615712
type: Answer

http://stackoverflow.com/q/2786292
linked to: http://stackoverflow.com/q/266903
score: 5
upvote count: 5
has answer: http://stackoverflow.com/a/2786641
has answer: http://stackoverflow.com/a/46274173
downvote count: 0
has answer: http://stackoverflow.com/a/2786437
favorite count: 0
possible better answer: http://stackoverflow.com/a/2786641
has title: Is it possible to instantiate a Java Annotation given a Class<? extends Annotation>?
has answer: http://stackoverflow.com/a/2786349
has body: I have a Class&lt;? extends Annotation&gt; and tried calling newInstance() but Java yelled at me for the obvious reason that I can't instantiate an interface. But I know frameworks like EasyMock are perfectly capable of instantiating interfaces. What would it take to get a completely dumb Annotation instance out of my Class?
answer count: 4
linked to: http://stackoverflow.com/q/16299717
type: AnsweredQuestion
tagged with: reflection
has comment: http://stackoverflow.com/comment/121656567
tagged with: java
tagged with: annotations
accepted answer: http://stackoverflow.com/a/2786437
type: Question

http://stackoverflow.com/q/2731295
has comment: http://stackoverflow.com/comment/2759507
has comment: http://stackoverflow.com/comment/2758806
accepted answer: http://stackoverflow.com/a/2731316
has comment: http://stackoverflow.com/comment/2758932
favorite count: 0
tagged with: while-loop
has answer: http://stackoverflow.com/a/2731316
has body: I solved a problem recently. But I have this one piece of code where I dont utilize the for loop initialization and condition check. It looks a bit odd that way for a for loop. I want to convert it into a while loop. Please help me do it. I tried many times, but somewhere something is missing. for(;;current =(current+1)%n){ if(eliminated[current%n]){ continue; }else{ inkiPinki++; if(inkiPinki == m){ eliminated[current%n] = true; printStatus(eliminated, people); remainingGuys--; break; } } } In the above code eliminiated[index] is a boolean. Edit: Thanks to Geoff who provided me with a solution which I further minimized like this. while( eliminated[current] || ++inkiPinki != m ) current = (current+1) % n; eliminated[current] = true; printStatus( eliminated, people ); remainingGuys--;
answer count: 4
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2731440
downvote count: 0
has answer: http://stackoverflow.com/a/2731501
score: 1
tagged with: java
has title: Need to convert this for loop to a while loop
has comment: http://stackoverflow.com/comment/2758866
has comment: http://stackoverflow.com/comment/2758839
type: Question
has comment: http://stackoverflow.com/comment/2758871
has comment: http://stackoverflow.com/comment/2758901
has answer: http://stackoverflow.com/a/2731350
possible better answer: http://stackoverflow.com/a/2731440
tagged with: for-loop
upvote count: 1

http://stackoverflow.com/q/2731443
tagged with: mysql
upvote count: 7
type: Question
has answer: http://stackoverflow.com/a/2731506
has title: cast a String to sql time
downvote count: 0
tagged with: sql
favorite count: 0
accepted answer: http://stackoverflow.com/a/2731506
has answer: http://stackoverflow.com/a/2731475
has comment: http://stackoverflow.com/comment/131606376
has answer: http://stackoverflow.com/a/74553729
answer count: 4
possible better answer: http://stackoverflow.com/a/8461549
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/8461549
has body: How we cast a string into time type with mysql in java So String------->java.sql.time thanks.
score: 7
tagged with: java

http://stackoverflow.com/comment/2636415
has text: What's the end goal here? Java has many tools for creating or modifying byte code (compiled Java code), but I don't know of any for generating Java code directly.
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2623726

http://stackoverflow.com/a/2758536
score: 2
upvote count: 3
downvote count: 1
has body: Is there a way to force the JVM to run on a single processor or Core. Yes. There are OS-specific tools for doing this. In Java, is there a way to force a JVM instance to run on a single CPU/Core. No. Additionally is there a way for given thread to figure out what CPU it is running on? No. (A thread figuring this out implies that you are doing this in Java ...) Those answers should be qualified by saying that is is not possible to do these things in pure Java. You might be able to use JNI to call some OS specific native APIs to do these things. But it is simpler and cleaner to do the task from the command prompt or from some appropriate OS management GUI.
answers question: http://stackoverflow.com/q/2758448
type: Answer

http://stackoverflow.com/comment/2732682
has text: One additional bit of info that might be useful... If you open the 'com.mycompany.myproject' node, what do you see as the content of the node?
comment on: http://stackoverflow.com/q/2701912
score: 0
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2653855
possible better answer: http://stackoverflow.com/a/16786475
tagged with: java
has answer: http://stackoverflow.com/a/16786475
has body: I want to implement a Custom logger which logs all log entries to a Database. Currently my app logs this way (slf4j and log4j binding): private static final Logger logger = LoggerFactory.getLogger( MyClass.class ); I'm not sure how to proceed. My Idea is to implement a Custom Logging binding through implementing the org.slf4j.Logger Interface What would be the next steps? My target is to not change the current code Links I considered: Java custom logger: logging standards or/and best practices http://www.slf4j.org/manual.html
tagged with: slf4j
answer count: 2
favorite count: 0
score: 38
accepted answer: http://stackoverflow.com/a/2653919
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/8629497
downvote count: 0
has title: Implement Custom Logger with slf4j
has answer: http://stackoverflow.com/a/2653919
has comment: http://stackoverflow.com/comment/2670280
type: Question
upvote count: 38
has comment: http://stackoverflow.com/comment/95663462

http://stackoverflow.com/a/2623834
upvote count: 1
has comment: http://stackoverflow.com/comment/2668157
score: 1
answers question: http://stackoverflow.com/q/2623726
has comment: http://stackoverflow.com/comment/2636598
downvote count: 0
has body: I have had some success using ASM to both modify existing classes at the bytecode level or to generate completely new classes on the fly. The tutorial walks you through this in a very understandable fashion. ASM like most such tools generates bytecode not source. The reason for this is if you want to dynamically generate and execute new code from with a program, historically it was not straight forward to invoke the Java compiler. Therefore it was generally easier to generate and use bytecode than source. If you need to generate and run the code immediately within your program I recommend you use bytecode manipulation tool. If all you need is Java source, I would roll my own code generator that takes my input format and generates the code. You may want to look for a framework to help you with this but since a source file is just text, usually it is just as easy to create this yourself especially if you have a custom input format.
type: Answer
has comment: http://stackoverflow.com/comment/2642496

http://stackoverflow.com/q/2757529
has answer: http://stackoverflow.com/a/2757542
tagged with: java
has answer: http://stackoverflow.com/a/2757554
type: Question
upvote count: 4
has title: Need java regex to match substring with multiple whitespace, only one punctuation
downvote count: 0
score: 4
answer count: 3
tagged with: regex
favorite count: 0
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2772219
has body: I want to make sure that the substring I am matching only has one possible piece of punctuation and as much whitespace as necessary. This is inside of a much longer REGEX, currently what there is is the following: [\p{P},\s] but that will match all punctuation and whitespace, so that it accepts: the string before,,,, ,,,. ....the string after when what I want it to match is any amount of whitespace in between the string before and the string after, with only one item of punctuation allowed- note that the punctuation can come at the beginning of the string, at the end, or with as much whitespace before or after.

http://stackoverflow.com/q/2675903
downvote count: 0
has answer: http://stackoverflow.com/a/2678257
linked to: http://stackoverflow.com/q/1335170
answer count: 1
tagged with: user-interface
has body: I need a multi-value JSlider (or a similar component) for an analysis application. The two features missing from the regular JSlider are the ability to have more than one knob and also the ability to add or remove knobs on the fly. The reason for this is that they will be used to partition the 0..100% range for a particular factor into two or more subranges which are fed into a binning algorithm. After some unsuccessful googling, it seems I'll have to develop a custom component (which I'm not very good at, I've been coding in Java for 10 years, but have zero experience in Swing). Is it possible to extend (easily :-) the JSlider component? Or are there better alternatives, perhaps not Swing-based but web-based? I have some flexibility in selecting the GUI approach for this. The current analysis application is command-line so a Swing GUI would be most straighforward, but nothing really prevents me for turning it into a web app if need be. Thank you!
favorite count: 0
type: UnansweredQuestion
has title: Multi-value JSlider component?
upvote count: 1
tagged with: swing
tagged with: jslider
score: 1
tagged with: java
type: Question
has comment: http://stackoverflow.com/comment/2694793

http://stackoverflow.com/q/2727568
tagged with: location
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2728356
downvote count: 0
score: 1
favorite count: 0
has comment: http://stackoverflow.com/comment/2754845
type: Question
has title: No GPS Update retrieved? Problem in Code?
tagged with: android
has body: I've got a serious problem with my GPS on my Nexus One: I wrote a kind of hello world with GPS, but the Toast that should be displayed isn't :( I don't know what I'm doing wrong...maybe you could help me getting this work. Here's my code: package gps.test; import android.app.Activity; import android.content.Context; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.Toast; public class GPS extends Activity { private LocationManager lm; private LocationListener locationListener; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // ---use the LocationManager class to obtain GPS locations--- lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locationListener = new MyLocationListener(); lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 100, 1, locationListener); } private class MyLocationListener implements LocationListener { @Override public void onLocationChanged(Location loc) { if (loc != null) { Toast.makeText( getBaseContext(), "Location changed : Lat: " + loc.getLatitude() + " Lng: " + loc.getLongitude(), Toast.LENGTH_SHORT).show(); } } @Override public void onProviderDisabled(String provider) { // TODO Auto-generated method stub } @Override public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Override public void onStatusChanged(String provider, int status, Bundle extras) { // TODO Auto-generated method stub } } } Theoretically there should be a new toast every 100 milliseconds, shouldn't it? Or at least, when I change my position by one meter!? I've no idea why it doesn't. I must admit I'm new to the topic, maybe I've missed something? It would be great if you could give me a hint :) nice greetings, poeschlorn
has comment: http://stackoverflow.com/comment/2756867
tagged with: gps
has comment: http://stackoverflow.com/comment/2755527
accepted answer: http://stackoverflow.com/a/2728356
has comment: http://stackoverflow.com/comment/2755300
tagged with: java
answer count: 2
has comment: http://stackoverflow.com/comment/2755054
upvote count: 1
has comment: http://stackoverflow.com/comment/2754798
has comment: http://stackoverflow.com/comment/2754762
has answer: http://stackoverflow.com/a/2728241
possible better answer: http://stackoverflow.com/a/2728241

http://stackoverflow.com/comment/2753503
type: Comment
comment on: http://stackoverflow.com/a/2721565
type: AnswerComment
has text: Thanks for citing an application. Is this Eclipse PDE (http://www.eclipse.org/pde/)?
score: 0

http://stackoverflow.com/a/2772860
downvote count: 0
answers question: http://stackoverflow.com/q/2772701
has body: Is it possible that MySql listening on the same port as JBoss? Is there a port number given in the error message - something like Address already in use: JVM_Bind:8080 You can change the port in JBoss server.xml to test this.
type: Answer
upvote count: 3
score: 3

http://stackoverflow.com/comment/2678776
score: 0
type: Comment
has text: @Jon Skeet, hm, you are right about that. But it's closely related
comment on: http://stackoverflow.com/a/2661385
type: AnswerComment

http://stackoverflow.com/a/2655737
answers question: http://stackoverflow.com/q/2651819
downvote count: 0
has body: While you've gotten a number of answers that cover your question fairly directly, I think it might be useful to step back a bit, and look at the question a bit more generally. That is, not to look specifically at how the Java library happens to be written, and look at why it's written that way. The problem here is that inheritance only models one type of commonality. If you pick out two things that both seem "collection-like", you can probably pick out a 8 or 10 things they have in common. If you pick out a different pair of "collection-like" things, they'll also 8 or 10 things in common -- but they won't be the same 8 or 10 things as the first pair. If you look at a dozen or so different "collection-like" things, virtually every one of them will probably have something like 8 or 10 characteristics in common with at least one other one -- but if you look at what's shared across every one of them, you're left with practically nothing. This is a situation that inheritance (especially single inheritance) just doesn't model well. There's no clean dividing line between which of those are really collections and which aren't -- but if you want to define a meaningful Collection class, you're stuck with leaving some of them out. If you leave only a few of them out, your Collection class will only be able to provide quite a sparse interface. If you leave more out, you'll be able to give it a richer interface. Some also take the option of basically saying: "this type of collection supports operation X, but you're not allowed to use it, by deriving from a base class that defines X, but attempting to use the derived class' X fails (e.g., by throwing an exception). That still leaves one problem: almost regardless of which you leave out and which you put in, you're going to have to draw a hard line between what classes are in and what are out. No matter where you draw that line, you're going to be left with a clear, rather artificial, division between some things that are quite si…
type: Answer
upvote count: 12
score: 12

http://stackoverflow.com/comment/2684027
type: Comment
has text: Yeh we have legacy C code that we want to use so I was attempting to find the limits of the NDK, to see what we can and cant use and what we should and shouldn't use
comment on: http://stackoverflow.com/a/2664601
type: AnswerComment
score: 0

http://stackoverflow.com/a/2767963
downvote count: 0
answers question: http://stackoverflow.com/q/2767841
type: Answer
score: 2
upvote count: 2
has body: The servlet api will not do anything for you to make your concurrency problems disappear. Things like using the synchronized keyword on your servlets are a bad idea because you are basically forcing your threads to be processed one at a time and it ruins your ability to respond quickly to multiple users. If you use Spring or EJB3, either one will provide threadlocal database connections and the ability to specify transactions. You should definitely check out one of those.

http://stackoverflow.com/a/2761625
type: Answer
answers question: http://stackoverflow.com/q/2761473
has comment: http://stackoverflow.com/comment/2799945
has comment: http://stackoverflow.com/comment/2793715
score: 0
has comment: http://stackoverflow.com/comment/2800084
has body: If you download the RIM JDE for the blackberry version you require, available here: https://www.blackberry.com/Downloads/entry.do?code=00EC53C4682D36F5C4359F4AE7BD7BA1 It should come with a jar file that you can import as a library. I think you want the Java Development Environment v4.2.1. To include it in Eclipse, I think you can import your project, right click on it in the Navigator/Package Explorer, go to properties, then click "Java Build Path", "Libraries". Remove the current RIM library, and then click "Add Library". Choose "UserLibrary", then click "User Libraries" and "New". Give it a name. Click "Add Jars", and then navigate to the JAR file that came with the JDE that you downloaded.

http://stackoverflow.com/comment/2806309
has text: @polygenelubricants I am not saying that you _can't_ have an Iterator on a string. I'm only trying to explain why. You can have an iterator on anything you want. The question is if it makes sense.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2772544

http://stackoverflow.com/a/2629295
type: Answer
upvote count: 1
score: 1
downvote count: 0
has body: In java swing this is called the 'look and feel'. You can change the look and feel as follows: UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName()); Sun has a large Look and feel tutorial that explains how this works. I'm not sure which look and feel you are linking to though, you'd have to find that out.
accepted answer of: http://stackoverflow.com/q/2629031
answers question: http://stackoverflow.com/q/2629031
type: AcceptedAnswer

buildconfig
tags question: http://stackoverflow.com/q/2718565
type: Tag
tag name: buildconfig

http://stackoverflow.com/a/2699818
has comment: http://stackoverflow.com/comment/9823252
upvote count: 3
downvote count: 1
has comment: http://stackoverflow.com/comment/9822078
has comment: http://stackoverflow.com/comment/9823945
answers question: http://stackoverflow.com/q/2698217
has comment: http://stackoverflow.com/comment/9824110
type: Answer
has body: A LinkedHashMap has a doubly linked list running through a hashtable. A FIFO only mutates the links on a write (insertion or removal). This makes implementing a version fairly straightforward. Write a LHM with only insertion order allowed. Switch to a ConcurrentHashMap as the hashtable. Protect #put() / #putIfAbsent() / #remove() with a lock. Make the "next" field volatile. On iteration, no lock is needed as you can safely follow the "next" field. Reads can be lock-free by just delegating to the CHM on a #get().
score: 2

http://stackoverflow.com/comment/2811821
type: QuestionComment
comment on: http://stackoverflow.com/q/2777214
has text: Clearly the people responsible for replacing a > b with a.compare(b) > 0 couldn't imagine a world where you wouldn't want to use getBigDecimal in place of any of the other options!
score: 1
type: Comment

http://stackoverflow.com/q/2686664
tagged with: jsf
has body: I'm using JSF (Mojarra 1.2) with Richfaces (3.3.2) within some facelets which are used as portlets (I'm using the Jboss Portlet Bridge 2.0 here). Now I'm facing something strange: I've got an actionlistener on my &lt;h:commandButton&gt; which is triggered, when the button is clicked but when I simply reload the page, the action is executed everytime I load the page again. This happens only if I already triggered the action before. Is this behaviour normal? I should notice that Spring 2.5 is used to manage my beans, the mentioned beans are session-scope beans, maybe this is a interessting point?!
tagged with: java
type: Question
downvote count: 0
has answer: http://stackoverflow.com/a/2686729
answer count: 1
has title: JSF, actionlistener at facelets
favorite count: 0
upvote count: 2
accepted answer: http://stackoverflow.com/a/2686729
type: AnsweredQuestion
score: 2

http://stackoverflow.com/q/2746218
score: 2
answer count: 1
has body: I'm required to implement a license management and i could not understand the difference between an online and offline license verification. Could you please try to help me? Regards,
favorite count: 0
upvote count: 2
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2747216
tagged with: java
has title: The difference between online and offline license verification
has comment: http://stackoverflow.com/comment/117752396
type: Question
downvote count: 0
accepted answer: http://stackoverflow.com/a/2747216

http://stackoverflow.com/comment/45731426
score: 1
type: AnswerComment
has text: @BradyZhu: Granted the answer above does not solve my problem with the fixed size array, but you are basically saying RTFM here, which is always bad form. Please expound on what is wrong with the answer or don't bother to comment.
type: Comment
comment on: http://stackoverflow.com/a/25594467

http://stackoverflow.com/a/2750681
answers question: http://stackoverflow.com/q/2749191
has comment: http://stackoverflow.com/comment/2781999
downvote count: 0
has body: @aioobe's approach is sound and the example is compelling. In addition to the cited tutorial, Performing Custom Painting, I would add that drawing should take place on the Event Dispatch Thread (EDT). In the variation below, note how the GUI is built using EventQueue.invokeLater. Similarly, the actionPerformed() method of javax.swing.Timer invokes repaint() on the EDT to display recently added nodes. A more elaborate example may be found here. import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.List; import java.util.Random; import javax.swing.*; public class StarPanel extends JPanel implements ActionListener { private static final Random rnd = new Random(); private final Timer t = new Timer(100, this); private final List&lt;Node&gt; nodes = new ArrayList&lt;Node&gt;(); private static class Node { private Point p; private Color c; public Node(Point p, Color c) { this.p = p; this.c = c; } } public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { @Override public void run() { JFrame f = new JFrame("Star Topology"); f.add(new StarPanel()); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.pack(); f.setVisible(true); } }); } public StarPanel() { this.setPreferredSize(new Dimension(400, 400)); t.start(); } @Override // Respond to the Timer public void actionPerformed(ActionEvent e) { int w = this.getWidth(); int h = this.getHeight(); nodes.add(new Node( new Point(rnd.nextInt(w), rnd.nextInt(h)), new Color(rnd.nextInt()))); this.repaint(); } @Override public void paintComponent(Graphics g) { int w2 = this.getWidth() / 2; int h2 = this.getHeight() / 2; for (Node n : nodes) { g.setColor(n.c); int x = n.p.x; int y = n.p.y; g.drawLine(w2, h2, x, y); g.drawLine(w2, h2, x, y); g.drawRect(x - 2, y - 2, 4, 4); } } }
type: Answer
has comment: http://stackoverflow.com/comment/2781126
upvote count: 2
has comment: http://stackoverflow.com/comment/2781918
score: 2

http://stackoverflow.com/a/2728224
type: Answer
has comment: http://stackoverflow.com/comment/2755444
has comment: http://stackoverflow.com/comment/2755659
answers question: http://stackoverflow.com/q/2728139
score: 0
has body: Having a coding standards document that is distributed to all of the developers in the team/department/organisation is a good start.

http://stackoverflow.com/comment/2629771
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2616023
has text: I can't reproduce it myself on Vista, and the user can't get a thread dump from VisualVM, as the VM seems to be no longer alive.
type: AnswerComment

http://stackoverflow.com/a/5183296
has comment: http://stackoverflow.com/comment/99524109
type: Answer
accepted answer of: http://stackoverflow.com/q/2712967
has body: Found it! The thing is you want to enter passive mode after you connect, but before you log in. Your code returns nothing for me, but this works for me: import org.apache.commons.net.ftp.FTPClient; import java.io.IOException; import org.apache.commons.net.ftp.FTPFile; public class BasicFTP { public static void main(String[] args) throws IOException { FTPClient client = new FTPClient(); client.connect("c64.rulez.org"); client.enterLocalPassiveMode(); client.login("anonymous", ""); FTPFile[] files = client.listFiles("/pub"); for (FTPFile file : files) { System.out.println(file.getName()); } } } Gives me this output: c128 c64 c64.hu incoming plus4
has comment: http://stackoverflow.com/comment/22841531
score: 101
has comment: http://stackoverflow.com/comment/22988162
has comment: http://stackoverflow.com/comment/139339792
has comment: http://stackoverflow.com/comment/38296808
upvote count: 101
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2712967

http://stackoverflow.com/comment/2611185
type: Comment
has text: Does that definition of `static` apply to nested `static class` as well?
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2601898

http://stackoverflow.com/comment/2775671
comment on: http://stackoverflow.com/a/2722434
type: Comment
has text: @BalusC right, the returned collection has the wrong type. see my answer for the solution to that.
score: 0
type: AnswerComment

http://stackoverflow.com/a/2786349
has comment: http://stackoverflow.com/comment/2827654
score: 2
upvote count: 2
has comment: http://stackoverflow.com/comment/30086884
has comment: http://stackoverflow.com/comment/2821957
downvote count: 0
has body: You can't create an instance of a class that's not fully specified. To illustrate, calling newInstance() on a class of type Class&lt;Object&gt; would definately create an Object, but calling newInstance() on a class of type Class&lt;?&gt; would leave the compiler wondering which class out of the entire universe of possibilities it should construct. Just because you have narrowed the field down a bit by specifying that instead of just ?, you want a ? that extends Annotation doesn't mean you've actually named a particular class to construct. ? extends Annotation just means "some class that extends Annotation" Without naming the exact class, the ClassLoader cannot figure out which constructor to call, because there is no limit to the number of classes that might extend Annotation. EasyMock doesn't instantiate Interfaces. I'm not familiar with the framework, but it likely instantiates java.lang.Object(s) which extend the desired interface, or it instantiates some sort of "behind the scenes" framework class which was generated with an "implements interface" clause in the class definition. Interfaces don't have a default constructor.
answers question: http://stackoverflow.com/q/2786292
type: Answer

modal-dialog
tag name: modal-dialog
type: Tag
tags question: http://stackoverflow.com/q/2681086
tags question: http://stackoverflow.com/q/2620448

http://stackoverflow.com/comment/2806285
type: QuestionComment
has text: So basically one can say (based on answers below) that professional Java desktop apps virtually do not exists? Is that fair conclusion? So for what purpose is java used then?
type: Comment
score: 0
comment on: http://stackoverflow.com/q/2772259

http://stackoverflow.com/q/2711071
downvote count: 0
has body: I am using javax.validation.Validator and relevant classes for annotation based validation. Configuration&lt;?&gt; configuration = Validation.byDefaultProvider().configure(); ValidatorFactory factory = configuration.buildValidatorFactory(); Validator validator = factory.getValidator(); Set&lt;ConstraintViolation&lt;ValidatableObject&gt;&gt; constraintViolations = validator.validate(o); for (ConstraintViolation&lt;ValidatableObject&gt; value : constraintViolations) { List&lt; Class&lt; ? extends ConstraintValidator&lt; ? extends Annotation,?&gt;&gt;&gt; list = value.getConstraintDescriptor().getConstraintValidatorClasses(); } I get a compilation error stating: Type mismatch: cannot convert from List&lt; Class&lt; ? extends ConstraintValidator&lt; capture#4-of ?,?>>> to List&lt; Class&lt; ? extends ConstraintValidator&lt; ? extends Annotation,?>>> What am I missing?
type: UnansweredQuestion
tagged with: constraints
score: 1
tagged with: java
has answer: http://stackoverflow.com/a/6104967
type: Question
tagged with: bean-validation
upvote count: 1
answer count: 1
has title: Constraint Validation
favorite count: 0
tagged with: generics

http://stackoverflow.com/a/2626170
downvote count: 0
answers question: http://stackoverflow.com/q/2626159
upvote count: 2
type: Answer
score: 2
has body: It depends what you are using to parse. I'm guessing this is a Spring bean configuration file. Usually there's a XML Schema associated with it and that will dictate all default values for attributes. So when the actual XML parser walks through the document, it will build some kind of representation (DOM parsers will obviously build a tree, SAX parsers will fire off events, etc) of the XML and insert those default values.

http://stackoverflow.com/a/72750793
answers question: http://stackoverflow.com/q/2704857
upvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/133689955
downvote count: 0
score: 1
has comment: http://stackoverflow.com/comment/133689766
has body: Can you give me some advice? There is an Elephant in the room that nobody has mentioned. Mere regex syntactic correctness is probably not sufficient. Validation using Pattern.compile is not enough. Syntax checking doesn't check that the regex does the right thing. Syntax checking doesn't check that the regex is not harmful. It is not difficult to accidentally or deliberately create a regex that will take an (effectively) infinite time to execute. Especially if the data being searched is pathological for the regex. So allowing users to enter regexes provides a vector for "denial of service" attacks. If you want more information on this problem: Runaway Regular Expressions. Regex Pattern Catastrophic backtracking. Google for "regex catastrophic backtracking". In short, if you let users plug regexes into your application, consider the potential consequences. Especially if the users could do stupid or malicious things.

http://stackoverflow.com/comment/2654151
has text: You call it on the enum value itself: Rate.Excellent.toInt(), or if you were to make the field rate public (and in good style final as well) you could say Rate.Excellent.rate.
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2637943
type: AnswerComment

http://stackoverflow.com/comment/75286916
type: Comment
comment on: http://stackoverflow.com/a/43994890
has text: Actually don't use the exact coordinates I put here. They are in the middle of no where somewhere with no roads around so that won't work.
score: 0
type: AnswerComment

http://stackoverflow.com/a/35315400
answers question: http://stackoverflow.com/q/2610068
upvote count: 3
downvote count: 1
type: Answer
has comment: http://stackoverflow.com/comment/89355327
score: 2
has body: I know it's an old question and this solution will not work at runtime, but I had a similar problem and only found this question. You can find a way to set spymemcached logging level via tomcat config files here. Important part: A short summary how you can make spymemcached more silent: Add the following to $CATALINA_HOME/bin/catalina.sh: CATALINA_OPTS="-Dnet.spy.log.LoggerImpl=net.spy.memcached.compat.log.SunLogger" Add this to $CATALINA_HOME/conf/logging.properties: (A handler's log level threshold can be set using SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST or ALL) net.spy.memcached.level = WARNING To make only the MemcachedConnection less verbose: net.spy.memcached.MemcachedConnection.level = WARNING

http://stackoverflow.com/a/2699841
score: 2
has comment: http://stackoverflow.com/comment/2729859
has comment: http://stackoverflow.com/comment/2722867
downvote count: 0
answers question: http://stackoverflow.com/q/2699774
has comment: http://stackoverflow.com/comment/2723325
type: Answer
has body: It sounds like you're asking about a general philosophy of Object-Oriented Programming. In general, you'll find that modelling real-world objects to classes doesn't always make the best sense for your code. One guideline that's helped me figure this stuff out is a dialogue between two anthropomorphic classes (if someone knows the original source of this quote, I'd appreciate a link!): Class A says to Class B: "Give me the value of x." Class B: "Why do you want the value of x?" Class A: "So I can flange it." Class B: "Ask me, and I'll flange it for you." This helps drive home the point that a class is meant to encapsulate the data and perform manipulations on it. In general, this is a parable that's helped me organize my code better. Another thing you may want to look at are some common Object-Oriented Design Patterns. Something like game dice might make more sense as a Singleton, since you don't need more than one instance of it. If you'd like a good introduction to Design Patterns, I'd recommend picking up the excellent Head First Design Patterns book.
has comment: http://stackoverflow.com/comment/2723404
has comment: http://stackoverflow.com/comment/2730259
upvote count: 2

http://stackoverflow.com/comment/8137528
type: Comment
type: QuestionComment
has text: @alphazero - thanks, but JMS is not the issue, the OP is about best pattern for *receiving* email.
comment on: http://stackoverflow.com/q/2643791
score: 0

http://stackoverflow.com/a/72040254
has body: For the sake of completeness as many may fall in this SO for other reasons than OP's question, here is another info that saved my day : TL;DR; Check that the port you want to open is not reserved (even though no application has opened it) On windows : netsh interface ipv4 show excludedportrange protocol=tcp Explanation : At least on windows, another possible cause for the java.net.BindException: Address already in use: JVM_Bind is that the operating system has "reserved" the port. If you use the commands from other answer in this topic, they will tell you that no application is listening to the port, yet you cannot open it. Some windows update like this one reserves range port that can then no longer be claimed by processes. Though not explicit on the port that can no longer be opened, the update note mentions a command that can help troubleshooting the issue : netsh interface ipv4 show excludedportrange protocol=tcp this will yield a list of port range that are blocked : Protocol tcp Port Exclusion Ranges Start Port End Port ---------- -------- 5357 5357 49709 49808 49809 49908 49909 50008 50009 50108 50109 50208 50280 50379 * - Administered port exclusions.
downvote count: 0
answers question: http://stackoverflow.com/q/2772701
type: Answer
upvote count: 3
score: 3

http://stackoverflow.com/q/2694045
has comment: http://stackoverflow.com/comment/2715905
possible better answer: http://stackoverflow.com/a/6860904
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2694306
has comment: http://stackoverflow.com/comment/2715789
tagged with: java
has answer: http://stackoverflow.com/a/2694216
has answer: http://stackoverflow.com/a/2694092
type: Question
score: 5
has body: There are a lot of questions that ask the best XML parser, I am more interested in what is the XML parser that is the most like Groovy for Java? I want: SomeApiDefinedObject o = parseXml( xml ); for( SomeApiDefinedObject it : o.getChildren() ) { System.out.println( it.getAttributes() ); } The most important things are that I don't want to create a class for every type of XML node, I'd rather just deal with them all as strings, and that building the XML doesn't require any converters or anything, just a simple object that is already defined If you have used the Groovy XML parser, you will know what I'm talking about Alternatively, would it be better for me to just use Groovy from Java?
has answer: http://stackoverflow.com/a/2694515
upvote count: 5
has answer: http://stackoverflow.com/a/54390771
has answer: http://stackoverflow.com/a/6860904
has comment: http://stackoverflow.com/comment/2716013
has answer: http://stackoverflow.com/a/2694185
tagged with: groovy
has title: A better way to do XML in Java
has answer: http://stackoverflow.com/a/2694241
downvote count: 0
tagged with: http://stackoverflow.com/tag/xml
favorite count: 0
accepted answer: http://stackoverflow.com/a/2694306
answer count: 9
has answer: http://stackoverflow.com/a/2694359
has comment: http://stackoverflow.com/comment/2720737

http://stackoverflow.com/comment/2815390
type: AnswerComment
type: Comment
score: 0
comment on: http://stackoverflow.com/a/2780487
has text: @rsp: add the 'abstract' keyword to the callHandler method in Message.

http://stackoverflow.com/q/2647912
accepted answer: http://stackoverflow.com/a/2649746
score: 2
type: AnsweredQuestion
tagged with: jdbc
downvote count: 0
favorite count: 0
type: Question
upvote count: 2
has body: I have an application running in Websphere Portal Server inside of Websphere Application Server 6.0 (WAS). In this application for one particular functionality that takes a long time to complete, I am firing a new thread that performs this action. This new thread opens a new Session from Hibernate and starts performing DB transactions with it. Sometimes (haven't been able to see a pattern), the transactions inside the thread work fine and the process completes successfully. Other times however I get the errors below: org.hibernate.exception.GenericJDBCException: could not load an entity: [OBJECT NAME#218294] ... Caused by: com.ibm.websphere.ce.cm.ObjectClosedException: DSRA9110E: Connection is closed. Method cleanup failed while trying to execute method cleanup on ManagedConnection WSRdbManagedConnectionImpl@642aa0d8 from resource jdbc/MyJDBCDataSource. Caught exception: com.ibm.ws.exception.WsException: DSRA0080E: An exception was received by the Data Store Adapter. See original exception message: Cannot call 'cleanup' on a ManagedConnection while it is still in a transaction.. How can I stop this from happening? Why does it seem that WAS wants to kill my connections even though they're not done. Is there a way I can stop WAS from attempting to close this particular connection? Thanks
tagged with: java
tagged with: hibernate
answer count: 1
has answer: http://stackoverflow.com/a/2649746
tagged with: websphere
has title: JDBC connection for a background thread being closed accessing in Websphere
linked to: http://stackoverflow.com/q/2648422

http://stackoverflow.com/comment/2806462
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2772807
type: Comment
has text: sorry for sure i mean "string" == "string" and "string".equals("string")

http://stackoverflow.com/q/2667346
tagged with: swing
type: AnsweredQuestion
score: 2
downvote count: 0
tagged with: java
has title: Java Swing TableModel fireTableRowsInserted on EDT
type: Question
has body: I have a TableModel that is populated from a background running thread. I am calling fireTableRowsInserted when data is inserted, which is NOT on the EDT. My question is, do I need to use invokeLater for the fireTableRowsInserted? In other words, is the below correct: public void putData(TableRow row) { // we are not on the EDT here... rows.add(row); fireTableRowsInserted(rows.size()-1, rows.size()-1); }
upvote count: 2
has answer: http://stackoverflow.com/a/2667408
accepted answer: http://stackoverflow.com/a/2667408
answer count: 1
favorite count: 0

http://stackoverflow.com/q/2614361
tagged with: java
tagged with: hibernate
tagged with: criteria-api
type: Question
possible better answer: http://stackoverflow.com/a/2614761
score: 4
upvote count: 4
answer count: 2
downvote count: 0
has body: I have got two entities Person and Book. Only one instance of a specific book is stored to the system (When a book is added, application checks if that book is already found before adding a new row to the database). Relevant source code of the entities is can be found below: @Entity @Table(name="persons") @SequenceGenerator(name="id_sequence", sequenceName="hibernate_sequence") public class Person extends BaseModel { @Id @Column(name = "id") @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "id_sequence") private Long id = null; @ManyToMany(targetEntity=Book.class) @JoinTable(name="persons_books", joinColumns = @JoinColumn( name="person_id"), inverseJoinColumns = @JoinColumn( name="book_id")) private List&lt;Book&gt; ownedBooks = new ArrayList&lt;Book&gt;(); } @Entity @Table(name="books") @SequenceGenerator(name="id_sequence", sequenceName="hibernate_sequence") public class Book extends BaseModel { @Id @Column(name = "id") @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "id_sequence") private Long id = null; @Column(name="name") private String name = null; } My problem is that I want to find persons, which are owning some of the books owned by a specific person. The returned list of persons should be ordered by using following logic: The person owning most of the same books should be at the first of the list, second person of the the list does not own as many books as the first person, but more than the third person. The code of the method performing this query is added below: @Override public List&lt;Person&gt; searchPersonsWithSimilarBooks(Long[] bookIds) { Criteria similarPersonCriteria = this.getSession().createCriteria(Person.class); similarPersonCriteria.add(Restrictions.in("ownedBooks.id", bookIds)); //How to set the ordering? similarPersonCriteria.addOrder(null); return similarPersonCriteria.list(); } My question is that can this be done by using Hibernate? And if so, how it can be done? I know I could implement a Comparator, bu…
favorite count: 0
has answer: http://stackoverflow.com/a/2614761
has title: Ordering the results of a Hibernate Criteria query by using information of the child entities of the asked entities
has answer: http://stackoverflow.com/a/2618417
accepted answer: http://stackoverflow.com/a/2618417
type: AnsweredQuestion

http://stackoverflow.com/comment/2821160
comment on: http://stackoverflow.com/a/2780170
type: Comment
has text: @Kevin: Point taken, but since this problem practically screams for a map, then I'd propose a different solution: ala `EnumMap`, we can have a specialized `IntMiniMap implements Map<Integer,V>` that has `get(int)` overload (to prevent autoboxing) and does a linear-search behind the screen (or perhaps a binary-search on a sorted array depending on threshold for N). A linear-search for mapping is ugly, but if it has to be done for performance reason, then at least hide it in a specialized `Map` instead of forcing people to bite their tongues and do it all over the place. Thoughts?
type: AnswerComment
score: 0

http://stackoverflow.com/a/2626383
upvote count: 3
type: Answer
downvote count: 0
score: 3
answers question: http://stackoverflow.com/q/2626186
has body: Take a look at Tiles.

http://stackoverflow.com/comment/134484637
type: Comment
comment on: http://stackoverflow.com/a/2661298
type: AnswerComment
score: 0
has text: Since nobody has mentioned yet: C and C++ actually allow `not` as a synonym of `!` as part of the [alternative operator representations](https://en.cppreference.com/w/cpp/language/operator_alternative), it's just the case that nobody ever uses it for whatever reason. (In C++ they're built into the language, [in C the header `iso646.h` must be included](https://en.wikipedia.org/wiki/C_alternative_tokens?useskin=vector).) So if one's issue is with `!` being less readable than `not` then for C and C++ (at least) there is another alternative to using `== true` or `== false`.

http://stackoverflow.com/a/51469613
downvote count: 2
has body: Kotlin In Kotlin you can use String.removeSurrounding(delimiter: CharSequence) E.g. string.removeSurrounding("\"") Removes the given delimiter string from both the start and the end of this string if and only if it starts with and ends with the delimiter. Otherwise returns this string unchanged. The source code looks like this: public fun String.removeSurrounding(delimiter: CharSequence): String = removeSurrounding(delimiter, delimiter) public fun String.removeSurrounding(prefix: CharSequence, suffix: CharSequence): String { if ((length &gt;= prefix.length + suffix.length) &amp;&amp; startsWith(prefix) &amp;&amp; endsWith(suffix)) { return substring(prefix.length, length - suffix.length) } return this }
score: 33
upvote count: 35
answers question: http://stackoverflow.com/q/2608665
type: Answer

http://stackoverflow.com/a/2735280
has body: Thanks for all your input. I decided to use surrogate keys and provide those right at object creation time. This way i stay clear of all that 'rarely' changing stuff and have something solid to base identity on. First tests look rather good. thank you all for your time. Unfortunately, i can only accept one answer as solution i will take Pascals, as he provided me with good reading ;) enjoy
answers question: http://stackoverflow.com/q/2719877
score: 0
type: Answer

http://stackoverflow.com/comment/2687445
has text: @Dan, thanks. My actual problem is that I cannot get the basic-authentication prompt dialog pop up in any of my browsers.
type: Comment
comment on: http://stackoverflow.com/a/2669121
score: 0
type: AnswerComment

http://stackoverflow.com/comment/98841143
comment on: http://stackoverflow.com/a/6378872
score: 0
type: AnswerComment
has text: I think this answer is outdated. `SSLSocketFactory` is marked as deprecated in the apache package.
type: Comment

http://stackoverflow.com/comment/77954167
comment on: http://stackoverflow.com/a/2699568
type: AnswerComment
score: 0
has text: Session resumption isn't limited to a single connection. If the client produces a valid sessionID in the `ClientHello` message, that session can be resumed.
type: Comment

http://stackoverflow.com/q/2622062
has answer: http://stackoverflow.com/a/13276459
favorite count: 0
has answer: http://stackoverflow.com/a/8699959
has answer: http://stackoverflow.com/a/2622080
has answer: http://stackoverflow.com/a/8446269
has answer: http://stackoverflow.com/a/24647165
type: UnansweredQuestion
has answer: http://stackoverflow.com/a/2622072
has comment: http://stackoverflow.com/comment/2634385
has answer: http://stackoverflow.com/a/37156772
answer count: 15
score: 59
has answer: http://stackoverflow.com/a/18397285
tagged with: java
upvote count: 59
tagged with: file
has answer: http://stackoverflow.com/a/56183347
has answer: http://stackoverflow.com/a/2622089
has answer: http://stackoverflow.com/a/51544113
has title: Run .jar from batch-file
type: Question
has answer: http://stackoverflow.com/a/7327138
has answer: http://stackoverflow.com/a/41888509
has answer: http://stackoverflow.com/a/14597381
has body: I have created an executable .jar file. How can I execute the .jar using a batch-file without mentioning a class path?
tagged with: batch-file
has answer: http://stackoverflow.com/a/2622084
downvote count: 0

http://stackoverflow.com/comment/2687828
type: Comment
has text: @Henk Holterman: Yes, but your new example is what regular expressions are there for, while simple, _static_ replacement is not.
score: 1
comment on: http://stackoverflow.com/a/2667077
type: AnswerComment

http://stackoverflow.com/q/2620603
has comment: http://stackoverflow.com/comment/2632874
type: Question
has answer: http://stackoverflow.com/a/2620617
answer count: 1
downvote count: 0
has title: New byte in php
tagged with: byte
has body: I have code JAVA byte abyte1[] = new byte[k]; But php not have byte type. Its possible to convert this line to php?
favorite count: 0
type: UnansweredQuestion
upvote count: 1
tagged with: php
score: 1
tagged with: java

http://stackoverflow.com/a/2682126
score: 0
type: Answer
answers question: http://stackoverflow.com/q/2682053
has body: For a task like that, I would probably roll my own. I would create a new String[] with the size of the a.length + b.length + c.length and then use an old-fashioned for loop, iterating Math.max(a.length, Math.max(b.length, c.length)) times. Inside the loop, I would add an element from each, testing the index against the length before doing so to avoid bounds exceptions. It has also been correctly pointed out elsewhere that you would need to keep track of the index of the last item added to the aggregate array.

http://stackoverflow.com/q/2765482
has answer: http://stackoverflow.com/a/2765531
has body: I am writing a piece of code in which i have to find only complete words for example if i have String str = "today is tuesday"; and I'm searching for "t" then I should not find any word. Can anybody tell how can I write such a program in java?
downvote count: 0
has answer: http://stackoverflow.com/a/2765518
has answer: http://stackoverflow.com/a/2765603
has answer: http://stackoverflow.com/a/2766135
has answer: http://stackoverflow.com/a/2766085
has answer: http://stackoverflow.com/a/2765504
possible better answer: http://stackoverflow.com/a/2765603
favorite count: 0
has answer: http://stackoverflow.com/a/2765524
has comment: http://stackoverflow.com/comment/2798079
answer count: 9
upvote count: 1
accepted answer: http://stackoverflow.com/a/2766135
type: AnsweredQuestion
score: 1
tagged with: java
has title: Find a complete word in a string java
has answer: http://stackoverflow.com/a/18441897
has answer: http://stackoverflow.com/a/2765528
type: Question

http://stackoverflow.com/comment/2657137
has text: This sounds like http://stackoverflow.com/questions/480775/programmatically-obtaining-big-o-efficiency-of-code
score: 1
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2642217

rowfilter
tags question: http://stackoverflow.com/q/2604238
type: Tag
tag name: rowfilter

http://stackoverflow.com/a/2652531
score: 2
downvote count: 0
has body: The only JDBC profiling tool that I know is P6Spy. Ancient but still works.
answers question: http://stackoverflow.com/q/2652447
upvote count: 2
type: Answer

http://stackoverflow.com/a/29439538
downvote count: 0
has comment: http://stackoverflow.com/comment/65219251
has body: What does the assert keyword in Java do? Let's look at the compiled bytecode. We will conclude that: public class Assert { public static void main(String[] args) { assert System.currentTimeMillis() == 0L; } } generates almost the exact same bytecode as: public class Assert { static final boolean $assertionsDisabled = !Assert.class.desiredAssertionStatus(); public static void main(String[] args) { if (!$assertionsDisabled) { if (System.currentTimeMillis() != 0L) { throw new AssertionError(); } } } } where Assert.class.desiredAssertionStatus() is true when -ea is passed on the command line, and false otherwise. We use System.currentTimeMillis() to ensure that it won't get optimized away (assert true; did). The synthetic field is generated so that Java only needs to call Assert.class.desiredAssertionStatus() once at load time, and it then caches the result there. See also: What is the meaning of "static synthetic"? We can verify that with: javac Assert.java javap -c -constants -private -verbose Assert.class With Oracle JDK 1.8.0_45, a synthetic static field was generated (see also: What is the meaning of "static synthetic"?): static final boolean $assertionsDisabled; descriptor: Z flags: ACC_STATIC, ACC_FINAL, ACC_SYNTHETIC together with a static initializer: 0: ldc #6 // class Assert 2: invokevirtual #7 // Method java/lang Class.desiredAssertionStatus:()Z 5: ifne 12 8: iconst_1 9: goto 13 12: iconst_0 13: putstatic #2 // Field $assertionsDisabled:Z 16: return and the main method is: 0: getstatic #2 // Field $assertionsDisabled:Z 3: ifne 22 6: invokestatic #3 // Method java/lang/System.currentTimeMillis:()J 9: lconst_0 10: lcmp 11: ifeq 22 14: new #4 // class java/lang/AssertionError 17: dup 18: invokespecial #5 // Method java/lang/AssertionError."<init>":()V 21: athrow 22: return We conclude that: there is no bytecode level support for assert: it is a Java language concept assert could be emulated pretty well with system properties -Pcom.me.assert=true to replace -ea …
has comment: http://stackoverflow.com/comment/55204663
type: Answer
answers question: http://stackoverflow.com/q/2758224
upvote count: 15
score: 15

http://stackoverflow.com/a/2640083
has body: I usually store files and other resources and then retrieve them as URLs: URL url = MyClass.class.getResource("/design/someResource.png"); Within a static context, or otherwise: URL url = getClass().getResource("/design/someResource.png"); From an instance. The above snippets assume that design is a top level folder within the jar. In general, if the path begins with a "/" it assumes an absolute path, otherwise it's relative from the class location.
answers question: http://stackoverflow.com/q/2639943
downvote count: 0
score: 1
type: Answer
upvote count: 1

nosuchmethoderror
type: Tag
tags question: http://stackoverflow.com/q/2772126
tags question: http://stackoverflow.com/q/2653958
tags question: http://stackoverflow.com/q/2647154
tag name: nosuchmethoderror

http://stackoverflow.com/comment/2719441
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2696497
has text: Alright, I've got it now. I guess the JRE System Library isn't included by default when one creates an Android project. Thanks for the help!

http://stackoverflow.com/q/2773108
has title: Java Mail timeout & connectiontimeout handling
tagged with: jakarta-mail
answer count: 2
tagged with: email
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/3787146
has answer: http://stackoverflow.com/a/2801057
tagged with: exception
score: 6
accepted answer: http://stackoverflow.com/a/3787146
upvote count: 6
possible better answer: http://stackoverflow.com/a/2801057
type: AnsweredQuestion
tagged with: java
type: Question
has body: I'm using JavaMail to send email requests to an SMTP server. I would like to set both "mail.smtp.connectiontimeout" and "mail.smtp.timeout" properties within my code. Programmatically, I want to catch both when timeout and/or connectiontimeout operations are reached in Java and handle things accordingly. Handling in the sense, I need to retry the same email once again the next time. How do I handle this in Java/JavaMail? Is it possible to catch &amp; handle this timeout operations? EDIT Also, is it possible to simulate/reproduce this timeout operation on my own assuming I've complete administration access to the SMTP server?

http://stackoverflow.com/a/2605769
has comment: http://stackoverflow.com/comment/137036185
type: Answer
has comment: http://stackoverflow.com/comment/137036177
upvote count: 42
score: 41
has comment: http://stackoverflow.com/comment/97876910
answers question: http://stackoverflow.com/q/2605747
accepted answer of: http://stackoverflow.com/q/2605747
has comment: http://stackoverflow.com/comment/2617633
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/30346303
downvote count: 1
has comment: http://stackoverflow.com/comment/30346002
has body: According to this ticket MRESOURCES-36, there should be a element, but only for Maven Resources Plugin 2.3. org.apache.maven.plugins maven-resources-plugin 2.3 true For Maven versions which included an older version of the Resources plugin: Until this issue is fixed, here is a workaround I've been using successfully. Add this plugin element into project/build/plugins in your pom.xml, and change the dir in the mkdir task. You can have multiple <mkdir> elements for multiple directories. The mkdir task does nothing if the directory has already been copied by the resources plugin. org.apache.maven.plugins maven-antrun-plugin create-empty-directory process-classes run <mkdir dir="${basedir}/target/classes/empty" /> This originally came from the openejb-standalone pom.xml in the openejb project.
has comment: http://stackoverflow.com/comment/2618556
has comment: http://stackoverflow.com/comment/30345967

http://stackoverflow.com/a/2626456
answers question: http://stackoverflow.com/q/2625229
has body: If keeping a sorted array or using a different data structure is not an option, you could try something like the following. The O time is similar to sorting the large array but in practice this should be more efficient. small_array = big_array.slice( number_of_items_to_find ); small_array.sort(); least_found_value = small_array.get(0).value; for ( item in big_array ) { // needs to skip first few items if ( item.value &gt; least_found_value ) { small_array.remove(0); small_array.insert_sorted(item); least_found_value = small_array.get(0).value; } } small_array could be an Object[] and the inner loop could be done with swapping instead of actually removing and inserting into an array.
score: 0
type: Answer

http://stackoverflow.com/comment/2800254
has text: Unfortunately, JNDI lookups are slow (as I understand it). Is that really a viable, scalable option?
type: Comment
comment on: http://stackoverflow.com/a/2767562
score: 0
type: AnswerComment

http://stackoverflow.com/a/2694278
has comment: http://stackoverflow.com/comment/2716069
has comment: http://stackoverflow.com/comment/2724483
has comment: http://stackoverflow.com/comment/2716061
type: Answer
upvote count: 2
has comment: http://stackoverflow.com/comment/49930267
score: 1
has body: People would probably rather spend time improving Eclipse or Netbeans.
downvote count: 1
answers question: http://stackoverflow.com/q/2694238

http://stackoverflow.com/a/2781886
downvote count: 0
has body: A checked exception does not stop being a checked exception. The way you can sort of turn a checked exception into unchecked is by wrapping it inside a type of RuntimeException and re-throwing it.
type: Answer
answers question: http://stackoverflow.com/q/2781845
score: 3
upvote count: 3

http://stackoverflow.com/comment/2793673
type: QuestionComment
comment on: http://stackoverflow.com/q/2754452
score: 0
type: Comment
has text: @Mark The initialization of the `SessionFactory` looks OK (the `hibernate.properties` is optional and your `hibernate.cfg.xml` seems to contains everything required). The next step would be to get the `Session` from the `SessionFactory` and to perform a little query (e.g. `from Courses`).

http://stackoverflow.com/q/2643893
has answer: http://stackoverflow.com/a/2644471
has body: I've got a jar that loads great with java web start when I browse through the IP address of the server. Once I try the server name instead I get the following exception: com.sun.deploy.net.FailedDownloadException: Unable to load resource: at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source) at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source) at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source) at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source) at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source) at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source) at com.sun.javaws.LaunchDownload$DownloadTask.call(Unknown Source) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) The wrapped exception: java.io.FileNotFoundException: at sun.reflect.GeneratedConstructorAccessor2.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at com.sun.deploy.net.BasicHttpRequest.doRequest(Unknown Source) at com.sun.deploy.net.BasicHttpRequest.doRequest(Unknown Source) at com.sun.deploy.net.BasicHttpRequest.doGetRequest(Unknown Source) at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source) at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source) at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source) at com.sun.deplo…
type: Question
has answer: http://stackoverflow.com/a/63375440
score: 10
tagged with: java-web-start
has answer: http://stackoverflow.com/a/2644456
has comment: http://stackoverflow.com/comment/2659370
has answer: http://stackoverflow.com/a/47454284
has answer: http://stackoverflow.com/a/36169293
has answer: http://stackoverflow.com/a/77610345
has answer: http://stackoverflow.com/a/13190931
favorite count: 0
has answer: http://stackoverflow.com/a/55716384
accepted answer: http://stackoverflow.com/a/2644466
has title: Java web start - Unable to load resource
has answer: http://stackoverflow.com/a/63805815
upvote count: 10
answer count: 10
possible better answer: http://stackoverflow.com/a/2644456
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/2644466
downvote count: 0
tagged with: java

http://stackoverflow.com/comment/2653295
type: QuestionComment
type: Comment
comment on: http://stackoverflow.com/q/2638986
has text: I don't understand this question at all. Java has the concept of "interface" too, as well as abstract classes. Visit http://java.sun.com maybe ...
score: 0

http://stackoverflow.com/comment/2816677
has text: @justkt, I didn't see that because `ArrayList<String>` was rendering as `ArrayList` until I fixed it.
comment on: http://stackoverflow.com/a/2781671
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2771183
type: Comment
type: QuestionComment
has text: possible duplicate of http://stackoverflow.com/questions/625687/java-getclassloader-getresource-driving-me-bonkers
comment on: http://stackoverflow.com/q/2742076
score: 0

http://stackoverflow.com/a/63957597
upvote count: 0
has body: You can assign double as int without losing precision.
type: Answer
downvote count: 3
answers question: http://stackoverflow.com/q/2781086
score: -3

http://stackoverflow.com/comment/2819898
type: QuestionComment
has text: **Related question:** http://stackoverflow.com/questions/2781987/how-can-i-customize-the-title-bar-on-jframe
score: 0
comment on: http://stackoverflow.com/q/2780780
type: Comment

http://stackoverflow.com/q/2634669
possible better answer: http://stackoverflow.com/a/39122519
tagged with: architecture
tagged with: spring
tagged with: spring-mvc
type: AnsweredQuestion
downvote count: 0
tagged with: java
accepted answer: http://stackoverflow.com/a/2638244
type: Question
has answer: http://stackoverflow.com/a/39122519
linked to: http://stackoverflow.com/q/821276
score: 10
has answer: http://stackoverflow.com/a/2638244
answer count: 2
has title: Spring MVC: should service layer be returning operation specific DTO's?
upvote count: 10
favorite count: 0
has body: In my Spring MVC application I am using DTO in the presentation layer in order to encapsulate the domain model in the service layer. The DTO's are being used as the spring form backing objects. hence my services look something like this: userService.storeUser(NewUserRequestDTO req); The service layer will translate DTO -> Domain object and do the rest of the work. Now my problem is that when I want to retrieve a DTO from the service to perform say an Update or Display I can't seem to find a better way to do it then to have multiple methods for the lookup that return different DTO's like... EditUserRequestDTO userService.loadUserForEdit(int id); DisplayUserDTO userService.loadUserForDisplay(int id); but something does not feel right about this approach. Perhaps the service should not return things like EditUserRequestDTO and the controller should be responsible of assembling a requestDTO from a dedicated form object and vice versa. The reason do have separate DTO's is that DisplayUserDTO is strongly typed to be read only and also there are many properties of user that are entities from a lookup table in the db (like city and state) so the DisplayUserDTO would have the string description of the properties while the EditUserRequestDTO will have the id's that will back the select drop down lists in the forms. What do you think? thanks
tagged with: n-tier-architecture

http://stackoverflow.com/comment/2666779
score: 0
has text: You can also see what ant is actually doing by looking the buildfile (most likely called build.xml). Even if you're not familiar with the syntax, you can kind of see what's going on. <javac> means it's compiling some Java code. <java> means it's actually running the compiled code. Probably it's creating a directory to put the .class files in, compiling the code, maybe creating some Javadoc, etc.
type: AnswerComment
comment on: http://stackoverflow.com/a/2650197
type: Comment

http://stackoverflow.com/comment/34411673
type: AnswerComment
has text: Is there any Java equivalent for above config?
type: Comment
comment on: http://stackoverflow.com/a/2602676
score: 1

checkbox
tag name: checkbox
tags question: http://stackoverflow.com/q/2718110
type: Tag

http://stackoverflow.com/a/2704037
answers question: http://stackoverflow.com/q/2703584
has comment: http://stackoverflow.com/comment/2732115
score: 0
has body: Differents solutions : 1) with tabs class TheClass { TheClass(String[] strings) {} TheClass(Object[] others) {} } 2) with generics class TheClass&lt;P&gt; { TheClass(P generic) {} }
type: Answer

http://stackoverflow.com/comment/86702990
has text: now it says "javax.net.ssl.SSLHandshakeException: Handshake failed" :(
score: 0
comment on: http://stackoverflow.com/a/4837230
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2785364
score: 0
type: Comment
type: QuestionComment
comment on: http://stackoverflow.com/q/2754306
has text: Not sure if it's a bug, but I see the same thing.

http://stackoverflow.com/q/2686870
tagged with: java
type: UnansweredQuestion
tagged with: htmlunit
tagged with: javascript
type: Question
tagged with: facebook
score: 0
has title: HTMLUNIT Facebook javascript warning
answer count: 1
has body: I am trying to create simple application that would be able to search people on facebook using given e-mail. I am already able to log into an account using the HTMLunit tool and even create a page, which should throw result of my search. But when I try to print the result as XML the file is missing some blocks of javascript results (I can tell that they are missing by comparing file created by my application and source code, that can be viewed by using IE) Is there any way around this? I just need to get the same result IE's showsource function does. Thanks a lot. During execution of file, I am getting these WARNINGS: 1.4.2010 23:25:14 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify WARNING: Expected content type of 'application/javascript' or 'application/ecmascript' for remotely loaded JavaScript element at 'https://s-static.ak.facebook.com/rsrc.php/z49PH/hash/9p47jvzp.js', but got 'application/x-javascript'. 21.4.2010 23:25:14 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify WARNING: Expected content type of 'application/javascript' or 'application/ecmascript' for remotely loaded JavaScript element at 'https://s-static.ak.facebook.com/rsrc.php/z5N5C/hash/dhdy6xq3.js', but got 'application/x-javascript'. 21.4.2010 23:25:14 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify WARNING: Expected content type of 'application/javascript' or 'application/ecmascript' for remotely loaded JavaScript element at 'https://s-static.ak.facebook.com/rsrc.php/z4TLI/hash/9ucb5trt.js', but got 'application/x-javascript'. 21.4.2010 23:25:23 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify WARNING: Expected content type of 'application/javascript' or 'application/ecmascript' for remotely loaded JavaScript element at 'http://static.ak.fbcdn.net/rsrc.php/z49PH/hash/9p47jvzp.js', but got 'application/x-javascript'. And then a lot of CSS errors 21.4.2010 23:25:23 com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error WARNING: CSS e…
has answer: http://stackoverflow.com/a/2787914
has comment: http://stackoverflow.com/comment/2827234

http://stackoverflow.com/comment/74028864
score: 2
type: AnswerComment
has text: `for inheriting from your singleton and overriding your singleton's methods with something else`. you can just use a `final class` to prevent that
comment on: http://stackoverflow.com/a/2709672
type: Comment

http://stackoverflow.com/q/2726295
has answer: http://stackoverflow.com/a/7082936
has title: Android: Changing LinearLayout in a widget
score: 0
accepted answer: http://stackoverflow.com/a/2729122
has body: I have this really annoying problem: In my widget, i would like to change the background by code. I noticed on the Google doc than I can easily change the background of an Imageview: remoteViews.setImageViewResource(R.id.my_iv, R.drawable.my_bg); Ok, too easy, i want to change now the Linear layout.. What I read about the remoteview id that I can change a Bitmap, Int, Bool, String, etc... but not a drawable. So i guess i cannot use: remoteViews.setBitmap(R.id.my_ll,"setBackgroundDrawable",BitmapFactory.decodeResource(context.getResources(), R.drawablemy_bg)); I am totally disapointed and tried a last idea: views.setInt(R.id.my_ll,"setBackgroundResource",R.drawable.my_bg); But The logcat told me: android.widget.RemoteViews$ActionException:view: android.widget.LinearLayout can't use method with RemoteViews: setBackgroundResource(int) I am totally lost and I really don't know what to do... I would really appreciate any help. Thank a lot!
possible better answer: http://stackoverflow.com/a/7082936
tagged with: android
has answer: http://stackoverflow.com/a/2729122
type: AnsweredQuestion
tagged with: java
type: Question
answer count: 2

http://stackoverflow.com/comment/2705652
type: Comment
score: 1
type: AnswerComment
has text: OK, you're welcome and good luck with the code. If you have more questions, you know to find us.
comment on: http://stackoverflow.com/a/2685418

http://stackoverflow.com/comment/2807700
comment on: http://stackoverflow.com/a/2772783
score: 0
type: Comment
has text: Sorry - I did mean primitives and good point about not being able to create value types in Java.
type: AnswerComment

http://stackoverflow.com/comment/102536460
type: AnswerComment
has text: compared to c, c++ offers higher level abstraction, more type safeness and more programming paradigms (oop, generic, concepts) at ZERO OVERHEAD. it is totally inaccurate to say "c++ is as fast as c, unless you use oop". c++ is as fast as c (this is what ZERO stands for) regardless on what you do with it. this is NOT the case with Go (because of garbage collector). this is also true with RUST. just to let you know.
score: 0
comment on: http://stackoverflow.com/a/52325174
type: Comment

http://stackoverflow.com/comment/2775750
score: 1
comment on: http://stackoverflow.com/q/2746386
type: QuestionComment
has text: Why do you need a batch file to include classpath? Have you seen the new Java 6 trick `-cp "lib/*"` That would include all jars in the lib directory
type: Comment

http://stackoverflow.com/a/2662790
score: 0
type: AcceptedAnswer
has body: Since TrayIcon supports both addMouseListener() and addMouseMotionListener() you should implement your listeners to care about the state of the selection/focus of the TrayBar.. you could try to see which events are fired when you focus it or unfocus. It depends on what you want to catch: if you want to see whenever the user hovers onto the icon you should try with mouseEntered or mouseExited, and so on. TrayIcon doesn't inherit from any standard GUI component so I think this is the only way to work with it. In addition I won't rely too much of making it work cross-platform since probably these kinds of events are fired from the OS and sent to JVM that forwards them to the TrayIcon object but I don't know how well this is implemented, just try it out by yourself.
type: Answer
accepted answer of: http://stackoverflow.com/q/2662750
answers question: http://stackoverflow.com/q/2662750

http://stackoverflow.com/comment/2796535
type: QuestionComment
type: Comment
has text: @Arthur let say we have a web application with data inside database. For demo purpose, we do not want our client tempt with the data, therefore, if can set readonly mode in xml file, that would be good.
comment on: http://stackoverflow.com/q/2681364
score: 0

http://stackoverflow.com/q/2729746
has answer: http://stackoverflow.com/a/2734555
accepted answer: http://stackoverflow.com/a/2734555
score: 2
upvote count: 2
type: Question
tagged with: jakarta-ee
has title: Wired component null in seam EntityHome action
type: AnsweredQuestion
tagged with: seam
tagged with: java
answer count: 1
downvote count: 0
has body: I have a custom EntityHome class. I wire the dependent entity in the wire method, but when I call the action (persist) the wired component is always null. What could be the reason, similar code generated by seam gen is apparently working. Here is the entity class. The round.teeSet component is always null when persist is called, although it is shown in the jsf page. Note: Seam version: 2.2.0.GA Jboss: jboss-5.1.0.GA I have overrden persist method to log the value of the wired element. @Name("roundHome") @Scope(ScopeType.CONVERSATION) public class RoundHome extends EntityHome&lt;Round&gt;{ @In(required = false) private Golfer currentGolfer; @In(create = true) private TeeSetHome teeSetHome; @Override public String persist() { logger.info("Persist called"); if (null != getInstance().getTeeSet() ) { logger.info("teeSet not null in persist"); } else { logger.info("teeSet null in persist"); // wire(); } String retVal = super.persist(); //To change body of overridden methods use File | Settings | File Templates. return retVal; } @Logger private Log logger; public void wire() { logger.info("wire called"); TeeSet teeSet = teeSetHome.getDefinedInstance(); if (null != teeSet) { getInstance().setTeeSet(teeSet); logger.info("Successfully wired the teeSet instance with color: " + teeSet.getColor()); } } public boolean isWired() { logger.info("is wired called"); if(null == getInstance().getTeeSet()) { logger.info("wired teeSet instance is null, the button will be disabled !"); return false; } else { logger.info("wired teeSet instance is NOT null, the button will be enabled !"); logger.info("teeSet color: "+getInstance().getTeeSet().getColor()); return true; } } @RequestParameter public void setRoundId(Long id) { super.setId(id); } @Override protected Round createInstance() { Round round = super.createInstance(); round.setGolfer(currentGolfer); round.setDate(new java.sql.Date(System.currentTimeMillis())); return round; } } Here the xhtml &lt;?xml version="1.0" encoding="UTF-8"?&gt;…
favorite count: 0

http://stackoverflow.com/comment/76668499
comment on: http://stackoverflow.com/a/2608435
has text: how can i call the least specific method ?? if i have foo(Object o); and foo(String s);. and i want to call foo(Object o). what do i do ?
score: 0
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/2778825
score: 0
type: AnswerComment
has text: @Marc: I agree that the simple static variable is the best trade-off of behavior and complexity. The use of a closure to create a variable with limited scope but unlimited lifetime is somewhat more common in certain functional languages which don't directly provide private fields -- a closure in the class factory does the trick.
type: Comment
comment on: http://stackoverflow.com/a/2748024

http://stackoverflow.com/a/2762201
type: Answer
answers question: http://stackoverflow.com/q/2762171
upvote count: 1
downvote count: 1
has body: Promote your variables to instance variables, that way they'll be visible to both methods (you are allowed to have state in an object after all). If they don't look like they should belong on your object then I don't think you'll be able to get around a redesign.
score: 0
has comment: http://stackoverflow.com/comment/2794438
has comment: http://stackoverflow.com/comment/2794378

http://stackoverflow.com/a/49526850
has comment: http://stackoverflow.com/comment/113760066
answers question: http://stackoverflow.com/q/2671858
downvote count: 0
has comment: http://stackoverflow.com/comment/113754866
has body: I know this is an old question but we were also facing the same need and was unable to find the solution that fulfills our need. Our requirement was to get a unique sequence (0,1,2,3...n) of ids and hence snowflake did not help. We created our own system to generate the ids using Redis. Redis is single threaded hence its list/queue mechanism would always give us 1 pop at a time. What we do is, We create a buffer of ids, Initially, the queue will have 0 to 20 ids that are ready to be dispatched when requested. Multiple clients can request an id and redis will pop 1 id at a time, After every pop from left, we insert BUFFER + currentId to the right, Which keeps the buffer list going. Implementation here
upvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/113758000
score: 2
has comment: http://stackoverflow.com/comment/113730244

http://stackoverflow.com/comment/2675671
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2658446
has text: ok, imagine i just want to store in a column of a table a matrix (16x16), how could I do it? what data type should I use when I create this column in MySQL?

http://stackoverflow.com/comment/100434990
type: Comment
comment on: http://stackoverflow.com/a/45286358
has text: Can't we access static fields through regular methods? Then this `A common use for static methods is to access static fields.` is not an argument.
type: AnswerComment
score: 0

http://stackoverflow.com/a/2738968
upvote count: 2
downvote count: 2
type: Answer
has comment: http://stackoverflow.com/comment/2767536
has body: It's good, as @leonbloy says, to understand it well. Even then, however, one "best" practice is to simply let your IDE write the function for you. It won't be optimal under some circumstances - and in some very rare circumstances it won't even be good - but for most situations, it's easy, repeatable, error-free, and as good (as a hash code) as it needs to be. Sure, read the docs and understand it well - but don't complicate it unnecessarily.
score: 0
answers question: http://stackoverflow.com/q/2738886

http://stackoverflow.com/comment/5966751
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2765791
type: Comment
has text: You might have to look into the Java Source Code for implementation details like Yaneeve did. You can attach java core lib source code to IDE.

http://stackoverflow.com/comment/2716567
has text: @BalusC: My guess is that there are in fact many other errors before the Rand error and he just picked that one to post because it looked interesting.
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2694490

http://stackoverflow.com/comment/2695302
score: 0
comment on: http://stackoverflow.com/q/2675929
type: QuestionComment
has text: What you're asking for doesn't exist because it doesn't make sense. You're asking for something "like an ArrayList" except it's nothing like an array list. Can you please clarify which is more important to you, the front end (ie interface), or the back end (the interpolator functionality). The back end is orders of magnitude harder to implement, wrapping an interpolator in a List-like interface is trivial.
type: Comment

jls
tags question: http://stackoverflow.com/q/2661210
type: Tag
tag name: jls

http://stackoverflow.com/comment/2655087
has text: Where is the problem ? Can't you read online documentation ? For example : http://static.springsource.org/spring/docs/2.5.x/reference/transaction.html (first google answer on 'spring hibernate transaction' search) !
score: 1
type: Comment
comment on: http://stackoverflow.com/q/2639729
type: QuestionComment

http://stackoverflow.com/q/2714326
type: Question
answer count: 2
tagged with: derby
score: 15
tagged with: javadb
possible better answer: http://stackoverflow.com/a/20567659
tagged with: sqlite
tagged with: sqlitejdbc
favorite count: 0
accepted answer: http://stackoverflow.com/a/2714388
upvote count: 16
has title: Derby/JavaDB vs SQLiteJDBC
has answer: http://stackoverflow.com/a/2714388
type: AnsweredQuestion
has body: I found a lot of comparisions here, but not this one; So, what is best in each one?
has answer: http://stackoverflow.com/a/20567659
tagged with: java
has comment: http://stackoverflow.com/comment/2751165
downvote count: 1

http://stackoverflow.com/comment/2788094
comment on: http://stackoverflow.com/a/2756668
score: 0
type: AnswerComment
type: Comment
has text: Nice, I just learned something new. I was wondering how to get the interrupt status.

http://stackoverflow.com/a/2732714
answers question: http://stackoverflow.com/q/2732640
type: Answer
has body: Does google use port 25 for the smtp? According to this document by Google you need to use port 587 for TLS/STARTTLS or 465 for SSL.
score: 0

http://stackoverflow.com/comment/2705226
score: 0
type: AnswerComment
has text: Neil, your argument is quite confused: "But then, once that result is in a register or on the stack, it's only accessed by the switching thread and is safe". Sure, using that value is thread-safe! But my point is that *that value can _already_ be wrong due to synchronization bugs in user code*. Using thread-safely a wrong value is less than useful :) This issue can never be eliminated: buggy concurrent code could already have produced the "out of thin air"/wrong long value, which can be subsequently used in the switch, making the switch go to a case address _nobody ever specified_.
type: Comment
comment on: http://stackoverflow.com/a/2676700

http://stackoverflow.com/q/2784009
has body: I was reading the JavaDoc for Threadlocal here https://docs.oracle.com/javase/1.5.0/docs/api/java/lang/ThreadLocal.html and it says "ThreadLocal instances are typically private static fields in classes that wish to associate state with a thread (e.g., a user ID or Transaction ID). " But my question is why did they choose to make it static (typically) - it makes things a bit confusing to have "per thread" state but the fields are static?
type: AnsweredQuestion
has answer: http://stackoverflow.com/a/14286991
downvote count: 0
has title: Why should Java ThreadLocal variables be static
favorite count: 0
type: Question
linked to: http://stackoverflow.com/q/35764959
has answer: http://stackoverflow.com/a/2784059
score: 116
tagged with: multithreading
possible better answer: http://stackoverflow.com/a/9172317
has answer: http://stackoverflow.com/a/9172317
answer count: 7
has answer: http://stackoverflow.com/a/52052557
has answer: http://stackoverflow.com/a/2785322
tagged with: java
has answer: http://stackoverflow.com/a/2784060
accepted answer: http://stackoverflow.com/a/2784059
upvote count: 116
has answer: http://stackoverflow.com/a/53940714

http://stackoverflow.com/q/2622748
has comment: http://stackoverflow.com/comment/2635216
has body: I have a question about type casting. I have the following JSON String: {"server":"clients","method":"whoIs","arguments":["hello"]} I am parsing it to the following Map&lt;String, Object>. {arguments=[hello], method=whoIs, server=clients} It is now possible to do the following: request.get("arguments"); This works fine. But I need to get the array that is stored in the arguments. How can I accomplish this? I tried (for example) the following: System.out.println(request.get("arguments")[0]); But of course this didn't work.. How would this be possible?
has answer: http://stackoverflow.com/a/6376187
accepted answer: http://stackoverflow.com/a/2624465
has comment: http://stackoverflow.com/comment/7467922
upvote count: 1
has answer: http://stackoverflow.com/a/2622831
type: AnsweredQuestion
has comment: http://stackoverflow.com/comment/2635196
tagged with: java
tagged with: http://stackoverflow.com/tag/json
possible better answer: http://stackoverflow.com/a/2622831
type: Question
has comment: http://stackoverflow.com/comment/2637111
tagged with: casting
has answer: http://stackoverflow.com/a/2624465
downvote count: 0
score: 1
favorite count: 0
has title: Java JSON/object to array
answer count: 3

http://stackoverflow.com/a/2711506
score: 4
upvote count: 4
downvote count: 0
type: Answer
answers question: http://stackoverflow.com/q/2711493
has body: Every Map needs to be parametrized on two types; your second (nested) Map has only one.

http://stackoverflow.com/q/2618230
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/162551
has title: How to find out all the dependency class names of one class?
has body: I have a big list of classes, a lot of them are not used any more. I know the entries class, I'd like to know all its child classes. I know read class binary would help, wondering whether there is any better way. We are not using class.forName. thanks.
score: 2
has answer: http://stackoverflow.com/a/2619820
tagged with: java
linked to: http://stackoverflow.com/q/786708
type: Question
answer count: 2
has comment: http://stackoverflow.com/comment/2630160
downvote count: 0
favorite count: 0
has answer: http://stackoverflow.com/a/2618256
tagged with: classloader
upvote count: 2

http://stackoverflow.com/comment/2615991
type: AnswerComment
score: 0
type: Comment
has text: Good point. However, I'm using a 64 bits JVM. I'll update the question.
comment on: http://stackoverflow.com/a/2605951

http://stackoverflow.com/q/2635155
has title: decode encode between String and byte in java
type: AnsweredQuestion
has body: byte[] bytes = new byte[] { 1, -1 }; System.out.println(Arrays.toString(new String(bytes, "UTF-8").getBytes("UTF-8"))); System.out.println(Arrays.toString(new String(bytes, "ISO-8859-1").getBytes("ISO-8859-1"))); output: [1, -17, -65, -67] [1, -1] why???
has answer: http://stackoverflow.com/a/2636861
possible better answer: http://stackoverflow.com/a/2635206
tagged with: java
has answer: http://stackoverflow.com/a/2635206
type: Question
accepted answer: http://stackoverflow.com/a/2635179
score: 0
answer count: 3
has answer: http://stackoverflow.com/a/2635179
has comment: http://stackoverflow.com/comment/2649151
linked to: http://stackoverflow.com/q/2544965

http://stackoverflow.com/comment/6948687
comment on: http://stackoverflow.com/a/2752363
score: 2
has text: @Daniel then your production system is insecure. You need to read the remarks about this in RFC2246. This is a very serious matter.
type: AnswerComment
type: Comment

http://stackoverflow.com/comment/60223596
has text: It isn't a keyword, it is a [literal](http://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-3.10.7). Poor quality and non-normative citation.
type: AnswerComment
type: Comment
comment on: http://stackoverflow.com/a/2707325
score: 3

http://stackoverflow.com/q/2724871
possible better answer: http://stackoverflow.com/a/5987145
has answer: http://stackoverflow.com/a/2726008
tagged with: java
linked to: http://stackoverflow.com/q/19187834
has title: How to bring up list of available notification sounds on Android
type: Question
downvote count: 0
score: 72
has answer: http://stackoverflow.com/a/56287912
upvote count: 72
tagged with: notifications
accepted answer: http://stackoverflow.com/a/2726008
tagged with: android
has body: I'm creating notifications in my Android application, and would like to have an option in my preferences to set what sound is used for the notification. I know that in the Settings application you can choose a default notification sound from a list. Where does that list come from, and is there a way for me to display the same list in my application?
has answer: http://stackoverflow.com/a/57373029
favorite count: 0
answer count: 5
has answer: http://stackoverflow.com/a/5987145
has answer: http://stackoverflow.com/a/29696216
type: AnsweredQuestion
tagged with: audio

http://stackoverflow.com/a/2756718
downvote count: 0
answers question: http://stackoverflow.com/q/2756626
has body: The Java documentation is a tad misleading. If the interrupted status of a thread is set, calling sleep() on that thread will cause an InterruptException to be thrown immediately. This applies even if the thread was interrupted before sleep() was called. As stated above, though, you can also check with Thread.isInterrupted() if you want to handle interrupts yourself.
upvote count: 2
type: Answer
score: 2

http://stackoverflow.com/comment/2678123
score: 0
type: AnswerComment
comment on: http://stackoverflow.com/a/2660850
type: Comment
has text: Thanks. 8) I thought the explanation had nothing to do with the code snippet. Silly me.

http://stackoverflow.com/a/2600759
has comment: http://stackoverflow.com/comment/2609926
score: 4
answers question: http://stackoverflow.com/q/2600608
has comment: http://stackoverflow.com/comment/2610052
type: Answer
has body: Following pseudocode should do the trick: build a map&lt;word, count&gt; build a tokenizer that gives you a word per iteration for each word*, if word in map, increment its count otherwise add with count = 1 sort words by count for each of the first 50 words, output word, frequency = count / total_words This is essentially O(N), and what jpabluz suggested. However, if you are going to use this on any sort of "in the wild" text, you will notice lots of garbage: uppercase/lowercase, punctuation, URLs, stop-words such as 'the' or 'and' with very high counts, multiple variations of the same word... The right way to do it is to lowercase all words, remove all punctuation (and things such as URLs), and add stop-word removal and stemming at the point marked with the asterisk in the above pseudocode.
upvote count: 4
has comment: http://stackoverflow.com/comment/2610368
downvote count: 0

http://stackoverflow.com/a/32540549
answers question: http://stackoverflow.com/q/2615712
score: -1
downvote count: 1
has body: static int secondLargest(int[] input){ int largest , secondlargest; if(input[0]&gt;input[1]) { largest=input[0]; secondlargest = input[1]; } else { secondlargest = input[0]; largest =input[1]; } for(int i =2 ;i&lt;input.length;i++){ if(input[i]&gt;largest) { secondlargest = largest; largest = input[i]; } else if(input[i]&gt;secondlargest){ secondlargest = input[i]; } } return secondlargest; }
type: Answer
upvote count: 0

http://stackoverflow.com/q/2744730
has comment: http://stackoverflow.com/comment/2774276
answer count: 2
score: 2
accepted answer: http://stackoverflow.com/a/2744774
favorite count: 0
upvote count: 2
has title: How to convert comma delimited String to List of T in Core Java
has comment: http://stackoverflow.com/comment/2773955
type: AnsweredQuestion
tagged with: java
possible better answer: http://stackoverflow.com/a/2744781
has answer: http://stackoverflow.com/a/2744774
type: Question
has answer: http://stackoverflow.com/a/2744781
has body: "first time long time" as they say on the radio talk shows... I'm trying to parse a delimited property into a List. Simple enough, but for some reason I can't figure how to do this in a generic fashion using only Core Java. By generic, I mean the type of List to create may be a List&lt; String >, List&lt; Integer >, or List&lt; Double >. My latest stab at it below gives runtime exceptions with non-Strings because I'm trying to cast from String to e.g. Double which is not allowed. Any help is appreciated. public static &lt;T&gt; void parsePropsToList(String propName, String delim, List&lt;T&gt; listToFill){ //This is paired down for convenience - assume getSplitList correctly parses to List&lt;String&gt; List&lt;String&gt; stringList = PropsManager.getSplitList(propName, delim); for(String s : stringList){ listToFill.add((T)s); } }
downvote count: 0

http://stackoverflow.com/a/2629512
downvote count: 0
answers question: http://stackoverflow.com/q/2629501
has comment: http://stackoverflow.com/comment/68853785
has comment: http://stackoverflow.com/comment/2642880
score: 21
upvote count: 21
type: Answer
has body: http://java.sun.com/docs/white/langenv/Simple.doc2.html There are no means provided by which programmers can overload the standard arithmetic operators. Once again, the effects of operator overloading can be just as easily achieved by declaring a class, appropriate instance variables, and appropriate methods to manipulate those variables. Eliminating operator overloading leads to great simplification of code. The last statement is of course very subjective.

http://stackoverflow.com/a/2799732
score: 0
answers question: http://stackoverflow.com/q/2777509
type: Answer
has body: Even faster than all of that is using the Miller-Rabin test. It's a probabilistic test, and therefore has a certain level of error; however, the test runs multiple times which shrinks that error as small as needed (50 often suffices for commercial applications). Not in Java, but here's a quick implementation in Python I cooked up.

http://stackoverflow.com/comment/102654482
score: 2
type: AnswerComment
has text: @EvanKairuz No, it is not. It should be `{"k1":"apple","k2":"orange"}`
comment on: http://stackoverflow.com/a/15943171
type: Comment

http://stackoverflow.com/comment/2660266
has text: MB/s is meaningless. take() gets a reference. Whether the payload of that (apart from the word of the reference itself) is few bytes, or many megabytes, is irrelevant to the queue.
score: 1
comment on: http://stackoverflow.com/q/2644688
type: Comment
type: QuestionComment

http://stackoverflow.com/q/2642651
has answer: http://stackoverflow.com/a/2642658
has answer: http://stackoverflow.com/a/2644233
has comment: http://stackoverflow.com/comment/2657854
downvote count: 0
has answer: http://stackoverflow.com/a/2643225
accepted answer: http://stackoverflow.com/a/2642731
possible better answer: http://stackoverflow.com/a/2642666
favorite count: 0
has answer: http://stackoverflow.com/a/2643013
has comment: http://stackoverflow.com/comment/2657572
has answer: http://stackoverflow.com/a/2644064
type: AnsweredQuestion
upvote count: 1
type: Question
answer count: 8
score: 1
has answer: http://stackoverflow.com/a/2642664
tagged with: java
has body: I have a program in which I need to store a Class object into memory by casting it into String. Is it possible to convert the String back into the original Class so that I can use that class variables? I am doing this in JAVA. Example: test.java class hello{ public String h1; public String h2; } public class test { public static void main(String[] args) { hello h = new hello(); h.h1 = "hello"; h.h2 = "world"; String s = h.toString(); System.out.println("Print s : "+s); // Now I need to convert String s into type hello so that // I can do this: // (hello)s.h1; // (hello)s.h2; } } NOTE: this is not a homework, this is a personal project and I would be grateful if anyone can help! Thanks! Ivar
has comment: http://stackoverflow.com/comment/2667973
has title: Casting Class into String and vice versa in Java
has answer: http://stackoverflow.com/a/2642731
has answer: http://stackoverflow.com/a/2642666
has comment: http://stackoverflow.com/comment/2657580

http://stackoverflow.com/q/2619435
has answer: http://stackoverflow.com/a/44668007
downvote count: 0
favorite count: 0
has body: I am trying to make a very simple web-service which does the following: The client hits the web service requesting a file. The web service's service class queries a hashtable which has the key (search query) and the value as the base64encoded value of a file (say a pdf) Now,I need to use MTOM to return the base64encoded value stored in the hashtable to the client. It's upto the client to decode it and convert it to pdf. So, here are my questions: I understand we encode files to base64 for transmission via web service, but where and how does MTOM come into the picture there? Can some one provide me a simple method which uses MTOM and sends the data back. Do we need to specify something in the WSDL too? or a simple String return type would suffice? Why/Why not? Thanks I have seen this code. It uses a lot of annotations, I just need a simple java code using MTOM. New to J2EE HERE :) UPDATE 1 Decent enough explanation here, now I need to understand it from the implementation level. Good info here, but for .Net UPDATE 2 What should be the return type of the method "createMTOM(int id)"??
has answer: http://stackoverflow.com/a/2619532
has title: How does MTOM work + sample code
possible better answer: http://stackoverflow.com/a/14087420
has answer: http://stackoverflow.com/a/14087420
tagged with: web-services
type: AnsweredQuestion
linked to: http://stackoverflow.com/q/215741
tagged with: java
accepted answer: http://stackoverflow.com/a/2619532
type: Question
score: 9
upvote count: 9
linked to: http://stackoverflow.com/q/1113656
tagged with: mtom
answer count: 3

inheritance
tags question: http://stackoverflow.com/q/2726119
tags question: http://stackoverflow.com/q/2709678
tags question: http://stackoverflow.com/q/2621733
tags question: http://stackoverflow.com/q/2700680
tags question: http://stackoverflow.com/q/2648758
tag name: inheritance
tags question: http://stackoverflow.com/q/2611015
type: Tag
tags question: http://stackoverflow.com/q/2744851
tags question: http://stackoverflow.com/q/2622240
tags question: http://stackoverflow.com/q/2713025
tags question: http://stackoverflow.com/q/2692343
tags question: http://stackoverflow.com/q/2651221
tags question: http://stackoverflow.com/q/2745265
tags question: http://stackoverflow.com/q/2772136
tags question: http://stackoverflow.com/q/2768748
tags question: http://stackoverflow.com/q/2626482
tags question: http://stackoverflow.com/q/2620728
tags question: http://stackoverflow.com/q/2601616
tags question: http://stackoverflow.com/q/2646960
tags question: http://stackoverflow.com/q/2686181

http://stackoverflow.com/q/2667851
tagged with: java
possible better answer: http://stackoverflow.com/a/11321223
has answer: http://stackoverflow.com/a/2674676
type: Question
has body: Atomikos is quite verbose when used. There seems to be lots of INFO messages (mostly irrelevant for me) that the transaction manager writes out to the console. The setting in the transaction.properties that is suppose to control the level of messaging com.atomikos.icatch.console_log_level does not seem to have any effect, since even when set to WARN (or ERROR) the INFO messages are still logged. Also the log4j settings for com.atomikos and atomikos seem to be ignored. Does anyone manage to turn off the INFO logs on the console with Atomikos?. How? Thanks Peter
tagged with: atomikos
score: 3
has title: How to set Atomikos to not write to console logs?
has answer: http://stackoverflow.com/a/2716614
upvote count: 3
has answer: http://stackoverflow.com/a/10834689
has answer: http://stackoverflow.com/a/11321223
downvote count: 0
favorite count: 0
accepted answer: http://stackoverflow.com/a/2674676
answer count: 4
type: AnsweredQuestion

http://stackoverflow.com/a/2774979
accepted answer of: http://stackoverflow.com/q/2714588
score: 3
answers question: http://stackoverflow.com/q/2714588
downvote count: 0
upvote count: 3
type: AcceptedAnswer
has body: I have determined though further research that trying to compile all these fragments at once is impossible, due to the name-space collision. The work around I decided upon was to compile each set of schema subsets into their own packages, and perform a heuristic test on the incoming XML before attempting to unmarshal it.
type: Answer

http://stackoverflow.com/comment/2819373
comment on: http://stackoverflow.com/a/2784095
score: 0
type: AnswerComment
type: Comment
has text: nice clever solution, but it won't show the body of the method too... only the name.

hashmap
tags question: http://stackoverflow.com/q/2686092
tags question: http://stackoverflow.com/q/2684823
tags question: http://stackoverflow.com/q/2688629
tags question: http://stackoverflow.com/q/2704882
tags question: http://stackoverflow.com/q/2632003
type: Tag
tags question: http://stackoverflow.com/q/2704080
tags question: http://stackoverflow.com/q/2762093
tags question: http://stackoverflow.com/q/2627889
tags question: http://stackoverflow.com/q/2774608
tags question: http://stackoverflow.com/q/2776819
tags question: http://stackoverflow.com/q/2633524
tags question: http://stackoverflow.com/q/2779251
tags question: http://stackoverflow.com/q/2665780
tag name: hashmap
tags question: http://stackoverflow.com/q/2773824
tags question: http://stackoverflow.com/q/2656995

http://stackoverflow.com/a/2607335
has comment: http://stackoverflow.com/comment/116836949
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/94846770
upvote count: 1754
answers question: http://stackoverflow.com/q/2607289
has comment: http://stackoverflow.com/comment/112255913
has comment: http://stackoverflow.com/comment/83147250
accepted answer of: http://stackoverflow.com/q/2607289
has comment: http://stackoverflow.com/comment/73726967
type: Answer
has comment: http://stackoverflow.com/comment/42066509
has comment: http://stackoverflow.com/comment/42032715
has comment: http://stackoverflow.com/comment/36683302
has comment: http://stackoverflow.com/comment/27050473
has body: In your example, it is because you can't have a List of a primitive type. In other words, List&lt;int&gt; is not possible. You can, however, have a List&lt;Integer&gt; using the Integer class that wraps the int primitive. Convert your array to a List with the Arrays.asList utility method. Integer[] numbers = new Integer[] { 1, 2, 3 }; List&lt;Integer&gt; list = Arrays.asList(numbers); See this code run live at IdeOne.com.
has comment: http://stackoverflow.com/comment/65636767
score: 1746
downvote count: 8
has comment: http://stackoverflow.com/comment/79729910
has comment: http://stackoverflow.com/comment/101158829
has comment: http://stackoverflow.com/comment/101158855
has comment: http://stackoverflow.com/comment/120520774
has comment: http://stackoverflow.com/comment/34949367
has comment: http://stackoverflow.com/comment/91566631
has comment: http://stackoverflow.com/comment/36680141
has comment: http://stackoverflow.com/comment/36680762

jvm
tags question: http://stackoverflow.com/q/2766538
tags question: http://stackoverflow.com/q/2710498
tags question: http://stackoverflow.com/q/2758289
type: Tag
tags question: http://stackoverflow.com/q/2762922
tags question: http://stackoverflow.com/q/2678423
tags question: http://stackoverflow.com/q/2693048
tags question: http://stackoverflow.com/q/2699354
tags question: http://stackoverflow.com/q/2734807
tags question: http://stackoverflow.com/q/2771868
tags question: http://stackoverflow.com/q/2715013
tags question: http://stackoverflow.com/q/2632362
tag name: jvm
tags question: http://stackoverflow.com/q/2609706
tags question: http://stackoverflow.com/q/2653458
tags question: http://stackoverflow.com/q/2743106
tags question: http://stackoverflow.com/q/2601233
tags question: http://stackoverflow.com/q/2674292
tags question: http://stackoverflow.com/q/2599973
tags question: http://stackoverflow.com/q/2723581
tags question: http://stackoverflow.com/q/2739539
tags question: http://stackoverflow.com/q/2646739
tags question: http://stackoverflow.com/q/2740725
tags question: http://stackoverflow.com/q/2744817

http://stackoverflow.com/comment/2648188
has text: Another thing you can do (if what Greg suggests fails, for example for network topology reasons) is to use either QP or Base64, and put one character at the beginning to let the other side know which one it is. This is certainly easy enough, on both encoder and decoder...
type: AnswerComment
score: 0
type: Comment
comment on: http://stackoverflow.com/a/2634149

buildpath
type: Tag
tags question: http://stackoverflow.com/q/2737486
tags question: http://stackoverflow.com/q/2727669
tag name: buildpath

http://stackoverflow.com/q/2711301
answer count: 1
has title: How can i make projects bound to eachother in eclipse?
favorite count: 0
tagged with: binding
score: 2
type: AnsweredQuestion
downvote count: 0
accepted answer: http://stackoverflow.com/a/2711319
has comment: http://stackoverflow.com/comment/2736295
type: Question
tagged with: java
has answer: http://stackoverflow.com/a/2711319
has body: I have 3 projects in Eclipse that are bound to eachother. With bound i mean this: Everytime i add a class in one of the projects, the other projects also updates themselves and add the class Now i want to add another project to these, but i don't know how to bind it together with the other projects. Any suggestions? Edit: alt text http://img218.imageshack.us/img218/8441/eclipsesymbol2.png This is how the projects are listed in eclipse. Any explanation about the [smax3]? Any explanation about the ">"? Thanks Thanks in advance!
tagged with: eclipse
upvote count: 2

jdialog
type: Tag
tags question: http://stackoverflow.com/q/2620448
tags question: http://stackoverflow.com/q/2665355
tag name: jdialog
tags question: http://stackoverflow.com/q/2632012

http://stackoverflow.com/comment/2812481
has text: I find myself required to state that `min` is less than `guess` (and/)or `max` is greater than `guess`. Consider `guess` as `Integer.MAX_VALUE` and `Integer.MIN_VALUE` for example.
comment on: http://stackoverflow.com/a/2777894
score: 0
type: Comment
type: AnswerComment

http://stackoverflow.com/q/2712967
has comment: http://stackoverflow.com/comment/2737888
has body: Can anyone explain me what's wrong with the following code? I tried different hosts, FTPClientConfigs, it's properly accessible via firefox/filezilla... The problem is I always get empty filelist without any exceptions (files.length == 0). I use commons-net-2.1.jar installed with Maven. FTPClientConfig config = new FTPClientConfig(FTPClientConfig.SYST_L8); FTPClient client = new FTPClient(); client.configure(config); client.connect("c64.rulez.org"); client.login("anonymous", "anonymous"); client.enterRemotePassiveMode(); FTPFile[] files = client.listFiles(); Assert.assertTrue(files.length &gt; 0);
has comment: http://stackoverflow.com/comment/2737843
has answer: http://stackoverflow.com/a/44317591
has answer: http://stackoverflow.com/a/5183296
accepted answer: http://stackoverflow.com/a/5183296
favorite count: 0
has comment: http://stackoverflow.com/comment/2739099
has comment: http://stackoverflow.com/comment/2737973
answer count: 4
has answer: http://stackoverflow.com/a/3480066
score: 41
downvote count: 0
has title: Apache Commons Net FTPClient and listFiles()
tagged with: ftp-client
has comment: http://stackoverflow.com/comment/2737938
type: AnsweredQuestion
tagged with: apache-commons
tagged with: java
has answer: http://stackoverflow.com/a/65463039
type: Question
upvote count: 41
possible better answer: http://stackoverflow.com/a/44317591

http://stackoverflow.com/comment/2629219
score: 0
type: Comment
type: QuestionComment
has text: I think the question might be clearer if you could show the code for what you are trying to do.
comment on: http://stackoverflow.com/q/2617369

http://stackoverflow.com/comment/55789569
type: Comment
score: 5
has text: Or similarly: `int index = 0; for (Object key : map.keySet()) { `Object value = map.get(key); ++index; } // dang formatting
type: AnswerComment
comment on: http://stackoverflow.com/a/2686109

http://stackoverflow.com/comment/9979768
type: Comment
has text: btw, if you are not to ignore interrupted flag the loop shall check `Thread.interrupted()` as well.
comment on: http://stackoverflow.com/a/2779565
score: 1
type: AnswerComment

http://stackoverflow.com/a/2724558
has body: Ehcache uses a different architecture with peers and synchronizing using multicasts. Check the documentation
downvote count: 0
type: Answer
upvote count: 1
score: 1
answers question: http://stackoverflow.com/q/2723815

http://stackoverflow.com/a/2611873
type: Answer
upvote count: 3
has body: You have a deadlock. However, you do not have a cycle, which is what the ThreadMXBean#findDeadlockedThreads method states it searches for. From the javadoc: Finds cycles of threads that are in deadlock waiting to acquire object monitors or ownable synchronizers. Threads are deadlocked in a cycle waiting for a lock of these two types if each thread owns one lock while trying to acquire another lock already held by another thread in the cycle. In this case, the main thread is waiting on the results of a Future. While another thread (which holds no locks) is waiting for the main thread to release its locks.
accepted answer of: http://stackoverflow.com/q/2609036
answers question: http://stackoverflow.com/q/2609036
type: AcceptedAnswer
downvote count: 0
score: 3

http://stackoverflow.com/a/2601803
has comment: http://stackoverflow.com/comment/2611087
has comment: http://stackoverflow.com/comment/2611587
type: Answer
has comment: http://stackoverflow.com/comment/74898595
has comment: http://stackoverflow.com/comment/2611053
downvote count: 2
upvote count: 1
has body: I think that new URL(yourString) will do the trick: it is supposed to raise MalformedURLException if url is not compliant (actually on java api it says If the string specifies an unknown protocol, but you can try it anyway): try { new URL(string); } catch (MalformedURLException e) { //do whatever }
answers question: http://stackoverflow.com/q/2601780
has comment: http://stackoverflow.com/comment/2611097
score: -1
has comment: http://stackoverflow.com/comment/2611076

http://stackoverflow.com/q/2614072
has answer: http://stackoverflow.com/a/32318317
tagged with: declaration
type: Question
answer count: 8
has comment: http://stackoverflow.com/comment/51706747
tagged with: java
accepted answer: http://stackoverflow.com/a/2614178
upvote count: 49
has answer: http://stackoverflow.com/a/41705074
has answer: http://stackoverflow.com/a/38497573
has body: I find the defs circular, the subjects are defined by their verbs but the verbs are undefined! So how do you define them? The Circular Definitions initialization: to initialize a variable. It can be done at the time of declaration. assignment: to assign value to a variable. It can be done anywhere, only once with the final-identifier. declaration: to declare value to a variable. [update, trying to understand the topic with lambda calc] D(x type) = (λx.x is declared with type) A(y D(x type)) = (λy.y is assigned to D(x type)) %Then after some beta reductions we get initialization. D(x type) me human // "me" declared with type "human" A(y (D(x type) me human)) asking // "asking" assigned to the last declaration %if the last two statemets are valid, an initialization exists. Right?
has answer: http://stackoverflow.com/a/2614097
has answer: http://stackoverflow.com/a/2614080
downvote count: 0
has answer: http://stackoverflow.com/a/65391309
has title: Java: define terms initialization, declaration and assignment
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2614422
tagged with: variable-assignment
has answer: http://stackoverflow.com/a/2614422
score: 49
has answer: http://stackoverflow.com/a/2614178
tagged with: initialization
favorite count: 0

http://stackoverflow.com/q/2768747
has title: How to make GridLayout row fill availible space?
accepted answer: http://stackoverflow.com/a/2773860
score: 0
tagged with: swt
type: AnsweredQuestion
tagged with: java
has answer: http://stackoverflow.com/a/2773860
type: Question
answer count: 1
has body: I have a GridLayout. I have two rows. I want one row to take up 500 pixels. I want the other row to take up the rest of the space. How can I do this?

http://stackoverflow.com/q/2631684
has answer: http://stackoverflow.com/a/2631699
has answer: http://stackoverflow.com/a/2631707
has answer: http://stackoverflow.com/a/2631705
has answer: http://stackoverflow.com/a/2632266
has body: I had a problem making a Blackberry app. I found some guy who made a tutorial which did what I attempted with mine. I copied the code of the tutorial's app to try and recreate it, just to see it in action. The result: Null Pointer Exception. I want to know what is triggering this. How can I?
tagged with: java
has answer: http://stackoverflow.com/a/2632620
tagged with: blackberry
type: Question
has title: How can I know where a Null Pointer Exception originated?
score: 4
has answer: http://stackoverflow.com/a/2642561
upvote count: 4
has answer: http://stackoverflow.com/a/2635023
downvote count: 0
answer count: 7
has comment: http://stackoverflow.com/comment/31307190
favorite count: 0
tagged with: nullpointerexception
type: UnansweredQuestion
linked to: http://stackoverflow.com/q/2411487

http://stackoverflow.com/q/2752094
has answer: http://stackoverflow.com/a/2752190
answer count: 3
downvote count: 0
tagged with: data-structures
has answer: http://stackoverflow.com/a/2752857
favorite count: 0
has body: I've started working on some Android applications and have a question regarding how people normally deal with situations where you have a static data set and have an application where that data is needed in memory as one of the standard java collections or as an array. In my current specific issue i have a spreadsheet with some pre-calculated data. It consists of ~100 rows and 3 columns. 1 Column is a string, 1 column is a float, 1 column is an integer. I need access to this data as an array in java. It seems like i could: 1) Encode in XML - This would be cpu intensive to decode in my experience. 2) build into SQLite database - seems like a lot of overhead for static access to data i only need array style access to in ram. 3) Build into binary blob and read in. (never done this in java, i miss void *) 4) Build a python script to take the CSV version of my data and spit out a java function that adds the values to my desired structure with hard coded values. 5) Store a string array via androids resource mechanism and compute the other 2 columns on application load. In my case the computation would require a lot of calls to Math.log, Math.pow and Math.floor which i'd rather not have to do for load time and battery usage reasons. I mostly work in low power embedded applications in C and as such #4 is what i'm used to doing in these situations. It just seems like it should be far easier to gain access to static data structures in java/android. Perhaps I'm just being too battery usage conscious and in my single case i imagine the answer is that it doesn't matter much, but if every application took that stance it could begin to matter. What approaches do people usually take in this situation? Anything I missed?
tagged with: static
accepted answer: http://stackoverflow.com/a/2752190
tagged with: android
has answer: http://stackoverflow.com/a/2752407
type: AnsweredQuestion
score: 2
upvote count: 2
possible better answer: http://stackoverflow.com/a/2752407
type: Question
has title: Static Data Structures on Embedded Devices (Android in particular)
tagged with: java

http://stackoverflow.com/comment/2800162
comment on: http://stackoverflow.com/a/2748878
type: Comment
has text: I tried the other way around, connecting to Windows from Unix and it worked successfully. Also, I did not need to give "java.rmi.server.hostname" when running server on Windows. I wonder if the information I have given below could be of any help! System.out.println for Registry object:: Windows--> RegistryImpl[UnicastServerRef [liveRef: [endpoint:[<MyMachinesIPNo>:1099](local),objID:[0:0:0, 0]]]] Unix--> gnu.java.rmi.server.UnicastServerRef@410e590 Host file contents:: Windows--> 127.0.0.1 localhost Unix--> 127.0.0.1 <Server-name> localhost.localdomain localhost
score: 0
type: AnswerComment

http://stackoverflow.com/q/2786038
tagged with: java
has answer: http://stackoverflow.com/a/2786052
linked to: http://stackoverflow.com/q/2699209
type: Question
accepted answer: http://stackoverflow.com/a/2786056
has answer: http://stackoverflow.com/a/2786656
has answer: http://stackoverflow.com/a/2786057
answer count: 6
score: 4
upvote count: 4
linked to: http://stackoverflow.com/q/1747040
has answer: http://stackoverflow.com/a/2787305
downvote count: 0
favorite count: 0
linked to: http://stackoverflow.com/q/46898
has title: How to write a hashtable<string, string > in to text file,java?
linked to: http://stackoverflow.com/q/40471
has answer: http://stackoverflow.com/a/2786049
has answer: http://stackoverflow.com/a/2786056
has body: I have hastable htmlcontent is html string of urlstring . I want to write hastable into a .text file . Can anyone suggest a solution?
tagged with: hashtable
type: AnsweredQuestion
possible better answer: http://stackoverflow.com/a/2786049

http://stackoverflow.com/q/2739186
upvote count: 16
has answer: http://stackoverflow.com/a/28505242
has answer: http://stackoverflow.com/a/21474806
type: AnsweredQuestion
tagged with: java
has body: I was wondering what is the easiest way to change the height of a ProgressBar in Android? Thanks, Tomek
type: Question
has answer: http://stackoverflow.com/a/37528537
tagged with: layout
downvote count: 0
tagged with: progress-bar
possible better answer: http://stackoverflow.com/a/28505242
tagged with: android
tagged with: user-interface
has title: Android: How do I change the height of a ProgressBar?
answer count: 4
favorite count: 0
has answer: http://stackoverflow.com/a/2739245
accepted answer: http://stackoverflow.com/a/2739245
score: 16

http://stackoverflow.com/a/2753542
downvote count: 0
score: 1
answers question: http://stackoverflow.com/q/2749889
upvote count: 1
has body: My advice is to power through a university's course on Java (not sure how many offer Python?) and perhaps their lower level data structures units and algorithms units. A lot of universities have their notes online, accessible to everyone. They will generally be a good guide to the basics that you should know, once you have the basics down you should have some idea of what you are missing and also how to fix the missing gaps in logical ways. At the very least, they provide a list of topics that you might want to know about. Once you have the basics down you can start to do the things you want to do.
type: Answer

http://stackoverflow.com/a/45553465
downvote count: 0
type: Answer
upvote count: 6
has comment: http://stackoverflow.com/comment/101127771
score: 6
has body: If you interested in showing the Latitude and Longitude from the current direction , you can use this : Directions are always given from the users current location. The following query will help you perform that . You can pass the destination latitude and longitude here: google.navigation:q=latitude,longitude Use above as: Uri gmmIntentUri = Uri.parse("google.navigation:q=latitude,longitude"); Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); mapIntent.setPackage("com.google.android.apps.maps"); startActivity(mapIntent); Or if you want to show via location , use: google.navigation:q=a+street+address More Info here: Google Maps Intents for Android
answers question: http://stackoverflow.com/q/2662531

http://stackoverflow.com/a/2681509
type: Answer
has body: Instrumentation.getInitiatedClasses(ClassLoader) may do what you want. According to the docs: Returns an array of all classes for which loader is an initiating loader. I'm not sure what "initiating loader" means though. If that does not give the right result try using the getAllLoadedClasses() method and manually filtering by ClassLoader. How to get an instance of Instrumentation Only the agent JAR (which is separate from the application JAR) can get an instance of the Instrumentation interface. A simple way to make it available to the application is to create an agent JAR containing one class with a premain method that does nothing but save a reference to the Instrumentation instance in the system properties. Example agent class: public class InstrumentHook { public static void premain(String agentArgs, Instrumentation inst) { if (agentArgs != null) { System.getProperties().put(AGENT_ARGS_KEY, agentArgs); } System.getProperties().put(INSTRUMENTATION_KEY, inst); } public static Instrumentation getInstrumentation() { return (Instrumentation) System.getProperties().get(INSTRUMENTATION_KEY); } // Needn't be a UUID - can be a String or any other object that // implements equals(). private static final Object AGENT_ARGS_KEY = UUID.fromString("887b43f3-c742-4b87-978d-70d2db74e40e"); private static final Object INSTRUMENTATION_KEY = UUID.fromString("214ac54a-60a5-417e-b3b8-772e80a16667"); } Example manifest: Manifest-Version: 1.0 Premain-Class: InstrumentHook The resulting JAR must then be referenced by the application and specified on the command line (with the -javaagent option) when launching the application. It might be loaded twice in different ClassLoaders, but that is not a problem since the system Properties is a per-process singleton. Example application class public class Main { public static void main(String[] args) { Instrumentation inst = InstrumentHook.getInstrumentation(); for (Class&lt;?&gt; clazz: inst.getAllLoadedClasses()) { System.err.println(clazz.getN…
has comment: http://stackoverflow.com/comment/13193950
answers question: http://stackoverflow.com/q/2681459
has comment: http://stackoverflow.com/comment/13193985
downvote count: 1
has comment: http://stackoverflow.com/comment/2701204
has comment: http://stackoverflow.com/comment/2701227
score: 37
has comment: http://stackoverflow.com/comment/98468646
accepted answer of: http://stackoverflow.com/q/2681459
type: AcceptedAnswer
has comment: http://stackoverflow.com/comment/2702035
upvote count: 38
has comment: http://stackoverflow.com/comment/2703507

http://stackoverflow.com/a/2761961
upvote count: 13
has comment: http://stackoverflow.com/comment/2822078
has comment: http://stackoverflow.com/comment/2823141
has body: I'm afraid you won't like the answer. GAE JDO has to be used a very specific way and is fraught with limitations that you have to observe to use it effectively. Read the docs forwards and backwards. For the issue you are seeing now, you probably need to read this section a couple of times: http://code.google.com/appengine/docs/java/datastore/relationships.html GAE JDO has owned and unowned relationships. See the documentation above for examples of owned vs unowned. I believe you want Car and User to have an unowned relationship. Note this revelation in the Google App Engine documentation about unowned relationships: http://code.google.com/appengine/docs/java/datastore/relationships.html#Unowned_Relationships In addition to owned relationships, the JDO API also provides a facility for managing unowned relationships. The App Engine implementation of JDO does not yet implement this facility, but don't worry, you can still manage these relationships using Key values in place of instances (or Collections of instances) of your model objects. This essentially means, to use GAE JDO, you should not use a direct reference for an unowned relationship like between the Car and User classes. Rather, you should use indirect references between them, i.e. Car should have a field for the User's key rather than a direct reference to the User itself. Some of the trouble you are having is because GAE JDO cannot deal with how you are modeling this relationship in code. Asker goes on to say: Went to the link suggested there, that explains how to create Keys, however they keep talking about "Entity Groups" and "Entity Group Parents". But I cant seem to find any articles or sites that explain what are "Entity Group"s or an "Entity Group Parents" Entity Group - a graph of objects that were initially persisted together. For example, because Car refers directly to a User, when you persist a given Car instance for the first time, then you would also persist the User instance to which it refers …
has comment: http://stackoverflow.com/comment/2827293
type: AcceptedAnswer
downvote count: 0
answers question: http://stackoverflow.com/q/2759805
accepted answer of: http://stackoverflow.com/q/2759805
has comment: http://stackoverflow.com/comment/2823915
type: Answer
score: 13